diff --git a/Server/DiscordBot.cs b/Server/DiscordBot.cs index 477bdf9..8200569 100644 --- a/Server/DiscordBot.cs +++ b/Server/DiscordBot.cs @@ -30,9 +30,10 @@ public class DiscordBot Init(); #pragma warning restore CS4014 }); - return "Restarting Discord bot..."; + return localSettings.Enabled ? "Restarting Discord bot..." : "The discord bot is disabled in settings.json (no action was taken)."; }); - logger.Info("Starting discord bot (ctor)"); + if (localSettings.Enabled) + logger.Info("Starting discord bot (ctor)"); Settings.LoadHandler += OnLoadSettings; Logger.AddLogHandler(LogToDiscordLogChannel); } @@ -54,9 +55,10 @@ public class DiscordBot private async Task Init() { - if (client != null) + if (client != null || !localSettings.Enabled) { - return; //this is bad if the client ever crashes and isn't reassigned to null, but we don't want multiple instances of the bot running at the same time. + return; //Either: the discord bot is disabled, or: this is bad if the client ever crashes and + //isn't reassigned to null, but we don't want multiple instances of the bot running at the same time. } if (localSettings.Token == null || (localSettings.AdminChannel == null && localSettings.CommandChannel == null)) { diff --git a/Server/Settings.cs b/Server/Settings.cs index c89b275..25a6e4c 100644 --- a/Server/Settings.cs +++ b/Server/Settings.cs @@ -71,6 +71,7 @@ public class Settings { } public class DiscordTable { + public bool Enabled { get; set; } = true; public string? Token { get; set; } public string Prefix { get; set; } = "$"; public string? CommandChannel { get; set; }