From c4ac1f789ff101542f4918534b0bcd49fb51ec56 Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Fri, 16 Aug 2024 12:35:27 +0800 Subject: [PATCH] Update command documentation --- bot/src/bot/commands/admin/eval.ts | 52 ------------------- bot/src/bot/commands/admin/shell_eval.ts | 47 ----------------- .../commands/configuration/bot_managers.ts | 2 +- bot/src/bot/commands/configuration/botctl.ts | 2 +- bot/src/bot/commands/configuration/login.ts | 2 +- bot/src/bot/commands/configuration/logout.ts | 2 +- .../bot/commands/configuration/moderator.ts | 2 +- bot/src/bot/commands/configuration/prefix.ts | 2 +- .../bot/commands/configuration/settings.ts | 14 ----- .../bot/commands/configuration/whitelist.ts | 2 +- bot/src/bot/commands/misc/healthcheck.ts | 13 ----- bot/src/bot/commands/misc/help.ts | 32 ++++++------ bot/src/bot/commands/misc/ping.ts | 2 +- bot/src/bot/commands/misc/support.ts | 15 ++++++ bot/src/bot/commands/misc/test.ts | 2 +- bot/src/bot/commands/moderation/avatar.ts | 2 +- bot/src/bot/commands/moderation/ban.ts | 2 +- bot/src/bot/commands/moderation/kick.ts | 2 +- bot/src/bot/commands/moderation/nick.ts | 2 +- bot/src/bot/commands/moderation/purge.ts | 2 +- bot/src/bot/commands/moderation/timeout.ts | 2 +- bot/src/bot/commands/moderation/unban.ts | 2 +- bot/src/bot/commands/moderation/votekick.ts | 2 +- bot/src/bot/commands/moderation/warn.ts | 2 +- bot/src/bot/commands/moderation/warns.ts | 4 +- 25 files changed, 52 insertions(+), 161 deletions(-) delete mode 100644 bot/src/bot/commands/admin/eval.ts delete mode 100644 bot/src/bot/commands/admin/shell_eval.ts delete mode 100644 bot/src/bot/commands/configuration/settings.ts delete mode 100644 bot/src/bot/commands/misc/healthcheck.ts create mode 100644 bot/src/bot/commands/misc/support.ts diff --git a/bot/src/bot/commands/admin/eval.ts b/bot/src/bot/commands/admin/eval.ts deleted file mode 100644 index 537fb1f..0000000 --- a/bot/src/bot/commands/admin/eval.ts +++ /dev/null @@ -1,52 +0,0 @@ -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { inspect } from 'util'; -import MessageCommandContext from "../../../struct/MessageCommandContext"; -import CommandCategory from "../../../struct/commands/CommandCategory"; - -export default { - name: 'eval', - aliases: [ 'e' ], - description: 'Evaluate JS code', - restrict: 'BOTOWNER', - removeEmptyArgs: false, - category: CommandCategory.Owner, - run: async (message: MessageCommandContext, args: string[]) => { - let cmd = args.join(' '); - - let m = await message.channel?.sendMessage(`Executing...`); - - try { - let e = eval(cmd); - - if (e instanceof Promise) { - await m?.edit({ content: `## **Promise**` }); - e.then((res) => { - m?.edit({ - content: `## **Promise**\n\`\`\`js\n${render(res)}\n\`\`\`` - }); - }) - .catch((res) => { - m?.edit({ - content: `## **Promise**\n\`\`\`js\n${render(res)}\n\`\`\`` - }); - }); - } else { - message.channel?.sendMessage(`\`\`\`js\n${render(e)}\n\`\`\``); - } - } catch(e) { - m?.edit({ content: `## Execution failed\n\`\`\`js\n${render(e)}\n\`\`\`` }); - } - } -} as SimpleCommand; - -function removeSecrets(input: string): string { - if (process.env['DB_PASS']) input = input.replace(new RegExp(process.env['DB_PASS']!, 'gi'), '[Secret redacted]'); - if (process.env['DB_URL']) input = input.replace(new RegExp(process.env['DB_URL']!, 'gi'), '[Secret redacted]'); - input = input.replace(new RegExp(process.env['BOT_TOKEN']!, 'gi'), '[Secret redacted]'); - - return input; -} - -function render(input: any): string { - return removeSecrets(inspect(input)).substr(0, 1960); -} diff --git a/bot/src/bot/commands/admin/shell_eval.ts b/bot/src/bot/commands/admin/shell_eval.ts deleted file mode 100644 index 494bb47..0000000 --- a/bot/src/bot/commands/admin/shell_eval.ts +++ /dev/null @@ -1,47 +0,0 @@ -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { exec } from 'child_process'; -import MessageCommandContext from "../../../struct/MessageCommandContext"; -import CommandCategory from "../../../struct/commands/CommandCategory"; - -export default { - name: 'shell', - aliases: [ 'exec', 'sh' ], - description: 'Run code in a shell', - restrict: 'BOTOWNER', - removeEmptyArgs: false, - category: CommandCategory.Owner, - run: async (message: MessageCommandContext, args: string[]) => { - let cmd = args.join(' '); - - let m = await message.channel?.sendMessage(`Executing...`); - - try { - let editMsg = () => { - if (str != '' && str != oldStr) { - if (str.length > 2000) { - str = str.substr(str.length - 2000); - } - - m?.edit({ content: str }) - .catch(e => console.warn('Failed to edit message', e)); - } - } - - let str = '', oldStr = ''; - let e = exec(cmd); - let i = setInterval(editMsg, 1000); - - e.stdout?.on('data', m => { - str += m; - }); - - e.on('exit', (code) => { - clearInterval(i); - str += `\n\n**Exit code:** ${code}`; - editMsg(); - }); - } catch(e) { - message.channel?.sendMessage(`${e}`); - } - } -} as SimpleCommand; diff --git a/bot/src/bot/commands/configuration/bot_managers.ts b/bot/src/bot/commands/configuration/bot_managers.ts index c9a40d8..0d86bd6 100644 --- a/bot/src/bot/commands/configuration/bot_managers.ts +++ b/bot/src/bot/commands/configuration/bot_managers.ts @@ -10,7 +10,7 @@ const SYNTAX = '/admin add @user; /admin remove @user; /admin list'; export default { name: 'admin', aliases: [ 'admins', 'manager', 'managers' ], - description: 'Allow users to control the bot\'s configuration', + description: "Manage users with permission to modify the configuration.", syntax: SYNTAX, category: CommandCategory.Config, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/configuration/botctl.ts b/bot/src/bot/commands/configuration/botctl.ts index 603aef4..9cda8b6 100644 --- a/bot/src/bot/commands/configuration/botctl.ts +++ b/bot/src/bot/commands/configuration/botctl.ts @@ -14,7 +14,7 @@ const WORDLIST_DEFAULT_MESSAGE = "<@{{user_id}}>, the message you sent contained export default { name: "botctl", aliases: null, - description: "Perform administrative actions", + description: "Perform administrative actions.", category: CommandCategory.Config, run: async (message: MessageCommandContext, args: string[]) => { if (!(await isBotManager(message))) return message.reply(NO_MANAGER_MSG); diff --git a/bot/src/bot/commands/configuration/login.ts b/bot/src/bot/commands/configuration/login.ts index 521cc18..8e30105 100644 --- a/bot/src/bot/commands/configuration/login.ts +++ b/bot/src/bot/commands/configuration/login.ts @@ -10,7 +10,7 @@ import { DEFAULT_PREFIX } from "../../modules/command_handler"; export default { name: 'login', aliases: null, - description: 'Log into the web dashboard', + description: 'Log into the web dashboard.', category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/configuration/logout.ts b/bot/src/bot/commands/configuration/logout.ts index f46cd68..ade28bf 100644 --- a/bot/src/bot/commands/configuration/logout.ts +++ b/bot/src/bot/commands/configuration/logout.ts @@ -7,7 +7,7 @@ import { DEFAULT_PREFIX } from "../../modules/command_handler"; export default { name: 'logout', aliases: null, - description: 'Log out of sessions created with /login', + description: 'Log out of web dashboard sessions.', category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/configuration/moderator.ts b/bot/src/bot/commands/configuration/moderator.ts index 5f0df58..0fd46e7 100644 --- a/bot/src/bot/commands/configuration/moderator.ts +++ b/bot/src/bot/commands/configuration/moderator.ts @@ -12,7 +12,7 @@ const SYNTAX = '/mod add @user; /mod remove @user; /mod list'; export default { name: 'moderator', aliases: [ 'moderators', 'mod', 'mods' ], - description: 'Allow users to moderate other users', + description: 'Allow users to moderate other users.', syntax: SYNTAX, category: CommandCategory.Config, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/configuration/prefix.ts b/bot/src/bot/commands/configuration/prefix.ts index c380337..2a1d9c2 100644 --- a/bot/src/bot/commands/configuration/prefix.ts +++ b/bot/src/bot/commands/configuration/prefix.ts @@ -11,7 +11,7 @@ const MENTION_TEXT = 'You can also @mention me instead of using the prefix.'; export default { name: 'prefix', aliases: null, - description: 'Configure AutoMod\'s prefix', + description: "Change AutoMod's prefix", syntax: SYNTAX, category: CommandCategory.Config, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/configuration/settings.ts b/bot/src/bot/commands/configuration/settings.ts deleted file mode 100644 index 689af09..0000000 --- a/bot/src/bot/commands/configuration/settings.ts +++ /dev/null @@ -1,14 +0,0 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; - -export default { - name: 'settings', - aliases: [ 'setting' ], - description: 'Manage AutoMod\'s configuration', - category: CommandCategory.Config, - run: async (message: MessageCommandContext) => { - await message.reply(`Bot configuration can be managed from ` - + `[here](<${process.env['WEB_UI_URL'] || 'https://automod.vale.rocks'}/dashboard>).`); - } -} as SimpleCommand; diff --git a/bot/src/bot/commands/configuration/whitelist.ts b/bot/src/bot/commands/configuration/whitelist.ts index 20add32..e613f34 100644 --- a/bot/src/bot/commands/configuration/whitelist.ts +++ b/bot/src/bot/commands/configuration/whitelist.ts @@ -11,7 +11,7 @@ const SYNTAX = '/whitelist add @user; /whitelist remove @user; /whitelist list'; export default { name: 'whitelist', aliases: [], - description: 'Allow users or roles to bypass moderation rules', + description: 'Allow users or roles to bypass moderation rules.', syntax: SYNTAX, category: CommandCategory.Config, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/misc/healthcheck.ts b/bot/src/bot/commands/misc/healthcheck.ts deleted file mode 100644 index 2d5f499..0000000 --- a/bot/src/bot/commands/misc/healthcheck.ts +++ /dev/null @@ -1,13 +0,0 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; - -export default { - name: 'healthcheck', - aliases: null, - description: 'Health check', - category: CommandCategory.Miscellaneous, - run: async (message: MessageCommandContext, args: string[]) => { - await message.reply('Health check success: ' + args.join(' ')); - } -} as SimpleCommand; diff --git a/bot/src/bot/commands/misc/help.ts b/bot/src/bot/commands/misc/help.ts index 713ee46..ca34ea0 100644 --- a/bot/src/bot/commands/misc/help.ts +++ b/bot/src/bot/commands/misc/help.ts @@ -12,27 +12,27 @@ const categories: { } = { [CommandCategory.Moderation]: { friendlyName: "Moderation", - description: "Moderation-focused commands", + description: "Commands for enforcing server rules.", aliases: ["moderation", "mod"], }, [CommandCategory.Config]: { friendlyName: "Configuration", - description: "Configure AutoMod", + description: "Commands for setting up and customizing settings.", aliases: ["configuration", "config", "conf"], }, [CommandCategory.Owner]: { friendlyName: "Owner", - description: "Owner-only commands for managing AutoMod", + description: "Exclusive commands for the bot owner to manage and control AutoMod.", aliases: ["owner"], }, [CommandCategory.Miscellaneous]: { friendlyName: "Miscellaneous", - description: "Assorted extras", + description: "Additional commands not covered by other categories.", aliases: ["miscellaneous", "misc"], }, [CommandCategory.None]: { friendlyName: "Uncategorized", - description: "Uncategorized commands", + description: "Commands that haven't been assigned to a specific category.", aliases: [], }, }; @@ -40,7 +40,7 @@ const categories: { export default { name: "help", aliases: null, - description: "Help command.", + description: "Displays usage instructions.", removeEmptyArgs: true, category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext, args: string[]) => { @@ -51,9 +51,7 @@ export default { if (!searchInput) { let msg = `## AutoMod Help\n` + - `Type **${prefix}help [category]** to view see all commands or **${prefix}help [command]** to learn more about a command.\n\n` + - `### [Open Server Settings]` + - `(<${process.env['WEB_UI_URL'] || "https://automod.vale.rocks"}/dashboard/${message.channel?.serverId}>)\n\n`; + `Type \`${prefix}help [category]\` to view commands within a category, or \`${prefix}help [command]\` to learn more about a specific command.\n\n`; let total = 0; @@ -67,7 +65,9 @@ export default { } } - msg += `\n##### Categories: ${total}`; + msg += `\n##### Categories: ${total}\n\n` + + `[Open Server Settings]` + + `(<${process.env['WEB_UI_URL'] || "https://automod.vale.rocks"}/dashboard/${message.channel?.serverId}>)`; await message.reply(msg); } else { @@ -76,17 +76,18 @@ export default { Object.entries(categories).find((c) => c[1].aliases.find((k) => k.toLowerCase() == searchInput)) || []; if (category && !searchInput.startsWith(prefix)) { - let msg = `**AutoMod Help** - Category: ${category.friendlyName}\n` + `${category.description}\n\n` + `Type **${prefix}help [command]** to learn more about a command.\n\n`; + let msg = `## AutoMod Help - ${category.friendlyName}\n` + + `${category.description}\n\n` + + `Type \`${prefix}help [command]\` to learn more about a specific command.\n\n`; let cmdList = commands.filter((c) => (c.category || "uncategorized") == categoryName); if (cmdList.length > 0) { for (const cmd of cmdList) { - msg += `**${prefix}${cmd.name}** \u200b $\\big |$ \u200b ${cmd.description}\n`; - + msg += `**${prefix}${cmd.name}** - ${cmd.description}`; msg += "\n"; } - msg += `##### Total: ${cmdList.length}`; + msg += `##### ${category.friendlyName} Commands: ${cmdList.length}`; } else msg += `### This category is empty.`; await message.reply(msg); @@ -97,7 +98,8 @@ export default { if (!cmd) { return message.reply(`I can't find any command or category matching \`${searchInput}\`.`); } else { - let msg = `**AutoMod Help** - Command: ${cmd.name}\n` + `${cmd.description}\n\n`; + let msg = `## AutoMod Help - ${cmd.name}\n` + + `${cmd.description}\n\n`; if (cmd.syntax) msg += `Syntax: \`${cmd.syntax}\`\n`; msg += "Aliases: " + (cmd.aliases ? `\`${cmd.aliases.join(`\`, \``)}\`` : "None") + "\n"; diff --git a/bot/src/bot/commands/misc/ping.ts b/bot/src/bot/commands/misc/ping.ts index 360a130..4166e6d 100644 --- a/bot/src/bot/commands/misc/ping.ts +++ b/bot/src/bot/commands/misc/ping.ts @@ -6,7 +6,7 @@ import CommandCategory from "../../../struct/commands/CommandCategory"; export default { name: "ping", aliases: null, - description: "ping pong", + description: "Checks response times.", category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext) => { let now = Date.now(); diff --git a/bot/src/bot/commands/misc/support.ts b/bot/src/bot/commands/misc/support.ts new file mode 100644 index 0000000..b4c68eb --- /dev/null +++ b/bot/src/bot/commands/misc/support.ts @@ -0,0 +1,15 @@ +import CommandCategory from "../../../struct/commands/CommandCategory"; +import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; + +export default { + name: "support", + aliases: ["donate", "tip"], + description: "Financially support AutoMod development and hosting.", + category: CommandCategory.Miscellaneous, + run: async (message: MessageCommandContext) => { + message.reply({ + content: "AutoMod is hosted and developed free of charge, but your financial support is greatly appreciated. You can support me via https://vale.rocks/support. Thank you so very much!", + }); + }, +} as SimpleCommand; diff --git a/bot/src/bot/commands/misc/test.ts b/bot/src/bot/commands/misc/test.ts index 244f92e..d6d6a52 100644 --- a/bot/src/bot/commands/misc/test.ts +++ b/bot/src/bot/commands/misc/test.ts @@ -5,7 +5,7 @@ import MessageCommandContext from "../../../struct/MessageCommandContext"; export default { name: "test", aliases: ["testalias"], - description: "Test command", + description: "Tests that the bot works.", category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext) => { message.reply({ diff --git a/bot/src/bot/commands/moderation/avatar.ts b/bot/src/bot/commands/moderation/avatar.ts index 96a5995..479d4f8 100644 --- a/bot/src/bot/commands/moderation/avatar.ts +++ b/bot/src/bot/commands/moderation/avatar.ts @@ -6,7 +6,7 @@ import { isModerator, NO_MANAGER_MSG, parseUser } from "../../util"; export default { name: 'avatar', aliases: [ 'pfp' ], - description: 'Get or clear someone\'s avatar', + description: 'Manage or return a user\'s profile picture.', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/moderation/ban.ts b/bot/src/bot/commands/moderation/ban.ts index 5ec7c18..9e1a448 100644 --- a/bot/src/bot/commands/moderation/ban.ts +++ b/bot/src/bot/commands/moderation/ban.ts @@ -32,7 +32,7 @@ Day.extend(RelativeTime); export default { name: "ban", aliases: ["eject"], - description: "Ban a member from the server", + description: "Bans a user from the server.", syntax: "/ban @username [10m|1h|...?] [reason?]", removeEmptyArgs: true, category: CommandCategory.Moderation, diff --git a/bot/src/bot/commands/moderation/kick.ts b/bot/src/bot/commands/moderation/kick.ts index 6922fdf..46e728f 100644 --- a/bot/src/bot/commands/moderation/kick.ts +++ b/bot/src/bot/commands/moderation/kick.ts @@ -26,7 +26,7 @@ import { export default { name: "kick", aliases: ["yeet", "vent"], - description: "Kick a member from the server", + description: "Kick a user from the server.", syntax: "/kick @username [reason?]", removeEmptyArgs: true, category: CommandCategory.Moderation, diff --git a/bot/src/bot/commands/moderation/nick.ts b/bot/src/bot/commands/moderation/nick.ts index 9958fc2..ae90585 100644 --- a/bot/src/bot/commands/moderation/nick.ts +++ b/bot/src/bot/commands/moderation/nick.ts @@ -9,7 +9,7 @@ import { client } from "../../.."; export default { name: 'nick', aliases: [ 'setnick' ], - description: 'Set or clear someone\'s nickname', + description: 'Manage a user\'s nickname.', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/moderation/purge.ts b/bot/src/bot/commands/moderation/purge.ts index 5b0f2f4..eaf63a0 100644 --- a/bot/src/bot/commands/moderation/purge.ts +++ b/bot/src/bot/commands/moderation/purge.ts @@ -11,7 +11,7 @@ const MAX_PURGE_AMOUNT = 100; export default { name: "purge", aliases: ["clear"], - description: "Mass delete messages", + description: "Delete messages in bulk.", syntax: SYNTAX, category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/moderation/timeout.ts b/bot/src/bot/commands/moderation/timeout.ts index 762170f..327b7fc 100644 --- a/bot/src/bot/commands/moderation/timeout.ts +++ b/bot/src/bot/commands/moderation/timeout.ts @@ -34,7 +34,7 @@ function parseTimeInput(input: string) { export default { name: 'timeout', aliases: [ 'mute' ], - description: 'Set a timeout on a user', + description: 'Set a timeout on a user.', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/moderation/unban.ts b/bot/src/bot/commands/moderation/unban.ts index e66a296..6f4bd5f 100644 --- a/bot/src/bot/commands/moderation/unban.ts +++ b/bot/src/bot/commands/moderation/unban.ts @@ -8,7 +8,7 @@ import { isModerator, NO_MANAGER_MSG, parseUser, ULID_REGEX, USER_MENTION_REGEX export default { name: 'unban', aliases: [ 'pardon' ], - description: 'Unbans a user', + description: "Removes a user's server ban.", syntax: '/unban [@user or ID]', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/bot/src/bot/commands/moderation/votekick.ts b/bot/src/bot/commands/moderation/votekick.ts index a20c65b..beb393a 100644 --- a/bot/src/bot/commands/moderation/votekick.ts +++ b/bot/src/bot/commands/moderation/votekick.ts @@ -19,7 +19,7 @@ type VoteEntry = { export default { name: 'votekick', aliases: [ 'voteban' ], - description: 'Allow trusted users to vote kick users', + description: 'Allow trusted users to vote kick users.', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { try { diff --git a/bot/src/bot/commands/moderation/warn.ts b/bot/src/bot/commands/moderation/warn.ts index 8f92e1e..31863ea 100644 --- a/bot/src/bot/commands/moderation/warn.ts +++ b/bot/src/bot/commands/moderation/warn.ts @@ -13,7 +13,7 @@ export default { name: 'warn', aliases: null, removeEmptyArgs: false, - description: 'add an infraction to an user\'s record', + description: "Adds an infraction to a user's record.", category: CommandCategory.Moderation, run: async (message, args, serverConfig) => { if (!await isModerator(message)) return message.reply(NO_MANAGER_MSG); diff --git a/bot/src/bot/commands/moderation/warns.ts b/bot/src/bot/commands/moderation/warns.ts index 2e88691..5abe4b9 100644 --- a/bot/src/bot/commands/moderation/warns.ts +++ b/bot/src/bot/commands/moderation/warns.ts @@ -17,8 +17,8 @@ const GLOBAL_BLACKLIST_TEXT = (reason?: string) => `> :warning: This user has be export default { name: 'warns', - aliases: [ 'warnings', 'infractions', 'infraction' ], - description: 'Show all user infractions', + aliases: [ 'warnings', 'infractions' ], + description: "Shows a user's infractions.", syntax: '/warns; /warns @username ["export-csv"]; /warns rm [ID]', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => {