Discord Bot Changes

- Have added All Profiles Alias global settings
- Have changed the discord bot to handle the All Profile alias to performs commands against all profiles in the channel.
This commit is contained in:
Brett Hewitson 2022-04-14 21:06:14 +10:00
parent fc658b04dd
commit 1aa8d79108
19 changed files with 1227 additions and 1026 deletions

View file

@ -1,26 +1,25 @@
using Discord;
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Addons.Interactive;
using Discord.Commands;
using Microsoft.Extensions.Configuration;
using ServerManagerTool.DiscordBot.Delegates;
using ServerManagerTool.DiscordBot.Enums;
using ServerManagerTool.DiscordBot.Interfaces;
using System;
using System.Threading.Tasks;
namespace ServerManagerTool.DiscordBot.Modules
{
[Name("Server Commands")]
public sealed class ServerCommandModule : InteractiveBase
{
private const int COMMAND_RESPONSE_DELAY = 500;
private readonly IServerManagerBot _serverManagerBot;
private readonly CommandService _commands;
private readonly HandleCommandDelegate _handleCommandCallback;
public ServerCommandModule(IServerManagerBot serverManagerBot, CommandService commands, HandleCommandDelegate handleCommandCallback)
public ServerCommandModule(IServerManagerBot serverManagerBot, HandleCommandDelegate handleCommandCallback)
{
_serverManagerBot = serverManagerBot;
_commands = commands;
_handleCommandCallback = handleCommandCallback;
}
@ -45,8 +44,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -76,8 +77,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -107,8 +110,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -138,8 +143,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -169,8 +176,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -200,8 +209,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)

View file

@ -1,37 +1,28 @@
using Discord;
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Addons.Interactive;
using Discord.Commands;
using ServerManagerTool.DiscordBot.Delegates;
using ServerManagerTool.DiscordBot.Enums;
using ServerManagerTool.DiscordBot.Interfaces;
using System;
using System.Threading.Tasks;
namespace ServerManagerTool.DiscordBot.Modules
{
[Name("Server Query")]
public sealed class ServerQueryModule : InteractiveBase
{
private const int COMMAND_RESPONSE_DELAY = 500;
private readonly IServerManagerBot _serverManagerBot;
private readonly CommandService _commands;
private readonly HandleCommandDelegate _handleCommandCallback;
public ServerQueryModule(IServerManagerBot serverManagerBot, CommandService commands, HandleCommandDelegate handleCommandCallback)
public ServerQueryModule(IServerManagerBot serverManagerBot, HandleCommandDelegate handleCommandCallback)
{
_serverManagerBot = serverManagerBot;
_commands = commands;
_handleCommandCallback = handleCommandCallback;
}
[Command("info", RunMode = RunMode.Async)]
[Summary("Poll server for information")]
[Remarks("info")]
[RequireBotPermission(ChannelPermission.ViewChannel | ChannelPermission.SendMessages)]
public async Task ServerInfoAsync()
{
await ServerInfoAsync(null);
}
[Command("info", RunMode = RunMode.Async)]
[Summary("Poll server for information")]
[Remarks("info profileId|alias")]
@ -53,8 +44,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -84,8 +77,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)
@ -94,15 +89,6 @@ namespace ServerManagerTool.DiscordBot.Modules
}
}
[Command("status", RunMode = RunMode.Async)]
[Summary("Poll server for status")]
[Remarks("status")]
[RequireBotPermission(ChannelPermission.ViewChannel | ChannelPermission.SendMessages)]
public async Task ServerStatusAsync()
{
await ServerStatusAsync(null);
}
[Command("status", RunMode = RunMode.Async)]
[Summary("Poll server for status")]
[Remarks("status profileId|alias")]
@ -124,8 +110,10 @@ namespace ServerManagerTool.DiscordBot.Modules
foreach (var output in response)
{
await ReplyAsync(output.Replace("&", "_"));
await Task.Delay(1000);
await Task.Delay(COMMAND_RESPONSE_DELAY);
}
await ReplyAsync($"'{Context.Message}' command complete.");
}
}
catch (Exception ex)