From 141da058f0dfb8eb71049ea00bbc6910591afd31 Mon Sep 17 00:00:00 2001 From: Winnie Date: Mon, 2 Sep 2024 21:32:20 +0200 Subject: [PATCH] more fixes --- Program.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Program.cs b/Program.cs index 8adfe42..0d5df62 100644 --- a/Program.cs +++ b/Program.cs @@ -66,6 +66,7 @@ static async Task Main(string[] args) await _client.LoginAsync(TokenType.Bot, token); await _client.StartAsync(); + // Prevent application from closing await Task.Delay(-1); } @@ -78,13 +79,14 @@ private static Task Log(LogMessage log) private static async Task OnReady() { Console.WriteLine("Bot is connected."); - await RegisterCommandsAsync(); - await ScheduleNextPost(); + + // Call asynchronous tasks without blocking + await Task.Run(() => RegisterCommandsAsync()).ConfigureAwait(false); + await Task.Run(() => ScheduleNextPost()).ConfigureAwait(false); } private static async Task RegisterCommandsAsync() { - // Register the command module await _commands.AddModuleAsync(_services); }