Added 'ConfReload' command type

This commit is contained in:
Noikoio 2018-03-04 20:14:54 -08:00
parent dc7725c7b0
commit 7a8a82102f
2 changed files with 26 additions and 0 deletions

View file

@ -47,6 +47,7 @@ namespace Noikoio.RegexBot.Module.ModTools
{ {
// Define all command types and their corresponding Types here // Define all command types and their corresponding Types here
{ "ban", typeof(Commands.Ban) }, { "ban", typeof(Commands.Ban) },
{ "confreload", typeof(Commands.ConfReload) },
{ "kick", typeof(Commands.Kick) }, { "kick", typeof(Commands.Kick) },
{ "say", typeof(Commands.Say) }, { "say", typeof(Commands.Say) },
{ "unban", typeof(Commands.Unban) } { "unban", typeof(Commands.Unban) }

View file

@ -0,0 +1,25 @@
using Discord.WebSocket;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
namespace Noikoio.RegexBot.Module.ModTools.Commands
{
class ConfReload : CommandBase
{
// No configuration.
protected ConfReload(ModTools l, string label, JObject conf) : base(l, label, conf) { }
// Usage: (command)
public override async Task Invoke(SocketGuild g, SocketMessage msg)
{
bool status = await RegexBot.Config.ReloadServerConfig();
string res;
if (status) res = ":white_check_mark: Configuration reloaded with no issues. Check the console to verify.";
else res = ":x: Reload failed. Check the console.";
await msg.Channel.SendMessageAsync(res);
}
// Crazy idea: somehow redirect all logging messages created from invoking config reloading
// and pass them onto the invoking channel.
}
}