using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Discord; using Discord.Commands; using Discord.WebSocket; using System.Net; namespace RMSoftware.ModularBot { public class CommandItem { public string Cmdname { get; private set; } public string cmdPerms { get; private set; } public string cmdSummary { get; private set; } public string cmdUsage { get; private set; } public string coreNote { get; private set; } public int index { get; private set; } bool is_core = false; string CoreID() { if(is_core) { return "CORE"; } else { return "CSTM"; } } public string generateTab() { return $@"

Summary: {cmdSummary}


Usage:

  • {cmdUsage}

Permissions:

  • {cmdPerms}

"; } public CommandItem(string CmdName, string CmdPerms, string CmdSummary, string CmdUsage, bool IsCore,int Index) { Cmdname = WebUtility.HtmlEncode(CmdName); cmdPerms = WebUtility.HtmlEncode(CmdPerms); cmdSummary = WebUtility.HtmlEncode(CmdSummary); cmdUsage = WebUtility.HtmlEncode(CmdUsage); is_core = IsCore; if(IsCore) { coreNote = "CORE"; } index = Index; } } public class CommandList { List commands { get; set; } int index = 0; public string botname { get; private set; } public string GenerateCoreCommandList() { string outresult = ""; foreach (var item in commands) { if (string.IsNullOrWhiteSpace(item.coreNote)) { continue; } outresult += item.generateTab(); } return outresult; } public string GenerateOtherCommandList() { string outresult = ""; foreach (var item in commands) { if (!string.IsNullOrWhiteSpace(item.coreNote)) { continue; } outresult += item.generateTab(); } return outresult; } public CommandList(string clientUsername) { botname = clientUsername; commands = new List(); } public void AddCommand(string cmdName,bool restricted, bool isCore,string summary=null,string usage=null) { string permission = restricted ? "Requires special permissions" : "Unrestricted"; if(string.IsNullOrWhiteSpace(summary)) { summary = "No summary was provided for this command."; } if (string.IsNullOrWhiteSpace(usage)) { usage = "No usage information was provided for this command."; } commands.Add(new CommandItem(cmdName, permission, summary, usage, isCore, index)); index++; } public string GetFullHTML() { return $@" {botname}'s Command List

Command list

Powered by RMSoftware.ModularBot

{GenerateCoreCommandList()}

{GenerateOtherCommandList()}

"; } } }