mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-18 09:35:48 +00:00
Nuget package updates
- discord - changes InteractiveBase to ModuleBase
This commit is contained in:
parent
f416b5cd78
commit
e12fd0e6e9
5 changed files with 19 additions and 15 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Addons.Interactive;
|
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using ServerManagerTool.DiscordBot.Delegates;
|
using ServerManagerTool.DiscordBot.Delegates;
|
||||||
using ServerManagerTool.DiscordBot.Enums;
|
using ServerManagerTool.DiscordBot.Enums;
|
||||||
|
|
@ -10,7 +9,7 @@ using ServerManagerTool.DiscordBot.Interfaces;
|
||||||
namespace ServerManagerTool.DiscordBot.Modules
|
namespace ServerManagerTool.DiscordBot.Modules
|
||||||
{
|
{
|
||||||
[Name("Server Commands")]
|
[Name("Server Commands")]
|
||||||
public sealed class ServerCommandModule : InteractiveBase
|
public sealed class ServerCommandModule : ModuleBase<SocketCommandContext>
|
||||||
{
|
{
|
||||||
private const int COMMAND_RESPONSE_DELAY = 500;
|
private const int COMMAND_RESPONSE_DELAY = 500;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Addons.Interactive;
|
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using ServerManagerTool.DiscordBot.Delegates;
|
using ServerManagerTool.DiscordBot.Delegates;
|
||||||
using ServerManagerTool.DiscordBot.Enums;
|
using ServerManagerTool.DiscordBot.Enums;
|
||||||
|
|
@ -10,7 +9,7 @@ using ServerManagerTool.DiscordBot.Interfaces;
|
||||||
namespace ServerManagerTool.DiscordBot.Modules
|
namespace ServerManagerTool.DiscordBot.Modules
|
||||||
{
|
{
|
||||||
[Name("Server Query")]
|
[Name("Server Query")]
|
||||||
public sealed class ServerQueryModule : InteractiveBase
|
public sealed class ServerQueryModule : ModuleBase<SocketCommandContext>
|
||||||
{
|
{
|
||||||
private const int COMMAND_RESPONSE_DELAY = 500;
|
private const int COMMAND_RESPONSE_DELAY = 500;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Addons.Interactive" Version="2.0.0" />
|
<PackageReference Include="Discord.Net" Version="3.7.2" />
|
||||||
<PackageReference Include="Discord.Net" Version="2.4.0" />
|
|
||||||
<PackageReference Include="Discord.Net.Providers.WS4Net" Version="2.4.0" />
|
<PackageReference Include="Discord.Net.Providers.WS4Net" Version="2.4.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using Discord.Addons.Interactive;
|
using Discord.Commands;
|
||||||
using Discord.Commands;
|
using Discord.Interactions;
|
||||||
using Discord.Net.Providers.WS4Net;
|
using Discord.Net.Providers.WS4Net;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
@ -69,26 +69,33 @@ namespace ServerManagerTool.DiscordBot
|
||||||
var commandConfig = new CommandServiceConfig
|
var commandConfig = new CommandServiceConfig
|
||||||
{
|
{
|
||||||
// Force all commands to run async
|
// Force all commands to run async
|
||||||
DefaultRunMode = RunMode.Async,
|
DefaultRunMode = Discord.Commands.RunMode.Async,
|
||||||
LogLevel = LogLevelHelper.GetLogSeverity(discordBotConfig.LogLevel),
|
LogLevel = LogLevelHelper.GetLogSeverity(discordBotConfig.LogLevel),
|
||||||
CaseSensitiveCommands = false,
|
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
|
// Build the service provider
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
|
.AddSingleton(config)
|
||||||
|
.AddSingleton(discordBotConfig)
|
||||||
// Add the discord client to the service provider
|
// Add the discord client to the service provider
|
||||||
.AddSingleton(new DiscordSocketClient(socketConfig))
|
.AddSingleton(new DiscordSocketClient(socketConfig))
|
||||||
// Add the command service to the service provider
|
// Add the command service to the service provider
|
||||||
.AddSingleton(new CommandService(commandConfig))
|
.AddSingleton(new CommandService(commandConfig))
|
||||||
|
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>(), interactionConfig))
|
||||||
// Add remaining services to the provider
|
// Add remaining services to the provider
|
||||||
.AddSingleton<CommandHandlerService>()
|
.AddSingleton<CommandHandlerService>()
|
||||||
.AddSingleton<InteractiveService>()
|
|
||||||
.AddSingleton<LoggingService>()
|
.AddSingleton<LoggingService>()
|
||||||
.AddSingleton<StartupService>()
|
.AddSingleton<StartupService>()
|
||||||
.AddSingleton<ShutdownService>()
|
.AddSingleton<ShutdownService>()
|
||||||
.AddSingleton<Random>()
|
.AddSingleton<Random>()
|
||||||
.AddSingleton(config)
|
|
||||||
.AddSingleton(discordBotConfig)
|
|
||||||
.AddSingleton(handleCommandCallback)
|
.AddSingleton(handleCommandCallback)
|
||||||
.AddSingleton(handleTranslationCallback)
|
.AddSingleton(handleTranslationCallback)
|
||||||
.AddSingleton<IServerManagerBot>(this);
|
.AddSingleton<IServerManagerBot>(this);
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,13 @@ namespace ServerManagerTool.DiscordBot.Services
|
||||||
throw new Exception("#DiscordBot_MissingTokenError");
|
throw new Exception("#DiscordBot_MissingTokenError");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load commands and modules into the command service
|
||||||
|
await _commands.AddModulesAsync(Assembly.GetExecutingAssembly(), _services);
|
||||||
|
|
||||||
// Login to discord
|
// Login to discord
|
||||||
await _client.LoginAsync(TokenType.Bot, discordToken);
|
await _client.LoginAsync(TokenType.Bot, discordToken);
|
||||||
// Connect to the websocket
|
// Connect to the websocket
|
||||||
await _client.StartAsync();
|
await _client.StartAsync();
|
||||||
|
|
||||||
// Load commands and modules into the command service
|
|
||||||
await _commands.AddModulesAsync(Assembly.GetExecutingAssembly(), _services);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue