Updated a file

This commit is contained in:
EmotionChild 2022-04-18 22:59:52 +12:00
parent 8408ddce01
commit 94324f4d4a
No known key found for this signature in database
GPG key ID: 23DC06AC32786520

View file

@ -29,7 +29,7 @@ namespace SupportChild
Console.WriteLine("Starting SupportChild version " + GetVersion() + "..."); Console.WriteLine("Starting SupportChild version " + GetVersion() + "...");
try try
{ {
Reload(); this.Reload();
// Block this task until the program is closed. // Block this task until the program is closed.
await Task.Delay(-1); await Task.Delay(-1);
@ -55,10 +55,10 @@ namespace SupportChild
public async void Reload() public async void Reload()
{ {
if (discordClient != null) if (this.discordClient != null)
{ {
await discordClient.DisconnectAsync(); await this.discordClient.DisconnectAsync();
discordClient.Dispose(); this.discordClient.Dispose();
Console.WriteLine("Discord client disconnected."); Console.WriteLine("Discord client disconnected.");
} }
@ -104,20 +104,20 @@ namespace SupportChild
Intents = DiscordIntents.All Intents = DiscordIntents.All
}; };
discordClient = new DiscordClient(cfg); this.discordClient = new DiscordClient(cfg);
eventHandler = new EventHandler(discordClient); this.eventHandler = new EventHandler(this.discordClient);
Console.WriteLine("Hooking events..."); Console.WriteLine("Hooking events...");
discordClient.Ready += eventHandler.OnReady; this.discordClient.Ready += this.eventHandler.OnReady;
discordClient.GuildAvailable += eventHandler.OnGuildAvailable; this.discordClient.GuildAvailable += this.eventHandler.OnGuildAvailable;
discordClient.ClientErrored += eventHandler.OnClientError; this.discordClient.ClientErrored += this.eventHandler.OnClientError;
discordClient.MessageCreated += eventHandler.OnMessageCreated; this.discordClient.MessageCreated += this.eventHandler.OnMessageCreated;
discordClient.GuildMemberAdded += eventHandler.OnMemberAdded; this.discordClient.GuildMemberAdded += this.eventHandler.OnMemberAdded;
discordClient.GuildMemberRemoved += eventHandler.OnMemberRemoved; this.discordClient.GuildMemberRemoved += this.eventHandler.OnMemberRemoved;
if (Config.reactionMessage != 0) if (Config.reactionMessage != 0)
{ {
discordClient.MessageReactionAdded += eventHandler.OnReactionAdded; this.discordClient.MessageReactionAdded += this.eventHandler.OnReactionAdded;
} }
Console.WriteLine("Registering commands..."); Console.WriteLine("Registering commands...");
@ -154,10 +154,10 @@ namespace SupportChild
this.commands.RegisterCommands<UnsetTicketCommand>(); this.commands.RegisterCommands<UnsetTicketCommand>();
Console.WriteLine("Hooking command events..."); Console.WriteLine("Hooking command events...");
this.commands.CommandErrored += eventHandler.OnCommandError; this.commands.CommandErrored += this.eventHandler.OnCommandError;
Console.WriteLine("Connecting to Discord..."); Console.WriteLine("Connecting to Discord...");
await discordClient.ConnectAsync(); await this.discordClient.ConnectAsync();
} }
} }
} }