Skip to content

Commit

Permalink
Delay Comp init until bot is connected / db init
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Jun 18, 2020
1 parent dec5690 commit be4c15a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 2 additions & 4 deletions CHEF/CHEF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ private async Task MainAsync()
{
await SetupBotLogin();

await ComponentHandler.Init(_client);

_client.Ready += () =>
_client.Ready += async () =>
{
Logger.Init(_client);
Database.Init();
return Task.CompletedTask;
await ComponentHandler.Init(_client);
};

await Task.Delay(-1);
Expand Down
6 changes: 1 addition & 5 deletions CHEF/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ internal static void Init(DiscordSocketClient client)
var guild = client.GetGuild(ror2ServerId);
if (guild != null)
{
_reportToUser = guild.GetUser(iDeathHdId);
if (_reportToUser == null)
{
_reportToUser = _client.Rest.GetGuildUserAsync(ror2ServerId, iDeathHdId).Result;
}
_reportToUser = guild.GetUser(iDeathHdId) ?? (IGuildUser) _client.Rest.GetGuildUserAsync(ror2ServerId, iDeathHdId).Result;
}
}

Expand Down

0 comments on commit be4c15a

Please sign in to comment.