Added support for channel creation / deletion and joining / leaving stages for Discord

This commit is contained in:
barelyprofessional
2024-08-23 12:27:31 +08:00
parent 61f54c6958
commit 840fe19430
7 changed files with 3634 additions and 1 deletions

View File

@@ -430,9 +430,31 @@ public class ChatBot
_discord.OnInvalidCredentials += DiscordOnInvalidCredentials;
_discord.OnMessageReceived += DiscordOnMessageReceived;
_discord.OnPresenceUpdated += DiscordOnPresenceUpdated;
_discord.OnChannelCreated += DiscordOnChannelCreated;
_discord.OnChannelDeleted += DiscordOnChannelDeleted;
_discord.StartWsClient().Wait(_cancellationToken);
}
private void DiscordOnChannelDeleted(object sender, DiscordChannelDeletionModel channel)
{
_logger.Info($"Received channel deletion event of type {channel.Type} with name {channel.Name}");
if (channel.Type != DiscordChannelType.GuildText && channel.Type != DiscordChannelType.GuildVoice &&
channel.Type != DiscordChannelType.GuildStageVoice) return;
var discordIcon = Helpers.GetValue(BuiltIn.Keys.DiscordIcon).Result;
var channelName = channel.Name ?? "Unknown name";
SendChatMessage($"[img]{discordIcon.Value}[/img] Discord {channel.Type.Humanize()} channel {channelName} was deleted", true);
}
private void DiscordOnChannelCreated(object sender, DiscordChannelCreationModel channel)
{
_logger.Info($"Received channel creation event of type {channel.Type} with name {channel.Name}");
if (channel.Type != DiscordChannelType.GuildText && channel.Type != DiscordChannelType.GuildVoice &&
channel.Type != DiscordChannelType.GuildStageVoice) return;
var discordIcon = Helpers.GetValue(BuiltIn.Keys.DiscordIcon).Result;
var channelName = channel.Name ?? "Unknown name";
SendChatMessage($"[img]{discordIcon.Value}[/img] New Discord {channel.Type.Humanize()} channel created: {channelName}", true);
}
private void BuildTwitchChat()
{
var settings = Helpers.GetMultipleValues([BuiltIn.Keys.TwitchBossmanJackUsername, BuiltIn.Keys.Proxy]).Result;
@@ -485,6 +507,19 @@ public class ChatBot
{
return;
}
if (message.Type == DiscordMessageType.StageStart)
{
SendChatMessage($"[img]{settings[BuiltIn.Keys.DiscordIcon].Value}[/img] BossmanJack just started a stage called {message.Content} 🚨🚨",
true);
return;
}
if (message.Type == DiscordMessageType.StageEnd)
{
SendChatMessage($"[img]{settings[BuiltIn.Keys.DiscordIcon].Value}[/img] BossmanJack just ended a stage called {message.Content} :lossmanjack:",
true);
return;
}
var result = $"[img]{settings[BuiltIn.Keys.DiscordIcon].Value}[/img] BossmanJack: {message.Content}";
foreach (var attachment in message.Attachments ?? [])