Skip to content

Commit

Permalink
Fix components initializing each time the bot reconnect to gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Jun 18, 2020
1 parent df8c2a4 commit 6bfd7d7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions CHEF/CHEF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ private async Task MainAsync()
{
await SetupBotLogin();

_client.Ready += async () =>
{
Logger.Init(_client);
Database.Init();
await ComponentHandler.Init(_client);
};
_client.Ready += InitOnClientReady;
_client.Ready += UniqueInitOnClientReady;

await Task.Delay(-1);
}

private async Task InitOnClientReady()
{
Logger.Init(_client);
await Task.CompletedTask;
}

private async Task UniqueInitOnClientReady()
{
Database.Init();
await ComponentHandler.Init(_client);
_client.Ready -= UniqueInitOnClientReady;
}

private async Task SetupBotLogin()
{
var config = new DiscordSocketConfig { MessageCacheSize = 100 };
Expand Down

0 comments on commit 6bfd7d7

Please sign in to comment.