Update command documentation
This commit is contained in:
parent
8a15e2a3a3
commit
c4ac1f789f
25 changed files with 52 additions and 161 deletions
|
@ -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**<pending>` });
|
||||
e.then((res) => {
|
||||
m?.edit({
|
||||
content: `## **Promise**<resolved>\n\`\`\`js\n${render(res)}\n\`\`\``
|
||||
});
|
||||
})
|
||||
.catch((res) => {
|
||||
m?.edit({
|
||||
content: `## **Promise**<rejected>\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);
|
||||
}
|
|
@ -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;
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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;
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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;
|
|
@ -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";
|
||||
|
|
|
@ -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();
|
||||
|
|
15
bot/src/bot/commands/misc/support.ts
Normal file
15
bot/src/bot/commands/misc/support.ts
Normal file
|
@ -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;
|
|
@ -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({
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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[]) => {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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[]) => {
|
||||
|
|
Loading…
Reference in a new issue