diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-20 22:50:45 -0500 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-20 22:50:45 -0500 |
| commit | 8fb88c737e49321ff2b612a9d0e0e059c64c272a (patch) | |
| tree | 6d22573479b7e7e047eceb85dbb7520b616a5a45 | |
| parent | d4a401ed2315a7b5e7dfa390836f2ebae1299976 (diff) | |
| download | tanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.tar.gz tanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.tar.bz2 tanzanite-8fb88c737e49321ff2b612a9d0e0e059c64c272a.zip | |
do some fixes or something
35 files changed, 511 insertions, 316 deletions
diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..3e79826 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,76 @@ +{ + "env": { + "es2021": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module", + "project": "./tsconfig.json" + }, + "plugins": [ + "@typescript-eslint", + "deprecation" + ], + "ignorePatterns": [ + "dist" + ], + "rules": { + "no-return-await": "off", + "@typescript-eslint/no-empty-interface": "warn", + "no-mixed-spaces-and-tabs": "off", + "no-duplicate-imports": "warn", + "no-empty-function": "off", + "@typescript-eslint/no-empty-function": "off", + "no-empty": "off", + "@typescript-eslint/ban-ts-comment": [ + "error", + { + "ts-expect-error": "allow-with-description", + "ts-ignore": "allow-with-description", + "ts-nocheck": "allow-with-description", + "ts-check": "allow-with-description", + "minimumDescriptionLength": 5 + } + ], + "@typescript-eslint/no-floating-promises": "warn", + "prefer-promise-reject-errors": "warn", + "@typescript-eslint/no-misused-promises": "error", + "@typescript-eslint/no-base-to-string": "error", + "no-loss-of-precision": "off", + "@typescript-eslint/no-loss-of-precision": "error", + "no-throw-literal": "off", + "@typescript-eslint/no-throw-literal": "warn", + "@typescript-eslint/prefer-nullish-coalescing": "warn", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "prefer-template": "warn", + "@typescript-eslint/no-this-alias": [ + "error", + { + "allowDestructuring": true, + "allowedNames": [ + "that" + ] + } + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_" + } + ], + "no-implied-eval": "off", + "@typescript-eslint/no-implied-eval": [ + "error" + ], + "deprecation/deprecation": "warn" + } +}
\ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..85b85a1 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,29 @@ +{ + "printWidth": 130, + "useTabs": true, + "quoteProps": "consistent", + "singleQuote": true, + "trailingComma": "none", + "endOfLine": "lf", + "overrides": [ + { + "files": [ + "*BushClientEvents.d.ts" + ], + "options": { + "printWidth": 80 + } + }, + { + "files": [ + "badwords.ts", + "badlinks.ts", + "badlinks-secret.ts" + ], + "options": { + "singleQuote": false, + "trailingComma": "es5" + } + } + ] +}
\ No newline at end of file diff --git a/package.json b/package.json index 4d27682..a4afd19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bush-bot", - "version": "3.0.0", + "version": "3.0.1", "description": "A multipurpose moderation bot developed for Moulberry's Bush.", "main": "dist/src/bot.js", "type": "module", @@ -37,7 +37,7 @@ "format:check": "yarn prettier . --check", "upgrade": "yarn rimraf yarn.lock && yarn cache clean && yarn install && yarn up && yarn up -R && yarn set version latest", "upgrade:sdk": "yarn dlx @yarnpkg/sdks vscode", - "upgrade:manual": "yarn add @notenoughupdates/discord.js-minesweeper @notenoughupdates/events-intercept @notenoughupdates/humanize-duration @notenoughupdates/simplify-number @notenoughupdates/wolfram-alpha-api @sentry/node @sentry/tracing canvas deep-lock chalk discord-akairo@npm:@notenoughupdates/discord-akairo@dev discord.js@npm:@notenoughupdates/discord.js@dev fuse.js got lodash mathjs moment nanoid node-os-utils numeral pg pg-hstore prettier pretty-bytes rimraf sequelize source-map-support tinycolor2 tslib typescript vm2 && yarn add --dev @types/express @types/lodash @types/node @types/node-os-utils @types/numeral @types/tinycolor2 @types/validator @typescript-eslint/eslint-plugin @typescript-eslint/parser discord-api-types@0.25.2 eslint eslint-config-prettier", + "upgrade:manual": "yarn add @notenoughupdates/discord.js-minesweeper @notenoughupdates/events-intercept @notenoughupdates/humanize-duration @notenoughupdates/simplify-number @notenoughupdates/wolfram-alpha-api @sentry/integrations @sentry/node @sentry/tracing canvas deep-lock chalk discord-akairo@npm:@notenoughupdates/discord-akairo@dev discord.js@npm:@notenoughupdates/discord.js@dev fuse.js got lodash mathjs moment nanoid node-os-utils numeral pg pg-hstore prettier pretty-bytes rimraf sequelize source-map-support tinycolor2 tslib typescript vm2 && yarn add --dev @types/express @types/lodash @types/node @types/node-os-utils @types/numeral @types/tinycolor2 @types/validator @typescript-eslint/eslint-plugin @typescript-eslint/parser discord-api-types@0.25.2 eslint eslint-config-prettier", "upgrade:package": "powershell -c \"yarn info --name-only | %{\\$_ -replace '^(?:├─ |└─ )?(@?[a-z0-9-~][a-z0-9-._~/]{0,}(?=.*(npm:(?!.*dev)|patch:.*?@npm).*))|.*\\$','\\$1'} | where{[string]::IsNullOrEmpty(\\$_) -eq \\$false} | yarn add\"", "beta": "git push && git checkout beta && git merge master && git push && git checkout master", "deploy:beta": "pm2 deploy ecosystem.config.cjs beta", @@ -50,6 +50,7 @@ "@notenoughupdates/humanize-duration": "^4.0.1", "@notenoughupdates/simplify-number": "^1.0.1", "@notenoughupdates/wolfram-alpha-api": "^1.0.1", + "@sentry/integrations": "^6.16.1", "@sentry/node": "^6.16.1", "@sentry/tracing": "^6.16.1", "canvas": "^2.8.0", @@ -70,7 +71,7 @@ "prettier": "^2.5.1", "pretty-bytes": "^5.6.0", "rimraf": "^3.0.2", - "sequelize": "^6.12.0-beta.3", + "sequelize": "^6.12.0", "source-map-support": "^0.5.21", "tinycolor2": "^1.4.2", "tslib": "^2.3.1", @@ -81,7 +82,7 @@ "@types/eslint": "^8", "@types/express": "^4.17.13", "@types/lodash": "^4.14.178", - "@types/node": "^16.11.12", + "@types/node": "^17.0.1", "@types/node-os-utils": "^1.2.0", "@types/numeral": "^2.0.2", "@types/pg": "^8", @@ -90,114 +91,12 @@ "@types/source-map-support": "^0", "@types/tinycolor2": "^1.4.3", "@types/validator": "^13.7.0", - "@typescript-eslint/eslint-plugin": "^5.7.0", - "@typescript-eslint/parser": "^5.7.0", + "@typescript-eslint/eslint-plugin": "^5.8.0", + "@typescript-eslint/parser": "^5.8.0", "discord-api-types": "0.25.2", - "eslint": "^8.4.1", - "eslint-config-prettier": "^8.3.0" - }, - "eslintConfig": { - "env": { - "es2021": true, - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "prettier" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module", - "project": "./tsconfig.json" - }, - "plugins": [ - "@typescript-eslint" - ], - "ignorePatterns": [ - "dist" - ], - "rules": { - "no-return-await": "off", - "@typescript-eslint/no-empty-interface": "warn", - "no-mixed-spaces-and-tabs": "off", - "no-duplicate-imports": "warn", - "no-empty-function": "off", - "@typescript-eslint/no-empty-function": "off", - "no-empty": "off", - "@typescript-eslint/ban-ts-comment": [ - "error", - { - "ts-expect-error": "allow-with-description", - "ts-ignore": "allow-with-description", - "ts-nocheck": "allow-with-description", - "ts-check": "allow-with-description", - "minimumDescriptionLength": 5 - } - ], - "@typescript-eslint/no-floating-promises": "warn", - "prefer-promise-reject-errors": "warn", - "@typescript-eslint/no-misused-promises": "error", - "@typescript-eslint/no-base-to-string": "error", - "no-loss-of-precision": "off", - "@typescript-eslint/no-loss-of-precision": "error", - "no-throw-literal": "off", - "@typescript-eslint/no-throw-literal": "warn", - "@typescript-eslint/prefer-nullish-coalescing": "warn", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "prefer-template": "warn", - "@typescript-eslint/no-this-alias": [ - "error", - { - "allowDestructuring": true, - "allowedNames": [ - "that" - ] - } - ], - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "argsIgnorePattern": "^_" - } - ], - "no-implied-eval": "off", - "@typescript-eslint/no-implied-eval": [ - "error" - ] - } - }, - "prettier": { - "printWidth": 130, - "useTabs": true, - "quoteProps": "consistent", - "singleQuote": true, - "trailingComma": "none", - "endOfLine": "lf", - "overrides": [ - { - "files": [ - "*BushClientEvents.d.ts" - ], - "options": { - "printWidth": 80 - } - }, - { - "files": [ - "badwords.ts", - "badlinks.ts", - "badlinks-secret.ts" - ], - "options": { - "singleQuote": false, - "trailingComma": "es5" - } - } - ] + "eslint": "^8.5.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-deprecation": "^1.3.2" }, "packageManager": "yarn@3.1.1" } diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts index a9a7c23..41cb9bb 100644 --- a/src/arguments/contentWithDuration.ts +++ b/src/arguments/contentWithDuration.ts @@ -1,8 +1,5 @@ -import { type BushArgumentTypeCaster } from '#lib'; +import { ParsedDuration, type BushArgumentTypeCaster } from '#lib'; -export const contentWithDuration: BushArgumentTypeCaster = async ( - _, - phrase -): Promise<{ duration: number | null; contentWithoutTime: string | null }> => { +export const contentWithDuration: BushArgumentTypeCaster = async (_, phrase): Promise<ParsedDuration> => { return client.util.parseDuration(phrase); }; diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts index 8648f7f..a3c531c 100644 --- a/src/arguments/discordEmoji.ts +++ b/src/arguments/discordEmoji.ts @@ -1,9 +1,14 @@ import { type BushArgumentTypeCaster } from '#lib'; import { type Snowflake } from 'discord-api-types'; -export const discordEmoji: BushArgumentTypeCaster = (_, phrase): { name: string; id: Snowflake } | null => { +export const discordEmoji: BushArgumentTypeCaster = (_, phrase): DiscordEmojiInfo | null => { if (!phrase) return null; const validEmoji: RegExpExecArray | null = client.consts.regex.discordEmoji.exec(phrase); if (!validEmoji || !validEmoji.groups) return null; return { name: validEmoji.groups.name, id: validEmoji.groups.id }; }; + +export interface DiscordEmojiInfo { + name: string; + id: Snowflake; +} diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts index 8c09072..b5ff4bf 100644 --- a/src/arguments/permission.ts +++ b/src/arguments/permission.ts @@ -1,12 +1,12 @@ import { type BushArgumentTypeCaster } from '#lib'; -import { Permissions } from 'discord.js'; +import { Permissions, PermissionString } from 'discord.js'; -export const permission: BushArgumentTypeCaster = (_, phrase) => { +export const permission: BushArgumentTypeCaster = (_, phrase): PermissionString | null => { if (!phrase) return null; phrase = phrase.toUpperCase().replace(/ /g, '_'); if (!(phrase in Permissions.FLAGS)) { return null; } else { - return phrase; + return phrase as PermissionString; } }; diff --git a/src/arguments/roleWithDuration.ts b/src/arguments/roleWithDuration.ts index 9bf4bb2..999ac1c 100644 --- a/src/arguments/roleWithDuration.ts +++ b/src/arguments/roleWithDuration.ts @@ -1,9 +1,7 @@ import { type BushArgumentTypeCaster } from '#lib'; +import { Role } from 'discord.js'; -export const roleWithDuration: BushArgumentTypeCaster = async ( - message, - phrase -): Promise<{ duration: number | null; role: string | null } | null> => { +export const roleWithDuration: BushArgumentTypeCaster = async (message, phrase): Promise<RoleWithDuration | null> => { // eslint-disable-next-line prefer-const let { duration, contentWithoutTime } = client.util.parseDuration(phrase); if (contentWithoutTime === null || contentWithoutTime === undefined) return null; @@ -12,3 +10,8 @@ export const roleWithDuration: BushArgumentTypeCaster = async ( if (!role) return null; return { duration, role }; }; + +export interface RoleWithDuration { + duration: number | null; + role: Role | null; +} @@ -5,8 +5,6 @@ import config from './config/options.js'; import { Sentry } from './lib/common/Sentry.js'; import { BushClient } from './lib/index.js'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -global.__rootdir__ = __dirname || process.cwd(); -new Sentry(); +new Sentry(dirname(fileURLToPath(import.meta.url)) || process.cwd()); BushClient.init(); void new BushClient(config).start(); diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index b44ae21..17bea40 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -14,7 +14,7 @@ export default class ChannelPermissionsCommand extends BushCommand { { id: 'target', description: 'The user/role to change the permissions of.', - customType: util.arg.union('member', 'role'), + type: util.arg.union('member', 'role'), readableType: 'member|role', prompt: 'What user/role would you like to change?', retry: '{error} Choose a valid user/role to change.', @@ -58,7 +58,7 @@ export default class ChannelPermissionsCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { target: Role | GuildMember; - permission: PermissionString | string; + permission: PermissionString; state: 'true' | 'false' | 'neutral'; } ) { @@ -67,7 +67,7 @@ export default class ChannelPermissionsCommand extends BushCommand { return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); - const permission: PermissionString = message.util.isSlashMessage(message) + const permission = message.util.isSlashMessage(message) ? await util.arg.cast('permission', message, args.permission) : args.permission; if (!permission) return await message.util.reply(`${util.emojis.error} Invalid permission.`); diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index 8bb778c..da4ad18 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -1,5 +1,6 @@ import { AllowedMentions, BushCommand, Global, type BushMessage, type BushSlashMessage } from '#lib'; -import { User, type Channel } from 'discord.js'; +import { GuildTextBasedChannels } from 'discord-akairo'; +import { User } from 'discord.js'; export default class BlacklistCommand extends BushCommand { public constructor() { @@ -25,7 +26,7 @@ export default class BlacklistCommand extends BushCommand { { id: 'target', description: 'The channel/user to blacklist.', - customType: util.arg.union('channel', 'user'), + type: util.arg.union('channel', 'user'), readableType: 'channel|user', prompt: 'What channel or user that you would like to blacklist/unblacklist?', retry: '{error} Pick a valid user or channel.', @@ -51,14 +52,14 @@ export default class BlacklistCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { action: 'blacklist' | 'unblacklist'; target: Channel | User | string; global: boolean } + args: { action: 'blacklist' | 'unblacklist'; target: GuildTextBasedChannels | User | string; global: boolean } ) { let action: 'blacklist' | 'unblacklist' | 'toggle' = args.action ?? (message?.util?.parsed?.alias as 'blacklist' | 'unblacklist') ?? 'toggle'; const global = args.global && message.author.isOwner(); const target = typeof args.target === 'string' - ? (await util.arg.cast('channel', message, args.target)) ?? (await util.arg.cast('user', message, args.target)) + ? (await util.arg.cast('textChannel', message, args.target)) ?? (await util.arg.cast('user', message, args.target)) : args.target; if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`); const targetID = target.id; @@ -81,13 +82,15 @@ export default class BlacklistCommand extends BushCommand { if (!success) return await message.util.reply({ content: `${util.emojis.error} There was an error globally ${action}ing ${util.format.input( - target?.tag ?? target.name + target instanceof User ? target.tag : target.name )}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)} globally.`, + content: `${util.emojis.success} Successfully ${action}ed ${util.format.input( + target instanceof User ? target.tag : target.name + )} globally.`, allowedMentions: AllowedMentions.none() }); // guild disable @@ -108,12 +111,16 @@ export default class BlacklistCommand extends BushCommand { .catch(() => false); if (!success) return await message.util.reply({ - content: `${util.emojis.error} There was an error ${action}ing ${util.format.input(target?.tag ?? target.name)}.`, + content: `${util.emojis.error} There was an error ${action}ing ${util.format.input( + target instanceof User ? target.tag : target.name + )}.`, allowedMentions: AllowedMentions.none() }); else return await message.util.reply({ - content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(target?.tag ?? target.name)}.`, + content: `${util.emojis.success} Successfully ${action}ed ${util.format.input( + target instanceof User ? target.tag : target.name + )}.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index 333ae19..a30652a 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -21,7 +21,7 @@ export default class DisableCommand extends BushCommand { { id: 'command', description: 'The command to disable/enable.', - customType: util.arg.union('commandAlias', 'command'), + type: util.arg.union('commandAlias', 'command'), readableType: 'command|commandAlias', prompt: 'What command would you like to enable/disable?', retry: '{error} Pick a valid command.', diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 87ea0cc..36504f8 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -13,7 +13,7 @@ export default class AvatarCommand extends BushCommand { { id: 'user', description: 'The user you would like to find the avatar of.', - customType: util.arg.union('member', 'globalUser'), + type: util.arg.union('member', 'globalUser'), readableType: 'member|user', prompt: 'Who would you like to see the avatar of?', retry: '{error} Choose a valid user.', diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index cb612b5..4277d56 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -1,9 +1,16 @@ -import { AllowedMentions, BushCommand, type BushGuildMember, type BushMessage, type BushRole, type BushSlashMessage } from '#lib'; -import { Argument } from 'discord-akairo'; -import { MessageEmbed, Role, type Message } from 'discord.js'; +import { + AllowedMentions, + BushArgumentTypeCaster, + BushCommand, + type BushGuildMember, + type BushMessage, + type BushRole, + type BushSlashMessage +} from '#lib'; +import { MessageEmbed, Role } from 'discord.js'; import tinycolor from 'tinycolor2'; -const isValidTinyColor = (_message: Message, phase: string) => { +const isValidTinyColor: BushArgumentTypeCaster<string | null> = (_message, phase) => { // if the phase is a number it converts it to hex incase it could be representing a color in decimal const newPhase = isNaN(phase as any) ? phase : `#${Number(phase).toString(16)}`; return tinycolor(newPhase).isValid() ? newPhase : null; @@ -21,7 +28,7 @@ export default class ColorCommand extends BushCommand { { id: 'color', description: 'The color string, role, or member to find the color of.', - customType: Argument.union(isValidTinyColor, 'role', 'member'), + type: util.arg.union(isValidTinyColor as any, 'role', 'member'), readableType: 'color|role|member', match: 'restContent', prompt: 'What color code, role, or user would you like to find the color of?', @@ -41,7 +48,7 @@ export default class ColorCommand extends BushCommand { public override async exec(message: BushMessage | BushSlashMessage, args: { color: string | BushRole | BushGuildMember }) { const _color = message.util.isSlashMessage(message) - ? ((await util.arg.cast(Argument.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as + ? ((await util.arg.cast(util.arg.union(isValidTinyColor as any, 'role', 'member'), message, args.color as string)) as | string | BushRole | BushGuildMember) diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index a38a446..ab09741 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -21,7 +21,7 @@ export default class GuildInfoCommand extends BushCommand { { id: 'guild', description: 'The guild to find information about.', - customType: util.arg.union('guild', 'snowflake'), + type: util.arg.union('guild', 'snowflake'), readableType: 'guild|snowflake', prompt: 'What server would you like to find information about?', retry: '{error} Choose a valid server to find information about.', diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 89d3c23..2d7fcfb 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -14,7 +14,7 @@ export default class UserInfoCommand extends BushCommand { { id: 'user', description: 'The user you would like to find information about.', - customType: util.arg.union('user', 'snowflake'), + type: util.arg.union('user', 'snowflake'), readableType: 'user|snowflake', prompt: 'What user would you like to find information about?', retry: '{error} Choose a valid user to find information about.', diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 3d68a97..506a7c3 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -13,7 +13,7 @@ export default class BanCommand extends BushCommand { { id: 'user', description: 'The user that will be banned.', - customType: util.arg.union('user', 'snowflake'), + type: util.arg.union('user', 'snowflake'), prompt: 'What user would you like to ban?', retry: '{error} Choose a valid user to ban.', slashType: 'USER' @@ -35,7 +35,7 @@ export default class BanCommand extends BushCommand { match: 'option', prompt: "How many days of the user's messages would you like to delete?", retry: '{error} Choose between 0 and 7 days to delete messages from the user for.', - customType: util.arg.range('integer', 0, 7, true), + type: util.arg.range('integer', 0, 7, true), optional: true, slashType: 'INTEGER', choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v })) @@ -91,7 +91,7 @@ export default class BanCommand extends BushCommand { return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`); } - let time: number; + let time: number | null; if (args.reason) { time = typeof args.reason === 'string' ? await util.arg.cast('duration', message, args.reason) : args.reason.duration; } diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 474eaa9..0f2d33c 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -13,7 +13,7 @@ export default class ModlogCommand extends BushCommand { { id: 'search', description: 'The case id or user to search for modlogs by.', - customType: util.arg.union('user', 'string'), + type: util.arg.union('user', 'string'), prompt: 'What case id or user would you like to see?', retry: '{error} Choose a valid case id or user.', slashType: 'STRING' diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index a18c04e..c7091b3 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -49,7 +49,7 @@ export default class MuteCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { user: BushUser; reason?: { duration: number | null; contentWithoutTime: string } | string; force: boolean } ) { - const reason: { duration: number | null; contentWithoutTime: string } = args.reason + const reason: { duration: number | null; contentWithoutTime: string | null } = args.reason ? typeof args.reason === 'string' ? await util.arg.cast('contentWithDuration', message, args.reason) : args.reason diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 21b9a3a..f039046 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -13,7 +13,7 @@ export default class PurgeCommand extends BushCommand { { id: 'amount', description: 'The amount of messages to purge.', - customType: util.arg.range('integer', 1, 100, true), + type: util.arg.range('integer', 1, 100, true), readableType: 'integer', prompt: 'How many messages would you like to purge?', retry: '{error} Please pick a number between 1 and 100.', diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index d543f60..4ada9d5 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -21,7 +21,7 @@ export default class RemoveReactionEmojiComm |
