diff --git a/.gitignore b/.gitignore index 4ce6fdd..1979d27 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +output/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/Leviathan.Bot/Leviathan.Bot.csproj b/Leviathan.Bot/Leviathan.Bot.csproj index 667c616..e26d29b 100644 --- a/Leviathan.Bot/Leviathan.Bot.csproj +++ b/Leviathan.Bot/Leviathan.Bot.csproj @@ -9,20 +9,20 @@ - - - - - - - - - - + + + + + + + + + + - + diff --git a/Leviathan.Bot/Modules/SlashCommands.cs b/Leviathan.Bot/Modules/SlashCommands.cs index f6af19f..3150a3f 100644 --- a/Leviathan.Bot/Modules/SlashCommands.cs +++ b/Leviathan.Bot/Modules/SlashCommands.cs @@ -36,7 +36,7 @@ public async Task About() var devLocalizedString = LocalizationHelper.GetLocalizedString("Developer"); var inGameNickLocalizedString = LocalizationHelper.GetLocalizedString("DiscordAboutCommandInGameNick"); - await RespondAsync("Leviathan v1.0.5 - EVE Online Discord Bot\n" + + await RespondAsync("Leviathan v1.0.8 - EVE Online Discord Bot\n" + $"{devLocalizedString}: TheBottle ({inGameNickLocalizedString} The Bottle)\n\n" + $"{runTimeLocalizedString} {stringDate}"); } diff --git a/Leviathan.Bot/Program.cs b/Leviathan.Bot/Program.cs index 571f253..9a20bce 100644 --- a/Leviathan.Bot/Program.cs +++ b/Leviathan.Bot/Program.cs @@ -50,6 +50,7 @@ public async Task Start(string[] args) try { Log.Information("Starting bot host"); + var builder = CreateHostBuilder(args).Build(); _discordSocketClient = builder.Services.GetRequiredService(); await builder.Services.GetRequiredService().InitializeAsync(); @@ -65,6 +66,12 @@ await builder.Services.GetRequiredService() await _discordSocketClient.LoginAsync(TokenType.Bot, _settings.DiscordConfig.BotToken); await _discordSocketClient.StartAsync(); + while (true) + { + if (_discordSocketClient.ConnectionState == ConnectionState.Connected) break; + else Thread.Sleep(250); + } + await builder.RunAsync(); } catch (Exception ex) diff --git a/Leviathan.Bot/Services/CommandHandler.cs b/Leviathan.Bot/Services/CommandHandler.cs index 8e0ca4d..863c9fb 100644 --- a/Leviathan.Bot/Services/CommandHandler.cs +++ b/Leviathan.Bot/Services/CommandHandler.cs @@ -21,7 +21,19 @@ public CommandHandler(DiscordSocketClient client, InteractionService commands, I public async Task InitializeAsync() { - await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); + var currentAssembly = Assembly.GetEntryAssembly(); + + if (currentAssembly!.GetName().Name == "Leviathan.Bot") + { + await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); + } + else + { + var assembly = AppDomain.CurrentDomain.GetAssemblies() + .SingleOrDefault(assembly => assembly.GetName().Name == "Leviathan.Bot"); + + await _commands.AddModulesAsync(assembly, _services); + } _client.InteractionCreated += HandleInteraction; }