Skip to content

Commit

Permalink
reordered Init to make startup more clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUbMunster committed Jul 11, 2023
1 parent cfe6c3e commit a5b8348
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Server/DiscordBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ private async Task Init()
});
try
{
await client.LoginAsync(Discord.TokenType.Bot, localSettings.Token);
await client.StartAsync();
SemaphoreSlim wait = new SemaphoreSlim(0);
#pragma warning disable CS1998
client.Ready += async () =>
#pragma warning restore CS1998
{
wait.Release();
};
await client.LoginAsync(Discord.TokenType.Bot, localSettings.Token);
await client.StartAsync();
await wait.WaitAsync();
//we need to wait for the ready event before we can do any of this nonsense.
logChannel = (ulong.TryParse(localSettings.AdminChannel, out ulong lcid) ? (client != null ? await client.GetChannelAsync(lcid) : null) : null) as SocketTextChannel;
Expand Down

0 comments on commit a5b8348

Please sign in to comment.