From aa594eef6aa96371a95aedd20a50d859c581487c Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Sun, 19 May 2024 06:27:20 +0100 Subject: [PATCH 1/4] Initial prep for subcategories --- DiscordBotPlugin/PluginMain.cs | 60 +++++++++---------- DiscordBotPlugin/Settings.cs | 104 ++++++++++++++++----------------- 2 files changed, 81 insertions(+), 83 deletions(-) diff --git a/DiscordBotPlugin/PluginMain.cs b/DiscordBotPlugin/PluginMain.cs index 4803dfe..7f3df5f 100644 --- a/DiscordBotPlugin/PluginMain.cs +++ b/DiscordBotPlugin/PluginMain.cs @@ -1,18 +1,18 @@ -using ModuleShared; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading.Tasks; -using Discord; -using Discord.WebSocket; +using Discord; using Discord.Commands; -using System.Linq; using Discord.Net; -using System.Text.RegularExpressions; +using Discord.WebSocket; +using LocalFileBackupPlugin; +using ModuleShared; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Reflection; using System.Text; -using Newtonsoft.Json; -using LocalFileBackupPlugin; +using System.Text.RegularExpressions; +using System.Threading.Tasks; namespace DiscordBotPlugin { @@ -47,7 +47,7 @@ public PluginMain(ILogger log, IConfigSerializer config, IPlatformInfo platform, aMPInstanceInfo = AMPInstanceInfo; features = Features; - features.PostLoadPlugin(application,"LocalFileBackupPlugin"); + features.PostLoadPlugin(application, "LocalFileBackupPlugin"); features.RegisterFeature(BackupProvider); backupProvider = BackupProvider; @@ -219,8 +219,6 @@ public async Task ConnectDiscordAsync(string BotToken) if (_settings.MainSettings.DiscordDebugMode) config.LogLevel = LogSeverity.Debug; - //config.GatewayHost = "wss://gateway.discord.gg"; - // Initialize Discord client with the specified configuration _client = new DiscordSocketClient(config); @@ -638,13 +636,13 @@ private async Task UpdateWebPanel(string webPanelPath) // Write content to the files ResourceReader reader = new ResourceReader(); - if(!File.Exists(scriptFilePath)) + if (!File.Exists(scriptFilePath)) File.WriteAllText(scriptFilePath, reader.ReadResource("script.js")); - if(!File.Exists(stylesFilePath)) + if (!File.Exists(stylesFilePath)) File.WriteAllText(stylesFilePath, reader.ReadResource("styles.css")); - if(!File.Exists(panelFilePath)) + if (!File.Exists(panelFilePath)) File.WriteAllText(panelFilePath, reader.ReadResource("panel.html")); //variables @@ -702,7 +700,7 @@ private async Task UpdateWebPanel(string webPanelPath) } else { - uptime = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", 0,0,0,0); + uptime = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", 0, 0, 0, 0); } if (onlinePlayerCount > 0 && _settings.MainSettings.ShowOnlinePlayers) { @@ -725,7 +723,7 @@ private async Task UpdateWebPanel(string webPanelPath) if (_settings.MainSettings.ShowPlaytimeLeaderboard) { string leaderboard = GetPlayTimeLeaderBoard(5, false, null, false, true); - playtimeLeaderBoard = leaderboard.Split(new[] {"\r\n","\n"}, StringSplitOptions.RemoveEmptyEntries); + playtimeLeaderBoard = leaderboard.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); } @@ -795,16 +793,16 @@ public void ApplicationStateChange(object sender, ApplicationStateChangeEventArg public async void UpdatePresence(object sender, ApplicationStateChangeEventArgs args, bool force = false) { - if(_settings.MainSettings.BotActive && (args == null || args.PreviousState != args.NextState || force) && _client.ConnectionState == ConnectionState.Connected) + if (_settings.MainSettings.BotActive && (args == null || args.PreviousState != args.NextState || force) && _client.ConnectionState == ConnectionState.Connected) { try { string currentActivity = _client.Activity?.Name ?? ""; - if(currentActivity != "") + if (currentActivity != "") { var customStatus = _client.Activity as CustomStatusGame; - if(customStatus != null) + if (customStatus != null) { currentActivity = customStatus.State; } @@ -841,7 +839,7 @@ public async void UpdatePresence(object sender, ApplicationStateChangeEventArgs ClearAllPlayTimes(); } - if(status != currentStatus) + if (status != currentStatus) { await _client.SetStatusAsync(status); } @@ -851,14 +849,14 @@ public async void UpdatePresence(object sender, ApplicationStateChangeEventArgs // Set the presence/activity based on the server state if (application.State == ApplicationState.Ready) { - if(currentActivity != presenceString) + if (currentActivity != presenceString) { await _client.SetActivityAsync(new CustomStatusGame(OnlineBotPresenceString(onlinePlayers, maximumPlayers))); } } else { - if(presenceString != application.State.ToString()) + if (presenceString != application.State.ToString()) { await _client.SetActivityAsync(new CustomStatusGame(application.State.ToString())); } @@ -1556,7 +1554,7 @@ private async Task ManageServer(SocketMessageComponent arg) private void BackupServer(SocketGuildUser user) { currentUser = user; - BackupManifest manifest = new BackupManifest { ModuleName = aMPInstanceInfo.ModuleName, TakenBy = "DiscordBot", CreatedAutomatically = true, Name = "Backup Triggered by Discord Bot", Description = "Requested by " + user.Username}; + BackupManifest manifest = new BackupManifest { ModuleName = aMPInstanceInfo.ModuleName, TakenBy = "DiscordBot", CreatedAutomatically = true, Name = "Backup Triggered by Discord Bot", Description = "Requested by " + user.Username }; // Register event handlers backupProvider.BackupActionComplete += OnBackupComplete; @@ -2281,16 +2279,16 @@ private string GetMemoryUsage() totalAvailable = platform.InstalledRAMMB; double usage = application.GetPhysicalRAMUsage(); - if(usage >= 1024 || (totalAvailable > 1024 && _settings.MainSettings.ShowMaximumRAM)) + if (usage >= 1024 || (totalAvailable > 1024 && _settings.MainSettings.ShowMaximumRAM)) gb = true; - - if(gb) + + if (gb) { usage = usage / 1024; totalAvailable = totalAvailable / 1024; - } + } - if(_settings.MainSettings.ShowMaximumRAM) + if (_settings.MainSettings.ShowMaximumRAM) { return (usage.ToString(gb ? "N2" : "N0") + "/" + totalAvailable.ToString(gb ? "N2" : "N0") + (gb ? " GB" : "MB")); } diff --git a/DiscordBotPlugin/Settings.cs b/DiscordBotPlugin/Settings.cs index 2ea2d1e..a108225 100644 --- a/DiscordBotPlugin/Settings.cs +++ b/DiscordBotPlugin/Settings.cs @@ -10,128 +10,128 @@ public class Settings : SettingStore public class DiscordBotSettings : SettingSectionStore { [StoreEncrypted] - [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password)] + [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password, Subcategory: "Discord Config")] public string BotToken = ""; - [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false)] + [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false, Subcategory: "Misc")] public string BotTagline = "Powered by AMP"; - [WebSetting("Server Display Name", "Displayed in the bot info panel", false)] + [WebSetting("Server Display Name", "Displayed in the bot info panel", false, Subcategory: "Server Info")] public string ServerDisplayName = ""; - [WebSetting("Server Connection URL", "Displayed in bot info panel", false)] + [WebSetting("Server Connection URL", "Displayed in bot info panel", false, Subcategory: "Server Info")] public string ServerConnectionURL = ""; - [WebSetting("Server Password", "Displayed in bot info panel", false)] + [WebSetting("Server Password", "Displayed in bot info panel", false, Subcategory: "Server Info")] public string ServerPassword = ""; - [WebSetting("Modpack URL", "Displayed in bot info panel", false)] + [WebSetting("Modpack URL", "Displayed in bot info panel", false, Subcategory: "Server Info")] public string ModpackURL = ""; - [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false)] + [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false, Subcategory: "Server Info")] public string GameImageURL = ""; - [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false)] + [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false, Subcategory: "Server Info")] public bool ValidPlayerCount = false; - [WebSetting("Bot Activated", "Turn the bot on and off", false)] + [WebSetting("Bot Activated", "Turn the bot on and off", false, Subcategory: "Discord Config")] public bool BotActive = false; - [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false)] + [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false, Subcategory: "Discord Config")] public int BotRefreshInterval = 30; - [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false)] + [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false, Subcategory: "Discord Config")] public bool RestrictFunctions = false; - [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false)] + [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false, Subcategory: "Discord Config")] public string DiscordRole = ""; - [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false)] + [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false, Subcategory: "Logging")] public bool LogButtonsAndCommands = false; - [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false)] + [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false, Subcategory: "Logging")] public string ButtonResponseChannel = ""; public List InfoMessageDetails = new List(); - [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false)] + [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false, Subcategory: "Logging")] public bool PostPlayerEvents = false; - [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false)] + [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false, Subcategory: "Logging")] public string PostPlayerEventsChannel = ""; - [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false)] + [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false, Subcategory: "Misc")] public string ManagementURL = ""; - [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false)] + [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false, Subcategory: "Misc")] public bool ManagementURLSSL = false; - [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false)] + [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowStartButton = false; - [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false)] + [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowStopButton = false; - [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false)] + [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowRestartButton = false; - [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false)] + [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowKillButton = false; - [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false)] + [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowUpdateButton = false; - [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false)] + [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowManageButton = false; - [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false)] + [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false, Subcategory: "Buttons")] public bool ShowBackupButton = false; - [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false)] + [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info")] public bool ShowOnlinePlayers = false; - [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false)] + [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc")] public Dictionary ChangeStatus = new Dictionary(); - [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false)] + [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc")] public string OnlineBotPresence = ""; public Dictionary PlayTime = new Dictionary(); - [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false)] + [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info")] public bool ShowPlaytimeLeaderboard = false; - [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false)] + [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false, Subcategory: "Discord Config")] public bool RemoveBotName = false; - [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false)] + [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false, Subcategory: "Misc")] public string AdditionalEmbedFieldTitle = ""; - [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false)] + [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false, Subcategory: "Misc")] public string AdditionalEmbedFieldText = ""; - [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false)] + [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false, Subcategory: "Logging")] public bool SendChatToDiscord = false; - [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false)] + [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false, Subcategory: "Logging")] public string ChatToDiscordChannel = ""; - [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false)] + [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false, Subcategory: "Logging")] public bool SendDiscordChatToServer = false; - [WebSetting("Send Console to Discord", "Send console output to a Discord channel",false)] + [WebSetting("Send Console to Discord", "Send console output to a Discord channel", false, Subcategory: "Logging")] public bool SendConsoleToDiscord; - [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false)] + [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false, Subcategory: "Logging")] public string ConsoleToDiscordChannel = ""; - [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false)] + [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false, Subcategory: "Discord Config")] public bool DiscordDebugMode = false; - [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false)] + [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false, Subcategory: "Misc")] public bool EnableWebPanel = false; - [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false)] + [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false, Subcategory: "Misc")] public bool ShowMaximumRAM = false; public Dictionary LastSeen = new Dictionary(); @@ -142,37 +142,37 @@ public class DiscordBotSettings : SettingSectionStore public class DiscordBotColoursSettings : SettingSectionStore { - [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string InfoPanelColour = ""; - [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerStartColour = ""; - [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerStopColour = ""; - [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerRestartColour = ""; - [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerKillColour = ""; - [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerUpdateColour = ""; - [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ManageLinkColour = ""; - [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ConsoleCommandColour = ""; - [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerPlayerJoinEventColour = ""; - [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string ServerPlayerLeaveEventColour = ""; - [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false)] + [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] public string PlaytimeLeaderboardColour = ""; } @@ -180,7 +180,7 @@ public class DiscordBotColoursSettings : SettingSectionStore public class DiscordBotGameSpecificSettings : SettingSectionStore { - [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false)] + [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false, Subcategory: "Game Specific")] public bool ValheimJoinCode = false; } From 619ef3dbb1e1cf3232c5a5bc3d4aad86fe4f5d59 Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Thu, 23 May 2024 18:41:15 +0100 Subject: [PATCH 2/4] TABS --- DiscordBotPlugin/Settings.cs | 117 +++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/DiscordBotPlugin/Settings.cs b/DiscordBotPlugin/Settings.cs index a108225..6800f12 100644 --- a/DiscordBotPlugin/Settings.cs +++ b/DiscordBotPlugin/Settings.cs @@ -1,137 +1,142 @@ using ModuleShared; using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; using System.Net.Configuration; namespace DiscordBotPlugin { public class Settings : SettingStore { + [Description("Discord Bot")] + [SettingsGroupName("Discord Bot:smart_toy")] + [Serializable] public class DiscordBotSettings : SettingSectionStore { [StoreEncrypted] - [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password, Subcategory: "Discord Config")] + [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password, Subcategory: "Discord Config:settings")] public string BotToken = ""; - [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false, Subcategory: "Misc")] + [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false, Subcategory: "Misc:more_vert")] public string BotTagline = "Powered by AMP"; - [WebSetting("Server Display Name", "Displayed in the bot info panel", false, Subcategory: "Server Info")] + [WebSetting("Server Display Name", "Displayed in the bot info panel", false, Subcategory: "Server Info:page_info")] public string ServerDisplayName = ""; - [WebSetting("Server Connection URL", "Displayed in bot info panel", false, Subcategory: "Server Info")] + [WebSetting("Server Connection URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] public string ServerConnectionURL = ""; - [WebSetting("Server Password", "Displayed in bot info panel", false, Subcategory: "Server Info")] + [WebSetting("Server Password", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] public string ServerPassword = ""; - [WebSetting("Modpack URL", "Displayed in bot info panel", false, Subcategory: "Server Info")] + [WebSetting("Modpack URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] public string ModpackURL = ""; - [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false, Subcategory: "Server Info")] + [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false, Subcategory: "Server Info:page_info")] public string GameImageURL = ""; - [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false, Subcategory: "Server Info")] + [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false, Subcategory: "Server Info:page_info")] public bool ValidPlayerCount = false; - [WebSetting("Bot Activated", "Turn the bot on and off", false, Subcategory: "Discord Config")] + [WebSetting("Bot Activated", "Turn the bot on and off", false, Subcategory: "Discord Config:settings")] public bool BotActive = false; - [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false, Subcategory: "Discord Config")] + [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false, Subcategory: "Discord Config:settings")] public int BotRefreshInterval = 30; - [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false, Subcategory: "Discord Config")] + [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false, Subcategory: "Discord Config:settings")] public bool RestrictFunctions = false; - [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false, Subcategory: "Discord Config")] + [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false, Subcategory: "Discord Config:settings")] public string DiscordRole = ""; - [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false, Subcategory: "Logging")] + [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false, Subcategory: "Logging:output")] public bool LogButtonsAndCommands = false; - [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false, Subcategory: "Logging")] + [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false, Subcategory: "Logging:output")] public string ButtonResponseChannel = ""; public List InfoMessageDetails = new List(); - [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false, Subcategory: "Logging")] + [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false, Subcategory: "Logging:output")] public bool PostPlayerEvents = false; - [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false, Subcategory: "Logging")] + [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false, Subcategory: "Logging:output")] public string PostPlayerEventsChannel = ""; - [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false, Subcategory: "Misc")] + [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false, Subcategory: "Misc:more_vert")] public string ManagementURL = ""; - [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false, Subcategory: "Misc")] + [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false, Subcategory: "Misc:more_vert")] public bool ManagementURLSSL = false; - [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowStartButton = false; - [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowStopButton = false; - [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowRestartButton = false; - [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowKillButton = false; - [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowUpdateButton = false; - [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowManageButton = false; - [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false, Subcategory: "Buttons")] + [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] public bool ShowBackupButton = false; - [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info")] + [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info:page_info")] public bool ShowOnlinePlayers = false; - [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc")] + [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc:more_vert")] public Dictionary ChangeStatus = new Dictionary(); - [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc")] + [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc:more_vert")] public string OnlineBotPresence = ""; public Dictionary PlayTime = new Dictionary(); - [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info")] + [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info:page_info")] public bool ShowPlaytimeLeaderboard = false; - [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false, Subcategory: "Discord Config")] + [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false, Subcategory: "Discord Config:settings")] public bool RemoveBotName = false; - [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false, Subcategory: "Misc")] + [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false, Subcategory: "Misc:more_vert")] public string AdditionalEmbedFieldTitle = ""; - [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false, Subcategory: "Misc")] + [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false, Subcategory: "Misc:more_vert")] public string AdditionalEmbedFieldText = ""; - [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false, Subcategory: "Logging")] + [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false, Subcategory: "Logging:output")] public bool SendChatToDiscord = false; - [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false, Subcategory: "Logging")] + [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false, Subcategory: "Logging:output")] public string ChatToDiscordChannel = ""; - [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false, Subcategory: "Logging")] + [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false, Subcategory: "Logging:output")] public bool SendDiscordChatToServer = false; - [WebSetting("Send Console to Discord", "Send console output to a Discord channel", false, Subcategory: "Logging")] + [WebSetting("Send Console to Discord", "Send console output to a Discord channel", false, Subcategory: "Logging:output")] public bool SendConsoleToDiscord; - [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false, Subcategory: "Logging")] + [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false, Subcategory: "Logging:output")] public string ConsoleToDiscordChannel = ""; - [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false, Subcategory: "Discord Config")] + [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false, Subcategory: "Discord Config:settings")] public bool DiscordDebugMode = false; - [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false, Subcategory: "Misc")] + [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false, Subcategory: "Misc:more_vert")] public bool EnableWebPanel = false; - [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false, Subcategory: "Misc")] + [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false, Subcategory: "Misc:more_vert")] public bool ShowMaximumRAM = false; public Dictionary LastSeen = new Dictionary(); @@ -139,48 +144,54 @@ public class DiscordBotSettings : SettingSectionStore } public DiscordBotSettings MainSettings = new DiscordBotSettings(); - + + [Description("Discord Bot")] + [SettingsGroupName("Discord Bot:smart_toy")] + [Serializable] public class DiscordBotColoursSettings : SettingSectionStore { - [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string InfoPanelColour = ""; - [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerStartColour = ""; - [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerStopColour = ""; - [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerRestartColour = ""; - [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerKillColour = ""; - [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerUpdateColour = ""; - [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ManageLinkColour = ""; - [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ConsoleCommandColour = ""; - [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerPlayerJoinEventColour = ""; - [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string ServerPlayerLeaveEventColour = ""; - [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours")] + [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] public string PlaytimeLeaderboardColour = ""; } public DiscordBotColoursSettings ColourSettings = new DiscordBotColoursSettings(); + [Description("Discord Bot")] + [SettingsGroupName("Discord Bot:smart_toy")] + [Serializable] public class DiscordBotGameSpecificSettings : SettingSectionStore { - [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false, Subcategory: "Game Specific")] + [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false, Subcategory: "Game Specific:sports_esports")] public bool ValheimJoinCode = false; } From 1069f16706dc5365b892518466d7f25c794d3d76 Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Fri, 24 May 2024 05:33:41 +0100 Subject: [PATCH 3/4] Re-order tabs --- DiscordBotPlugin/Settings.cs | 104 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/DiscordBotPlugin/Settings.cs b/DiscordBotPlugin/Settings.cs index 6800f12..38f7e9a 100644 --- a/DiscordBotPlugin/Settings.cs +++ b/DiscordBotPlugin/Settings.cs @@ -15,128 +15,128 @@ public class Settings : SettingStore public class DiscordBotSettings : SettingSectionStore { [StoreEncrypted] - [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password, Subcategory: "Discord Config:settings")] + [WebSetting("Discord Bot Token", "From the [Discord Developer Site](https://discord.com/developers/applications)", false, "", CustomFieldTypes.Password, Subcategory: "Discord Config:settings:1")] public string BotToken = ""; - [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false, Subcategory: "Misc:more_vert")] + [WebSetting("Bot Tagline", "Displayed at the bottom of bot embeds", false, Subcategory: "Misc:more_vert:7")] public string BotTagline = "Powered by AMP"; - [WebSetting("Server Display Name", "Displayed in the bot info panel", false, Subcategory: "Server Info:page_info")] + [WebSetting("Server Display Name", "Displayed in the bot info panel", false, Subcategory: "Server Info:page_info:2")] public string ServerDisplayName = ""; - [WebSetting("Server Connection URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] + [WebSetting("Server Connection URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info:2")] public string ServerConnectionURL = ""; - [WebSetting("Server Password", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] + [WebSetting("Server Password", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info:2")] public string ServerPassword = ""; - [WebSetting("Modpack URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info")] + [WebSetting("Modpack URL", "Displayed in bot info panel", false, Subcategory: "Server Info:page_info:2")] public string ModpackURL = ""; - [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false, Subcategory: "Server Info:page_info")] + [WebSetting("Game Image URL", "Displayed in bot info panel, needs to be a publicly accessible image URL", false, Subcategory: "Server Info:page_info:2")] public string GameImageURL = ""; - [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false, Subcategory: "Server Info:page_info")] + [WebSetting("Valid Player Count?", "If the player count reports correctly, for info panel and bot status", false, Subcategory: "Server Info:page_info:2")] public bool ValidPlayerCount = false; - [WebSetting("Bot Activated", "Turn the bot on and off", false, Subcategory: "Discord Config:settings")] + [WebSetting("Bot Activated", "Turn the bot on and off", false, Subcategory: "Discord Config:settings:1")] public bool BotActive = false; - [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false, Subcategory: "Discord Config:settings")] + [WebSetting("Bot Refresh Interval", "How often, in seconds, the bot should update the presence and info panel. Recommended minimum 30 seconds otherwise requests to update Discord could be throttled", false, Subcategory: "Discord Config:settings:1")] public int BotRefreshInterval = 30; - [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false, Subcategory: "Discord Config:settings")] + [WebSetting("Restrict Functions to Discord Role", "Restrict server functions (start/stop/restart/kill/update/console/manage) to Discord role", false, Subcategory: "Discord Config:settings:1")] public bool RestrictFunctions = false; - [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false, Subcategory: "Discord Config:settings")] + [WebSetting("Discord Role Name", "Name of the role in your Discord server that should be allowed to excecute server functions", false, Subcategory: "Discord Config:settings:1")] public string DiscordRole = ""; - [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false, Subcategory: "Logging:output")] + [WebSetting("Log Button Presses and Commands", "Log when buttons are pressed and commands are used", false, Subcategory: "Logging:output:4")] public bool LogButtonsAndCommands = false; - [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false, Subcategory: "Logging:output")] + [WebSetting("Button/Command Log Channel (Name OR ID)", "Channel name or ID of where to log button presses and commands. If left blank response will be the same channel as the info panel display", false, Subcategory: "Logging:output:4")] public string ButtonResponseChannel = ""; public List InfoMessageDetails = new List(); - [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false, Subcategory: "Logging:output")] + [WebSetting("Post Join and Leave Messages", "Post player join and leave events to a Discord channel", false, Subcategory: "Logging:output:4")] public bool PostPlayerEvents = false; - [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false, Subcategory: "Logging:output")] + [WebSetting("Post Join and Leave Messages Channel (Name OR ID)", "Channel name or ID to post player join and leave events", false, Subcategory: "Logging:output:4")] public string PostPlayerEventsChannel = ""; - [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false, Subcategory: "Misc:more_vert")] + [WebSetting("Base Management URL", "Address used to manage instances, should be in the format of amp.domain.com or your external IP if you do not use a domain", false, Subcategory: "Misc:more_vert:7")] public string ManagementURL = ""; - [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false, Subcategory: "Misc:more_vert")] + [WebSetting("Base Management URL SSL (https)", "Enable https for the manage URL. Link will be http if disabled", false, Subcategory: "Misc:more_vert:7")] public bool ManagementURLSSL = false; - [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Start Button", "Toggle the start button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowStartButton = false; - [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Stop Button", "Toggle the stop button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowStopButton = false; - [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Restart Button", "Toggle the restart button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowRestartButton = false; - [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Kill Button", "Toggle the kill button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowKillButton = false; - [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Update Button", "Toggle the update button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowUpdateButton = false; - [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Manage Button", "Toggle the manage button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowManageButton = false; - [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked")] + [WebSetting("Display Backup Button", "Toggle the backup button visibility on the info panel", false, Subcategory: "Buttons:radio_button_checked:3")] public bool ShowBackupButton = false; - [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info:page_info")] + [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info:page_info:2")] public bool ShowOnlinePlayers = false; - [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc:more_vert")] + [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc:more_vert:7")] public Dictionary ChangeStatus = new Dictionary(); - [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc:more_vert")] + [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc:more_vert:7")] public string OnlineBotPresence = ""; public Dictionary PlayTime = new Dictionary(); - [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info:page_info")] + [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info:page_info:2")] public bool ShowPlaytimeLeaderboard = false; - [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false, Subcategory: "Discord Config:settings")] + [WebSetting("Remove Bot Name", "Remove [BOT NAME] from the command", false, Subcategory: "Discord Config:settings:1")] public bool RemoveBotName = false; - [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false, Subcategory: "Misc:more_vert")] + [WebSetting("Additional Embed Field Title", "Add an additional field in the info panel embed, put your title here", false, Subcategory: "Misc:more_vert:7")] public string AdditionalEmbedFieldTitle = ""; - [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false, Subcategory: "Misc:more_vert")] + [WebSetting("Additional Embed Field Text", "Add an additional field in the info panel embed, put your content here", false, Subcategory: "Misc:more_vert:7")] public string AdditionalEmbedFieldText = ""; - [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false, Subcategory: "Logging:output")] + [WebSetting("Send Chat to Discord", "Send chat messages to a Discord channel", false, Subcategory: "Logging:output:4")] public bool SendChatToDiscord = false; - [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false, Subcategory: "Logging:output")] + [WebSetting("Chat Discord Channel", "Discord channel name (or ID) to send chat messages to (if enabled)", false, Subcategory: "Logging:output:4")] public string ChatToDiscordChannel = ""; - [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false, Subcategory: "Logging:output")] + [WebSetting("Send Chat from Discord to Server", "Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)", false, Subcategory: "Logging:output:4")] public bool SendDiscordChatToServer = false; - [WebSetting("Send Console to Discord", "Send console output to a Discord channel", false, Subcategory: "Logging:output")] + [WebSetting("Send Console to Discord", "Send console output to a Discord channel", false, Subcategory: "Logging:output:4")] public bool SendConsoleToDiscord; - [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false, Subcategory: "Logging:output")] + [WebSetting("Console Discord Channel", "Discord channel name (or ID) to send console output to (if enabled)", false, Subcategory: "Logging:output:4")] public string ConsoleToDiscordChannel = ""; - [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false, Subcategory: "Discord Config:settings")] + [WebSetting("Discord Debug Mode", "Enable verbose logging on the Discord bot for debugging", false, Subcategory: "Discord Config:settings:1")] public bool DiscordDebugMode = false; - [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false, Subcategory: "Misc:more_vert")] + [WebSetting("Enable Web Panel", "Enable a web panel on the specified port for embedding onto a website. Info on further configuration [here](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Configure-the-Web-Panel)", false, Subcategory: "Misc:more_vert:7")] public bool EnableWebPanel = false; - [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false, Subcategory: "Misc:more_vert")] + [WebSetting("Show Maximum RAM", "Show maximum RAM on the info panel", false, Subcategory: "Misc:more_vert:7")] public bool ShowMaximumRAM = false; public Dictionary LastSeen = new Dictionary(); @@ -150,37 +150,37 @@ public class DiscordBotSettings : SettingSectionStore [Serializable] public class DiscordBotColoursSettings : SettingSectionStore { - [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Info Panel Colour", "Colour of the info panel embed message. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string InfoPanelColour = ""; - [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Start Server Colour", "Colour of the embed message when starting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerStartColour = ""; - [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Stop Server Colour", "Colour of the embed message when stopping server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerStopColour = ""; - [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Restart Server Colour", "Colour of the embed message when restarting server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerRestartColour = ""; - [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Kill Server Colour", "Colour of the embed message when killing server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerKillColour = ""; - [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Update Server Colour", "Colour of the embed message when updating server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerUpdateColour = ""; - [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Manage Link Colour", "Colour of the embed message when someone requests the manage link if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ManageLinkColour = ""; - [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Console Command Colour", "Colour of the embed message when a console message is sent to the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ConsoleCommandColour = ""; - [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Player Join Event Colour", "Colour of the embed message when a player joins the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerPlayerJoinEventColour = ""; - [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Player Leave Event Colour", "Colour of the embed message when a player leaves the server if logging is enabled. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string ServerPlayerLeaveEventColour = ""; - [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette")] + [WebSetting("Playtime Leaderboard Colour", "Colour of the embed message for the playtime leaderboard. Get the HEX colour from [here](https://www.color-hex.com/color-wheel/)", false, Subcategory: "Colours:palette:5")] public string PlaytimeLeaderboardColour = ""; } @@ -191,7 +191,7 @@ public class DiscordBotColoursSettings : SettingSectionStore [Serializable] public class DiscordBotGameSpecificSettings : SettingSectionStore { - [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false, Subcategory: "Game Specific:sports_esports")] + [WebSetting("Valheim Join Code", "Look for Valheim join code and display it in the info panel (restart the server after enabling)", false, Subcategory: "Game Specific:sports_esports:6")] public bool ValheimJoinCode = false; } From 857805bfd34d7559a02406c6ed1a918c302e3f72 Mon Sep 17 00:00:00 2001 From: Dave Ross Date: Wed, 29 May 2024 18:07:58 +0100 Subject: [PATCH 4/4] Category work, icons, about page --- DiscordBotPlugin/Settings.cs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/DiscordBotPlugin/Settings.cs b/DiscordBotPlugin/Settings.cs index 38f7e9a..73bbc22 100644 --- a/DiscordBotPlugin/Settings.cs +++ b/DiscordBotPlugin/Settings.cs @@ -9,8 +9,8 @@ namespace DiscordBotPlugin { public class Settings : SettingStore { - [Description("Discord Bot")] - [SettingsGroupName("Discord Bot:smart_toy")] + [Description("Discord Bot:smart_toy")] + [SettingsGroupName("Discord Bot")] [Serializable] public class DiscordBotSettings : SettingSectionStore { @@ -95,12 +95,12 @@ public class DiscordBotSettings : SettingSectionStore [WebSetting("Display Online Player List", "Display online player list in the info panel - if not compatible with the server nothing will show", false, Subcategory: "Server Info:page_info:2")] public bool ShowOnlinePlayers = false; - [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc:more_vert:7")] - public Dictionary ChangeStatus = new Dictionary(); - [WebSetting("Online Server Bot Presence Text", "Change the presence text when application is running, use {OnlinePlayers} and {MaximumPlayers} as variables", false, Subcategory: "Misc:more_vert:7")] public string OnlineBotPresence = ""; + [WebSetting("Change Displayed Status", "Replace the default AMP status with your own - key is the AMP value, value is the replacement - possible values listed on the [Wiki](https://github.com/winglessraven/AMP-Discord-Bot/wiki/Changing-Application-State-Values-to-Custom-Text)", false, Subcategory: "Misc:more_vert:7")] + public Dictionary ChangeStatus = new Dictionary(); + public Dictionary PlayTime = new Dictionary(); [WebSetting("Display Playtime Leaderboard", "Display the playtime leaderboard on the info panel - top 5 are shown", false, Subcategory: "Server Info:page_info:2")] @@ -145,8 +145,8 @@ public class DiscordBotSettings : SettingSectionStore public DiscordBotSettings MainSettings = new DiscordBotSettings(); - [Description("Discord Bot")] - [SettingsGroupName("Discord Bot:smart_toy")] + [Description("Discord Bot:smart_toy")] + [SettingsGroupName("Discord Bot")] [Serializable] public class DiscordBotColoursSettings : SettingSectionStore { @@ -186,8 +186,8 @@ public class DiscordBotColoursSettings : SettingSectionStore public DiscordBotColoursSettings ColourSettings = new DiscordBotColoursSettings(); - [Description("Discord Bot")] - [SettingsGroupName("Discord Bot:smart_toy")] + [Description("Discord Bot:smart_toy")] + [SettingsGroupName("Discord Bot")] [Serializable] public class DiscordBotGameSpecificSettings : SettingSectionStore { @@ -196,5 +196,22 @@ public class DiscordBotGameSpecificSettings : SettingSectionStore } public DiscordBotGameSpecificSettings GameSpecificSettings = new DiscordBotGameSpecificSettings(); + + [Description("Discord Bot:smart_toy")] + [SettingsGroupName("Discord Bot")] + [Serializable] + public class DiscordBotAboutSettings : SettingSectionStore + { + [WebSetting("Support", "For support, or to submit issues and feature requests visit the [GitHub](https://github.com/winglessraven/AMP-Discord-Bot) page.", false, Subcategory: "About:info:8")] + public int? AboutMessage = null; + + [WebSetting("Donations", "If you appreciate my work, donations are gratefully received! Visit my [Sponsor](https://github.com/sponsors/winglessraven) page.", false, Subcategory: "About:info:8")] + public int? DonationsMessage = null; + + [WebSetting("AMP Discord Bot", "Created by winglessraven", false, Subcategory: "About:info:8")] + public int? AMPDiscordBot = null; + } + + public DiscordBotAboutSettings AboutSettings = new DiscordBotAboutSettings(); } }