diff --git a/packages/bot/src/bot/commands/configuration/allowlist.ts b/packages/bot/src/bot/commands/configuration/allowlist.ts index 2d88cb2..19bb3e7 100644 --- a/packages/bot/src/bot/commands/configuration/allowlist.ts +++ b/packages/bot/src/bot/commands/configuration/allowlist.ts @@ -1,8 +1,8 @@ -import { dbs } from "../../.."; import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import ServerConfig from "automod-lib/dist/types/ServerConfig"; +import { dbs } from "../../.."; import { isBotManager, NO_MANAGER_MSG, parseUser } from "../../util"; const SYNTAX = "/allowlist add ; /allowlist remove ; /allowlist list"; diff --git a/packages/bot/src/bot/commands/configuration/bot_managers.ts b/packages/bot/src/bot/commands/configuration/bot_managers.ts index 63a567a..a035433 100644 --- a/packages/bot/src/bot/commands/configuration/bot_managers.ts +++ b/packages/bot/src/bot/commands/configuration/bot_managers.ts @@ -1,9 +1,9 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { parseUser } from "../../util"; -import { client, dbs } from "../../.."; -import { User } from "../../../stoat/index.js"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; +import { User } from "../../../stoat/index.js"; +import { client, dbs } from "../../.."; +import { parseUser } from "../../util"; const SYNTAX = "/admin add @user; /admin remove @user; /admin list"; @@ -67,3 +67,4 @@ export default { } }, } as SimpleCommand; + diff --git a/packages/bot/src/bot/commands/configuration/filter.ts b/packages/bot/src/bot/commands/configuration/filter.ts index f85be8c..1eb4189 100644 --- a/packages/bot/src/bot/commands/configuration/filter.ts +++ b/packages/bot/src/bot/commands/configuration/filter.ts @@ -1,19 +1,19 @@ -import ServerConfig from "automod-lib/dist/types/ServerConfig"; import axios from "axios"; import FormData from "form-data"; -import { client, dbs } from "../../.."; +import ServerConfig from "automod-lib/dist/types/ServerConfig"; import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { checkMessageForFilteredWords } from "../../modules/antispam"; import { DEFAULT_PREFIX } from "../../modules/command_handler"; +import { client, dbs } from "../../.."; import { embed, EmbedColor, getDmChannel, isBotManager, NO_MANAGER_MSG, sanitizeMessageContent } from "../../util"; const WORDLIST_DEFAULT_MESSAGE = "<@{{user_id}}>, the message you sent contained a blocked word."; export default { name: "filter", - aliases: null, + aliases: [], description: "Allows for messages to be checked against a word list and then action to be taken based on infractions.", documentation: "/configuration/filter", category: CommandCategory.Configuration, diff --git a/packages/bot/src/bot/commands/configuration/log.ts b/packages/bot/src/bot/commands/configuration/log.ts index dd82f47..a018d34 100644 --- a/packages/bot/src/bot/commands/configuration/log.ts +++ b/packages/bot/src/bot/commands/configuration/log.ts @@ -1,15 +1,18 @@ -import { client, dbs } from "../../.."; import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { DEFAULT_PREFIX } from "../../modules/command_handler"; +import { client, dbs } from "../../.."; import { isBotManager, NO_MANAGER_MSG } from "../../util"; +const SYNTAX = "/logs [category] [#channel]"; + export default { name: "logs", - aliases: null, + aliases: [], description: "Configure log collection.", documentation: "/configuration/logs", + syntax: SYNTAX, category: CommandCategory.Configuration, run: async (message: MessageCommandContext, args: string[]) => { if (!(await isBotManager(message))) return message.reply(NO_MANAGER_MSG); @@ -80,3 +83,4 @@ export default { } }, } as SimpleCommand; + diff --git a/packages/bot/src/bot/commands/configuration/prefix.ts b/packages/bot/src/bot/commands/configuration/prefix.ts index 4028853..43b9900 100644 --- a/packages/bot/src/bot/commands/configuration/prefix.ts +++ b/packages/bot/src/bot/commands/configuration/prefix.ts @@ -1,9 +1,9 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { dbs } from "../../.."; +import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; import { DEFAULT_PREFIX } from "../../modules/command_handler"; +import { dbs } from "../../.."; import { isBotManager, NO_MANAGER_MSG } from "../../util"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; -import CommandCategory from "../../../struct/commands/CommandCategory"; const SYNTAX = "/prefix set [new prefix]; /prefix get; prefix clear"; const MENTION_TEXT = "You can also @mention me instead of using the prefix."; @@ -57,6 +57,7 @@ export default { }, } as SimpleCommand; + function validatePrefix(prefix: string): string | true { // Check length if (prefix.length > 32) return "Prefix may not be longer than 32 characters"; diff --git a/packages/bot/src/bot/commands/configuration/spam.ts b/packages/bot/src/bot/commands/configuration/spam.ts index d0657db..aa16796 100644 --- a/packages/bot/src/bot/commands/configuration/spam.ts +++ b/packages/bot/src/bot/commands/configuration/spam.ts @@ -1,14 +1,18 @@ -import { dbs } from "../../.."; -import { DEFAULT_PREFIX } from "../../modules/command_handler"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import SimpleCommand from "../../../struct/commands/SimpleCommand"; import MessageCommandContext from "../../../struct/MessageCommandContext"; +import { DEFAULT_PREFIX } from "../../modules/command_handler"; +import { dbs } from "../../.."; import { isBotManager, NO_MANAGER_MSG } from "../../util"; +const SYNTAX = "/spam enable; /spam disable"; + export default { name: "spam", aliases: ["antispam"], description: "Enable or disable anti-spam features.", documentation: "/configuration/spam", + syntax: SYNTAX, category: CommandCategory.Configuration, run: async (message: MessageCommandContext, args: string[]) => { if (!(await isBotManager(message))) return message.reply(NO_MANAGER_MSG); @@ -39,4 +43,4 @@ export default { } } }, -}; +} as SimpleCommand; diff --git a/packages/bot/src/bot/commands/miscellaneous/help.ts b/packages/bot/src/bot/commands/miscellaneous/help.ts index 4625a06..b6edd2b 100644 --- a/packages/bot/src/bot/commands/miscellaneous/help.ts +++ b/packages/bot/src/bot/commands/miscellaneous/help.ts @@ -1,7 +1,7 @@ -import Command from "../../../struct/commands/SimpleCommand"; -import { commands, DEFAULT_PREFIX, ownerIDs } from "../../modules/command_handler"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; +import SimpleCommand from "../../../struct/commands/SimpleCommand"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; +import { commands, DEFAULT_PREFIX, ownerIDs } from "../../modules/command_handler"; const categories: { [key in CommandCategory]: { @@ -39,8 +39,8 @@ const categories: { export default { name: "help", - aliases: null, - description: "Displays instructions for using the bot’s commands.", + aliases: [], + description: "Displays instructions for using the bot's commands.", documentation: "/miscellaneous/help", removeEmptyArgs: true, category: CommandCategory.Miscellaneous, @@ -62,7 +62,7 @@ export default { if (cmdCount > 0) { total++; const category = (categories as any)[categoryName]; - msg += `**${category.friendlyName}**\n` + ` \u2003 ↳ ${category.description} | **${cmdCount}** command${cmdCount == 1 ? "" : "s"}\n`; + msg += `**${category.friendlyName}**\n` + `   ↳ ${category.description} | **${cmdCount}** command${cmdCount == 1 ? "" : "s"}\n`; } } @@ -102,4 +102,4 @@ export default { } } }, -} as Command; +} as SimpleCommand; diff --git a/packages/bot/src/bot/commands/miscellaneous/info.ts b/packages/bot/src/bot/commands/miscellaneous/info.ts index 5f23a67..02f264b 100644 --- a/packages/bot/src/bot/commands/miscellaneous/info.ts +++ b/packages/bot/src/bot/commands/miscellaneous/info.ts @@ -1,6 +1,6 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; import { ULID_REGEX } from "../../util"; import { decodeTime } from "ulid"; diff --git a/packages/bot/src/bot/commands/miscellaneous/ping.ts b/packages/bot/src/bot/commands/miscellaneous/ping.ts index 331e437..69836de 100644 --- a/packages/bot/src/bot/commands/miscellaneous/ping.ts +++ b/packages/bot/src/bot/commands/miscellaneous/ping.ts @@ -1,18 +1,18 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { client } from "../../.."; -import MessageCommandContext from "../../../struct/MessageCommandContext"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; +import { client } from "../../.."; export default { name: "ping", - aliases: null, + aliases: [], description: "Checks how long it takes AutoMod to respond.", documentation: "/miscellaneous/ping", category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext) => { const now = Date.now(); const wsPing = client.events.ping(); - const wsDisplay = wsPing === null || wsPing < 0 ? "\`Reconnecting/Syncing…\`" : `\`${wsPing}ms\``; + const wsDisplay = wsPing === null || wsPing < 0 ? "`Reconnecting/Syncing…`" : `\`${wsPing}ms\``; const uptime = process.uptime(); const d = Math.floor(uptime / 86400); diff --git a/packages/bot/src/bot/commands/miscellaneous/support.ts b/packages/bot/src/bot/commands/miscellaneous/support.ts index 755c104..157befb 100644 --- a/packages/bot/src/bot/commands/miscellaneous/support.ts +++ b/packages/bot/src/bot/commands/miscellaneous/support.ts @@ -1,11 +1,11 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; export default { name: "support", aliases: ["donate", "tip"], - description: "Provides details regarding how to financially support AutoMod’s development and hosting.", + description: "Provides details regarding how to financially support AutoMod's development and hosting.", documentation: "/miscellaneous/support", category: CommandCategory.Miscellaneous, run: async (message: MessageCommandContext) => { diff --git a/packages/bot/src/bot/commands/miscellaneous/test.ts b/packages/bot/src/bot/commands/miscellaneous/test.ts index b20d148..31ef743 100644 --- a/packages/bot/src/bot/commands/miscellaneous/test.ts +++ b/packages/bot/src/bot/commands/miscellaneous/test.ts @@ -1,10 +1,10 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; export default { name: "test", - aliases: null, + aliases: [], description: "Checks that the bot works.", documentation: "/miscellaneous/test", category: CommandCategory.Miscellaneous, diff --git a/packages/bot/src/bot/commands/miscellaneous/web.ts b/packages/bot/src/bot/commands/miscellaneous/web.ts index a33b868..f59cc23 100644 --- a/packages/bot/src/bot/commands/miscellaneous/web.ts +++ b/packages/bot/src/bot/commands/miscellaneous/web.ts @@ -1,31 +1,10 @@ -import { dbs } from "../../.."; -import CommandCategory from "../../../struct/commands/CommandCategory"; +import { WithId } from "mongodb"; +import PendingLogin from "automod-lib/dist/types/PendingLogin"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; -import PendingLogin from "automod-lib/dist/types/PendingLogin"; import { DEFAULT_PREFIX } from "../../modules/command_handler"; -import { WithId } from "mongodb"; - -export default { - name: "web", - aliases: null, - description: "Allows you to log in and out of the web dashboard.", - documentation: "/miscellaneous/web", - category: CommandCategory.Miscellaneous, - run: async (message: MessageCommandContext, args: string[]) => { - const subcommand = args.shift()?.toLowerCase(); - - if (!subcommand || (subcommand !== "login" && subcommand !== "logout")) { - return message.reply(`Usage: \`${DEFAULT_PREFIX}web login [Code]\` or \`${DEFAULT_PREFIX}web logout [Code/ALL]\``); - } - - if (subcommand === "login") { - await handleLogin(message, args); - } else if (subcommand === "logout") { - await handleLogout(message, args); - } - }, -} as SimpleCommand; +import { dbs } from "../../.."; async function handleLogin(message: MessageCommandContext, args: string[]) { try { @@ -121,3 +100,24 @@ async function handleLogout(message: MessageCommandContext, args: string[]) { message.reply(`An error occurred: ${e}`); } } + +export default { + name: "web", + aliases: [], + description: "Allows you to log in and out of the web dashboard.", + documentation: "/miscellaneous/web", + category: CommandCategory.Miscellaneous, + run: async (message: MessageCommandContext, args: string[]) => { + const subcommand = args.shift()?.toLowerCase(); + + if (!subcommand || (subcommand !== "login" && subcommand !== "logout")) { + return message.reply(`Usage: \`${DEFAULT_PREFIX}web login [Code]\` or \`${DEFAULT_PREFIX}web logout [Code/ALL]\``); + } + + if (subcommand === "login") { + await handleLogin(message, args); + } else if (subcommand === "logout") { + await handleLogout(message, args); + } + }, +} as SimpleCommand; diff --git a/packages/bot/src/bot/commands/moderation/avatar.ts b/packages/bot/src/bot/commands/moderation/avatar.ts index bbf5ace..52d8ada 100644 --- a/packages/bot/src/bot/commands/moderation/avatar.ts +++ b/packages/bot/src/bot/commands/moderation/avatar.ts @@ -1,12 +1,12 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { isModerator, NO_MANAGER_MSG, parseUser } from "../../util"; export default { name: "avatar", aliases: ["pfp"], - description: "Allows managing or returning a user’s profile picture.", + description: "Allows managing or returning a user's profile picture.", documentation: "/moderation/avatar", category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { diff --git a/packages/bot/src/bot/commands/moderation/ban.ts b/packages/bot/src/bot/commands/moderation/ban.ts index e9a8525..ffd55b0 100644 --- a/packages/bot/src/bot/commands/moderation/ban.ts +++ b/packages/bot/src/bot/commands/moderation/ban.ts @@ -1,8 +1,12 @@ import { ulid } from "ulid"; -import { client } from "../../../index"; +import Day from "dayjs"; +import RelativeTime from "dayjs/plugin/relativeTime"; import Infraction from "automod-lib/dist/types/antispam/Infraction"; import InfractionType from "automod-lib/dist/types/antispam/InfractionType"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; +import type { SendableEmbed } from "../../../stoat/index.js"; +import { User } from "../../../stoat/index.js"; import { fetchUsername, logModAction } from "../../modules/mod_logs"; import { storeTempBan } from "../../modules/tempbans"; import { @@ -20,20 +24,18 @@ import { storeInfraction, yesNoMessage, } from "../../util"; -import Day from "dayjs"; -import RelativeTime from "dayjs/plugin/relativeTime"; -import CommandCategory from "../../../struct/commands/CommandCategory"; -import type { SendableEmbed } from "../../../stoat/index.js"; -import { User } from "../../../stoat/index.js"; +import { client } from "../../.."; Day.extend(RelativeTime); +const SYNTAX = "/ban @username [10m|1h|...?] [reason?]"; + export default { name: "ban", aliases: ["eject"], description: "Removes a user from the server and prevents them from rejoining.", documentation: "/moderation/ban", - syntax: "/ban @username [10m|1h|...?] [reason?]", + syntax: SYNTAX, removeEmptyArgs: true, category: CommandCategory.Moderation, run: async (message, args, serverConfig) => { diff --git a/packages/bot/src/bot/commands/moderation/infractions.ts b/packages/bot/src/bot/commands/moderation/infractions.ts index 114305d..945746a 100644 --- a/packages/bot/src/bot/commands/moderation/infractions.ts +++ b/packages/bot/src/bot/commands/moderation/infractions.ts @@ -1,20 +1,21 @@ -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { dbs } from "../../.."; -import Infraction from "automod-lib/dist/types/antispam/Infraction"; -import InfractionType from "automod-lib/dist/types/antispam/InfractionType"; -import { isModerator, NO_MANAGER_MSG, parseUserOrId, getDmChannel, embed, EmbedColor } from "../../util"; import Day from "dayjs"; import RelativeTime from "dayjs/plugin/relativeTime"; -import Xlsx from "xlsx"; -import { fetchUsername } from "../../modules/mod_logs"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; -import CommandCategory from "../../../struct/commands/CommandCategory"; import axios from "axios"; import FormData from "form-data"; -import { client } from "../../.."; +import Xlsx from "xlsx"; +import Infraction from "automod-lib/dist/types/antispam/Infraction"; +import InfractionType from "automod-lib/dist/types/antispam/InfractionType"; +import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; +import { fetchUsername } from "../../modules/mod_logs"; +import { isModerator, NO_MANAGER_MSG, parseUserOrId, getDmChannel, embed, EmbedColor } from "../../util"; +import { client, dbs } from "../../.."; Day.extend(RelativeTime); +const SYNTAX = '/infractions; /infractions @username ["export-csv"]; /infractions rm [ID]'; + const formatInfraction = async (inf: Infraction) => { const timestamp = Math.floor(inf.date / 1000); return `- ${getInfEmoji(inf)} ID: \`${inf._id}\` — ${inf.reason} ( by ${inf.type === InfractionType.Manual ? await fetchUsername(inf.createdBy!) : "System"})\n`; @@ -193,7 +194,7 @@ export default { aliases: ["warns", "warnings"], description: "Shows a user's infractions.", documentation: "/moderation/infractions", - syntax: '/infractions; /infractions @username ["export-csv"]; /infractions rm [ID]', + syntax: SYNTAX, category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { const { id: serverId, name: serverName } = message.serverContext; diff --git a/packages/bot/src/bot/commands/moderation/kick.ts b/packages/bot/src/bot/commands/moderation/kick.ts index 9c0d831..b490b37 100644 --- a/packages/bot/src/bot/commands/moderation/kick.ts +++ b/packages/bot/src/bot/commands/moderation/kick.ts @@ -1,11 +1,10 @@ import { User } from "../../../stoat/index.js"; import type { SendableEmbed } from "../../../stoat/index.js"; import { ulid } from "ulid"; -import { client } from "../../../"; import Infraction from "automod-lib/dist/types/antispam/Infraction"; import InfractionType from "automod-lib/dist/types/antispam/InfractionType"; -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import { fetchUsername, logModAction } from "../../modules/mod_logs"; import { dedupeArray, @@ -21,13 +20,16 @@ import { storeInfraction, yesNoMessage, } from "../../util"; +import { client } from "../../.."; + +const SYNTAX = "/kick @username [reason?]"; export default { name: "kick", aliases: [], description: "Removes a user from the server, but they can rejoin if they have an invite.", documentation: "/moderation/kick", - syntax: "/kick @username [reason?]", + syntax: SYNTAX, removeEmptyArgs: true, category: CommandCategory.Moderation, run: async (message, args, serverConfig) => { diff --git a/packages/bot/src/bot/commands/moderation/nick.ts b/packages/bot/src/bot/commands/moderation/nick.ts index 4125f18..7502c92 100644 --- a/packages/bot/src/bot/commands/moderation/nick.ts +++ b/packages/bot/src/bot/commands/moderation/nick.ts @@ -1,5 +1,5 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { isModerator, NO_MANAGER_MSG, parseUser } from "../../util"; diff --git a/packages/bot/src/bot/commands/moderation/purge.ts b/packages/bot/src/bot/commands/moderation/purge.ts index 9f8991a..7fc909e 100644 --- a/packages/bot/src/bot/commands/moderation/purge.ts +++ b/packages/bot/src/bot/commands/moderation/purge.ts @@ -1,9 +1,9 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; import { Message } from "../../../stoat/index.js"; import { decodeTime } from "ulid"; import { isModerator, parseUserOrId } from "../../util"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; -import CommandCategory from "../../../struct/commands/CommandCategory"; const SYNTAX = "/purge [number] [user[,user...]]"; const MAX_PURGE_AMOUNT = 100; diff --git a/packages/bot/src/bot/commands/moderation/role.ts b/packages/bot/src/bot/commands/moderation/role.ts index d46b8de..aceb923 100644 --- a/packages/bot/src/bot/commands/moderation/role.ts +++ b/packages/bot/src/bot/commands/moderation/role.ts @@ -1,5 +1,5 @@ -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { isModerator, NO_MANAGER_MSG, parseUser } from "../../util"; import { dbs } from "../../.."; @@ -71,7 +71,9 @@ export default { return message.reply(`Reaction role added! Reacting to message \`${messageId}\` with ${displayEmoji} will now grant the role.`); } catch (e) { console.error("Could not add initial reaction:", e); - return message.reply(`Failed to add reaction role. Check that the message ID is correct, the emoji is valid, you're sending the command in the same channel as the message, and the bot has permission to read messages and add reactions in this channel.`); + return message.reply( + `Failed to add reaction role. Check that the message ID is correct, the emoji is valid, you're sending the command in the same channel as the message, and the bot has permission to read messages and add reactions in this channel.`, + ); } } @@ -146,7 +148,7 @@ export default { return message.reply(`User \`@${targetUser.username}\` doesn't have the role \`${roleId}\`.`); } try { - await target.edit({ roles: currentRoles.filter((role) => role !== roleId) }); + await target.edit({ roles: currentRoles.filter((r) => r !== roleId) }); await message.reply(`Role \`${roleId}\` has been removed from \`@${targetUser.username}\`.`); } catch (error) { console.error("Role remove error:", error); diff --git a/packages/bot/src/bot/commands/moderation/timeout.ts b/packages/bot/src/bot/commands/moderation/timeout.ts index 5f53950..cc9e899 100644 --- a/packages/bot/src/bot/commands/moderation/timeout.ts +++ b/packages/bot/src/bot/commands/moderation/timeout.ts @@ -1,8 +1,8 @@ -import { client } from "../../.."; -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { isModerator, NO_MANAGER_MSG, parseUser } from "../../util"; +import { client } from "../../.."; function parseTimeInput(input: string) { if (!/([0-9]{1,3}[smhdwy])+/g.test(input)) return null; diff --git a/packages/bot/src/bot/commands/moderation/unban.ts b/packages/bot/src/bot/commands/moderation/unban.ts index fc86610..028f39b 100644 --- a/packages/bot/src/bot/commands/moderation/unban.ts +++ b/packages/bot/src/bot/commands/moderation/unban.ts @@ -1,16 +1,18 @@ -import { dbs } from "../../../"; -import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; +import CommandCategory from "../../../struct/commands/CommandCategory"; import MessageCommandContext from "../../../struct/MessageCommandContext"; import { removeTempBan } from "../../modules/tempbans"; +import { dbs } from "../../.."; import { isModerator, NO_MANAGER_MSG, parseUser, ULID_REGEX, USER_MENTION_REGEX } from "../../util"; +const SYNTAX = "/unban [@user or ID]"; + export default { name: "unban", aliases: ["pardon"], - description: "Removes a user’s server ban, allowing them to rejoin the server if they have an invite.", + description: "Removes a user's server ban, allowing them to rejoin the server if they have an invite.", documentation: "/moderation/unban", - syntax: "/unban [@user or ID]", + syntax: SYNTAX, category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { if (!(await isModerator(message))) return message.reply(NO_MANAGER_MSG); diff --git a/packages/bot/src/bot/commands/moderation/warn.ts b/packages/bot/src/bot/commands/moderation/warn.ts index 544771a..efb2b9a 100644 --- a/packages/bot/src/bot/commands/moderation/warn.ts +++ b/packages/bot/src/bot/commands/moderation/warn.ts @@ -1,18 +1,29 @@ -import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import { dedupeArray, embed, EmbedColor, generateInfractionDMEmbed, getDmChannel, isModerator, NO_MANAGER_MSG, parseUserOrId, sanitizeMessageContent, storeInfraction } from "../../util"; -import Infraction from "automod-lib/dist/types/antispam/Infraction"; import { ulid } from "ulid"; +import Infraction from "automod-lib/dist/types/antispam/Infraction"; import InfractionType from "automod-lib/dist/types/antispam/InfractionType"; -import { fetchUsername, logModAction } from "../../modules/mod_logs"; +import SimpleCommand from "../../../struct/commands/SimpleCommand"; import CommandCategory from "../../../struct/commands/CommandCategory"; import type { SendableEmbed } from "../../../stoat/index.js"; import { User } from "../../../stoat/index.js"; +import { fetchUsername, logModAction } from "../../modules/mod_logs"; +import { + dedupeArray, + embed, + EmbedColor, + generateInfractionDMEmbed, + getDmChannel, + isModerator, + NO_MANAGER_MSG, + parseUserOrId, + sanitizeMessageContent, + storeInfraction, +} from "../../util"; export default { name: "warn", - aliases: null, + aliases: [], removeEmptyArgs: false, - description: "Adds an infraction to a user’s record.", + description: "Adds an infraction to a user's record.", documentation: "/moderation/warn", category: CommandCategory.Moderation, run: async (message, args, serverConfig) => { diff --git a/packages/bot/src/bot/commands/owner/override.ts b/packages/bot/src/bot/commands/owner/override.ts index 162b0f0..dd19830 100644 --- a/packages/bot/src/bot/commands/owner/override.ts +++ b/packages/bot/src/bot/commands/owner/override.ts @@ -1,6 +1,6 @@ import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; import CommandCategory from "../../../struct/commands/CommandCategory"; +import MessageCommandContext from "../../../struct/MessageCommandContext"; import { User } from "../../../stoat/index.js"; import { DEFAULT_PREFIX } from "../../modules/command_handler"; @@ -20,7 +20,7 @@ const updateSudoTimeout = (user: User) => { export default { name: "override", aliases: ["sudo", "doas"], - description: "Allows running any command regardless of the user’s current permissions.", + description: "Allows running any command regardless of the user's current permissions.", documentation: "/owner/override", restrict: "BOTOWNER", category: CommandCategory.Owner, diff --git a/packages/bot/src/bot/commands/owner/stats.ts b/packages/bot/src/bot/commands/owner/stats.ts index b544169..ee2d530 100644 --- a/packages/bot/src/bot/commands/owner/stats.ts +++ b/packages/bot/src/bot/commands/owner/stats.ts @@ -1,10 +1,10 @@ +import fs from "fs"; +import path from "path"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; -import MessageCommandContext from "../../../struct/MessageCommandContext"; import CommandCategory from "../../../struct/commands/CommandCategory"; -import { client, dbs } from "../../.."; +import MessageCommandContext from "../../../struct/MessageCommandContext"; import { commands, ownerIDs } from "../../modules/command_handler"; -import fs from "fs"; -import path from "path"; +import { client, dbs } from "../../.."; const pjson = JSON.parse((await fs.promises.readFile(path.join(process.cwd(), "package.json"))).toString());