Nuget package updates

- discord
- changes InteractiveBase to ModuleBase
This commit is contained in:
Brett Hewitson 2022-06-21 23:44:14 +10:00
parent f416b5cd78
commit e12fd0e6e9
5 changed files with 19 additions and 15 deletions

View file

@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Addons.Interactive;
using Discord.Commands;
using ServerManagerTool.DiscordBot.Delegates;
using ServerManagerTool.DiscordBot.Enums;
@ -10,7 +9,7 @@ using ServerManagerTool.DiscordBot.Interfaces;
namespace ServerManagerTool.DiscordBot.Modules
{
[Name("Server Commands")]
public sealed class ServerCommandModule : InteractiveBase
public sealed class ServerCommandModule : ModuleBase<SocketCommandContext>
{
private const int COMMAND_RESPONSE_DELAY = 500;

View file

@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Addons.Interactive;
using Discord.Commands;
using ServerManagerTool.DiscordBot.Delegates;
using ServerManagerTool.DiscordBot.Enums;
@ -10,7 +9,7 @@ using ServerManagerTool.DiscordBot.Interfaces;
namespace ServerManagerTool.DiscordBot.Modules
{
[Name("Server Query")]
public sealed class ServerQueryModule : InteractiveBase
public sealed class ServerQueryModule : ModuleBase<SocketCommandContext>
{
private const int COMMAND_RESPONSE_DELAY = 500;

View file

@ -12,8 +12,7 @@
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Addons.Interactive" Version="2.0.0" />
<PackageReference Include="Discord.Net" Version="2.4.0" />
<PackageReference Include="Discord.Net" Version="3.7.2" />
<PackageReference Include="Discord.Net.Providers.WS4Net" Version="2.4.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />

View file

@ -1,5 +1,5 @@
using Discord.Addons.Interactive;
using Discord.Commands;
using Discord.Commands;
using Discord.Interactions;
using Discord.Net.Providers.WS4Net;
using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
@ -69,26 +69,33 @@ namespace ServerManagerTool.DiscordBot
var commandConfig = new CommandServiceConfig
{
// Force all commands to run async
DefaultRunMode = RunMode.Async,
DefaultRunMode = Discord.Commands.RunMode.Async,
LogLevel = LogLevelHelper.GetLogSeverity(discordBotConfig.LogLevel),
CaseSensitiveCommands = false,
};
var interactionConfig = new InteractionServiceConfig
{
// Force all interactions to run async
DefaultRunMode = Discord.Interactions.RunMode.Async,
LogLevel = LogLevelHelper.GetLogSeverity(discordBotConfig.LogLevel),
};
// Build the service provider
var services = new ServiceCollection()
.AddSingleton(config)
.AddSingleton(discordBotConfig)
// Add the discord client to the service provider
.AddSingleton(new DiscordSocketClient(socketConfig))
// Add the command service to the service provider
.AddSingleton(new CommandService(commandConfig))
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>(), interactionConfig))
// Add remaining services to the provider
.AddSingleton<CommandHandlerService>()
.AddSingleton<InteractiveService>()
.AddSingleton<LoggingService>()
.AddSingleton<StartupService>()
.AddSingleton<ShutdownService>()
.AddSingleton<Random>()
.AddSingleton(config)
.AddSingleton(discordBotConfig)
.AddSingleton(handleCommandCallback)
.AddSingleton(handleTranslationCallback)
.AddSingleton<IServerManagerBot>(this);

View file

@ -33,13 +33,13 @@ namespace ServerManagerTool.DiscordBot.Services
throw new Exception("#DiscordBot_MissingTokenError");
}
// Load commands and modules into the command service
await _commands.AddModulesAsync(Assembly.GetExecutingAssembly(), _services);
// Login to discord
await _client.LoginAsync(TokenType.Bot, discordToken);
// Connect to the websocket
await _client.StartAsync();
// Load commands and modules into the command service
await _commands.AddModulesAsync(Assembly.GetExecutingAssembly(), _services);
}
}
}