From 8fb88c737e49321ff2b612a9d0e0e059c64c272a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 20 Dec 2021 22:50:45 -0500 Subject: do some fixes or something --- .eslintrc.json | 76 ++++++ .prettierrc.json | 29 +++ package.json | 121 +-------- src/arguments/contentWithDuration.ts | 7 +- src/arguments/discordEmoji.ts | 7 +- src/arguments/permission.ts | 6 +- src/arguments/roleWithDuration.ts | 11 +- src/bot.ts | 4 +- src/commands/admin/channelPermissions.ts | 6 +- src/commands/config/blacklist.ts | 23 +- src/commands/config/disable.ts | 2 +- src/commands/info/avatar.ts | 2 +- src/commands/info/color.ts | 19 +- src/commands/info/guildInfo.ts | 2 +- src/commands/info/userInfo.ts | 2 +- src/commands/moderation/ban.ts | 6 +- src/commands/moderation/modlog.ts | 2 +- src/commands/moderation/mute.ts | 2 +- src/commands/moderation/purge.ts | 2 +- src/commands/moderation/removeReactionEmoji.ts | 2 +- src/commands/moderation/slowmode.ts | 4 +- src/commands/moulberry-bush/rule.ts | 2 +- src/commands/utilities/activity.ts | 2 +- src/commands/utilities/steal.ts | 6 +- src/commands/utilities/viewRaw.ts | 2 +- src/lib/common/Sentry.ts | 10 +- src/lib/common/util/Arg.ts | 119 +++++++-- .../discord-akairo/BushArgumentTypeCaster.ts | 2 +- src/lib/extensions/discord-akairo/BushClient.ts | 9 +- .../extensions/discord-akairo/BushClientUtil.ts | 2 +- src/lib/extensions/discord-akairo/BushCommand.ts | 51 ++-- src/lib/extensions/discord.js/BushStoreChannel.ts | 1 + src/lib/extensions/global.d.ts | 1 - src/listeners/message/blacklistedFile.ts | 8 +- yarn.lock | 277 ++++++++++++++------- 35 files changed, 511 insertions(+), 316 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .prettierrc.json 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 => { 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 => { // 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; +} diff --git a/src/bot.ts b/src/bot.ts index c1d4c29..bbef018 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -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 = (_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 RemoveReactionEmojiCommand extends BushCommand { { id: 'emoji', description: 'The emoji to remove all the reactions of from a message.', - customType: util.arg.union('emoji', 'snowflake'), + type: util.arg.union('emoji', 'snowflake'), readableType: 'emoji|snowflake', match: 'restContent', prompt: 'What emoji would you like to remove?', diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 949038c..f4ab822 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -21,7 +21,7 @@ export default class SlowModeCommand extends BushCommand { { id: 'length', description: 'The amount of time to set the slowmode of a channel to.', - customType: Argument.union('duration', 'durationSeconds', 'off', 'none', 'disable'), + type: Argument.union('duration', 'durationSeconds', 'off', 'none', 'disable'), readableType: "duration|durationSeconds|'off'|'none'|'disable'", prompt: 'What would you like to set the slowmode to?', retry: '{error} Please set the slowmode to a valid length.', @@ -52,7 +52,7 @@ export default class SlowModeCommand extends BushCommand { length, channel }: { - length: number | 'off' | 'none' | 'disable'; + length: number | 'off' | 'none' | 'disable' | null; channel: TextChannel | ThreadChannel | BushTextChannel | BushNewsChannel | BushThreadChannel | NewsChannel; } ) { diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index a88b323..2404c4d 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -62,7 +62,7 @@ export default class RuleCommand extends BushCommand { { id: 'rule', description: 'The rule to view.', - customType: util.arg.range('integer', 1, rules.length, true), + type: util.arg.range('integer', 1, rules.length, true), readableType: 'integer', prompt: 'What rule would you like to have cited?', retry: '{error} Choose a valid rule.', diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 6829757..2ab56cc 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -112,7 +112,7 @@ export default class YouTubeCommand extends BushCommand { id: 'activity', description: 'The activity to create an invite for.', match: 'rest', - customType: activityTypeCaster, + type: activityTypeCaster, prompt: 'What activity would you like to play?', retry: `{error} You must choose one of the following options: ${Object.values(activityMap) .flatMap((a) => a.aliases) diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 190277a..6a15d71 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,5 +1,5 @@ import { BushCommand, BushSlashMessage, type BushMessage } from '#lib'; -import { ArgumentOptions, Flag } from 'discord-akairo'; +import { ArgumentOptions, ArgumentType, ArgumentTypeCaster, Flag } from 'discord-akairo'; import { type Snowflake } from 'discord.js'; import _ from 'lodash'; @@ -15,7 +15,7 @@ export default class StealCommand extends BushCommand { { id: 'emoji', description: 'The emoji to steal.', - customType: util.arg.union('discordEmoji', 'snowflake', 'url'), + type: util.arg.union('discordEmoji', 'snowflake', 'url'), readableType: 'discordEmoji|snowflake|url', prompt: 'What emoji would you like to steal?', retry: '{error} Pick a valid emoji, emoji id, or image url.', @@ -47,7 +47,7 @@ export default class StealCommand extends BushCommand { ? message.attachments.first()!.url : yield { id: 'emoji', - type: util.arg.union('discordEmoji', 'snowflake', 'url'), + type: util.arg.union('discordEmoji', 'snowflake', 'url') as ArgumentType | ArgumentTypeCaster, prompt: { start: 'What emoji would you like to steal?', retry: '{error} Pick a valid emoji, emoji id, or image url.' diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts index c934e2e..0809a39 100644 --- a/src/commands/utilities/viewRaw.ts +++ b/src/commands/utilities/viewRaw.ts @@ -13,7 +13,7 @@ export default class ViewRawCommand extends BushCommand { { id: 'message', description: 'The message to view the raw content of.', - customType: util.arg.union('guildMessage', 'messageLink'), + type: util.arg.union('guildMessage', 'messageLink'), readableType: 'guildMessage|messageLink', prompt: 'What message would you like to view?', retry: '{error} Choose a valid message.', diff --git a/src/lib/common/Sentry.ts b/src/lib/common/Sentry.ts index 1de09ac..119e205 100644 --- a/src/lib/common/Sentry.ts +++ b/src/lib/common/Sentry.ts @@ -1,12 +1,18 @@ +import { RewriteFrames } from '@sentry/integrations'; import * as SentryNode from '@sentry/node'; import config from './../../config/options.js'; export class Sentry { - public constructor() { + public constructor(rootdir: string) { SentryNode.init({ dsn: config.credentials.sentryDsn, environment: config.environment, - tracesSampleRate: 1.0 + tracesSampleRate: 1.0, + integrations: [ + new RewriteFrames({ + root: rootdir + }) + ] }); } } diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts index 1982f4a..9ce8b54 100644 --- a/src/lib/common/util/Arg.ts +++ b/src/lib/common/util/Arg.ts @@ -1,4 +1,4 @@ -import { type BushArgumentType, type BushMessage, type BushSlashMessage } from '#lib'; +import { BaseBushArgumentType, BushArgumentTypeCaster, BushSlashMessage, type BushArgumentType } from '#lib'; import { Argument, type ArgumentTypeCaster, type Flag, type ParsedValuePredicate } from 'discord-akairo'; import { type Message } from 'discord.js'; @@ -9,12 +9,16 @@ export class Arg { * @param message - Message that called the command. * @param phrase - Phrase to process. */ - public static cast( - type: BushArgumentType | ArgumentTypeCaster, - message: BushMessage | BushSlashMessage, - phrase: string - ): Promise { - return Argument.cast(type, client.commandHandler.resolver, message as Message, phrase); + public static async cast(type: T, message: Message | BushSlashMessage, phrase: string): Promise>; + public static async cast(type: T, message: Message | BushSlashMessage, phrase: string): Promise; + public static async cast(type: T, message: Message | BushSlashMessage, phrase: string): Promise; + public static async cast(type: ATC | AT, message: Message | BushSlashMessage, phrase: string): Promise { + return Argument.cast( + type as ArgumentTypeCaster | keyof BushArgumentType, + client.commandHandler.resolver, + message as Message, + phrase + ); } /** @@ -22,8 +26,11 @@ export class Arg { * If any of the types fails, the entire composition fails. * @param types - Types to use. */ - public static compose(...types: BushArgumentType[]): ArgumentTypeCaster { - return Argument.compose(...types); + public static compose(...types: T[]): ATCATCR; + public static compose(...types: T[]): ATCBAT; + public static compose(...types: T[]): ATC; + public static compose(...types: (AT | ATC)[]): ATC { + return Argument.compose(...(types as any)); } /** @@ -31,8 +38,11 @@ export class Arg { * If any of the types fails, the composition still continues with the failure passed on. * @param types - Types to use. */ - public static composeWithFailure(...types: BushArgumentType[]): ArgumentTypeCaster { - return Argument.composeWithFailure(...types); + public static composeWithFailure(...types: T[]): ATCATCR; + public static composeWithFailure(...types: T[]): ATCBAT; + public static composeWithFailure(...types: T[]): ATC; + public static composeWithFailure(...types: (AT | ATC)[]): ATC { + return Argument.composeWithFailure(...(types as any)); } /** @@ -48,8 +58,11 @@ export class Arg { * Only inputs where each type resolves with a non-void value are valid. * @param types - Types to use. */ - public static product(...types: BushArgumentType[]): ArgumentTypeCaster { - return Argument.product(...types); + public static product(...types: T[]): ATCATCR; + public static product(...types: T[]): ATCBAT; + public static product(...types: T[]): ATC; + public static product(...types: (AT | ATC)[]): ATC { + return Argument.product(...(types as any)); } /** @@ -59,8 +72,11 @@ export class Arg { * @param max - Maximum value. * @param inclusive - Whether or not to be inclusive on the upper bound. */ - public static range(type: BushArgumentType, min: number, max: number, inclusive?: boolean): ArgumentTypeCaster { - return Argument.range(type, min, max, inclusive); + public static range(type: T, min: number, max: number, inclusive?: boolean): ATCATCR; + public static range(type: T, min: number, max: number, inclusive?: boolean): ATCBAT; + public static range(type: T, min: number, max: number, inclusive?: boolean): ATC; + public static range(type: AT | ATC, min: number, max: number, inclusive?: boolean): ATC { + return Argument.range(type as any, min, max, inclusive); } /** @@ -69,8 +85,11 @@ export class Arg { * @param type - The type to use. * @param tag - Tag to add. Defaults to the `type` argument, so useful if it is a string. */ - public static tagged(type: BushArgumentType, tag?: any): ArgumentTypeCaster { - return Argument.tagged(type, tag); + public static tagged(type: T, tag?: any): ATCATCR; + public static tagged(type: T, tag?: any): ATCBAT; + public static tagged(type: T, tag?: any): ATC; + public static tagged(type: AT | ATC, tag?: any): ATC { + return Argument.tagged(type as any, tag); } /** @@ -79,8 +98,11 @@ export class Arg { * Each type will also be tagged using `tagged` with themselves. * @param types - Types to use. */ - public static taggedUnion(...types: BushArgumentType[]): ArgumentTypeCaster { - return Argument.taggedUnion(...types); + public static taggedUnion(...types: T[]): ATCATCR; + public static taggedUnion(...types: T[]): ATCBAT; + public static taggedUnion(...types: T[]): ATC; + public static taggedUnion(...types: (AT | ATC)[]): ATC { + return Argument.taggedUnion(...(types as any)); } /** @@ -89,8 +111,11 @@ export class Arg { * @param type - The type to use. * @param tag - Tag to add. Defaults to the `type` argument, so useful if it is a string. */ - public static taggedWithInput(type: BushArgumentType, tag?: any): ArgumentTypeCaster { - return Argument.taggedWithInput(type, tag); + public static taggedWithInput(type: T, tag?: any): ATCATCR; + public static taggedWithInput(type: T, tag?: any): ATCBAT; + public static taggedWithInput(type: T, tag?: any): ATC; + public static taggedWithInput(type: AT | ATC, tag?: any): ATC { + return Argument.taggedWithInput(type as any, tag); } /** @@ -98,8 +123,11 @@ export class Arg { * The first type that resolves to a non-void value is used. * @param types - Types to use. */ - public static union(...types: BushArgumentType[]): ArgumentTypeCaster { - return Argument.union(...types); + public static union(...types: T[]): ATCATCR; + public static union(...types: T[]): ATCBAT; + public static union(...types: T[]): ATC; + public static union(...types: (AT | ATC)[]): ATC { + return Argument.union(...(types as any)); } /** @@ -108,8 +136,11 @@ export class Arg { * @param type - The type to use. * @param predicate - The predicate function. */ - public static validate(type: BushArgumentType, predicate: ParsedValuePredicate): ArgumentTypeCaster { - return Argument.validate(type, predicate); + public static validate(type: T, predicate: ParsedValuePredicate): ATCATCR; + public static validate(type: T, predicate: ParsedValuePredicate): ATCBAT; + public static validate(type: T, predicate: ParsedValuePredicate): ATC; + public static validate(type: AT | ATC, predicate: ParsedValuePredicate): ATC { + return Argument.validate(type as any, predicate); } /** @@ -117,7 +148,41 @@ export class Arg { * Result is in an object `{ input, value }` and wrapped in `Flag.fail` when failed. * @param type - The type to use. */ - public static withInput(type: BushArgumentType): ArgumentTypeCaster { - return Argument.withInput(type); + public static withInput(type: T): ATC>; + public static withInput(type: T): ATCBAT; + public static withInput(type: T): ATC; + public static withInput(type: AT | ATC): ATC { + return Argument.withInput(type as any); } } + +type ArgumentTypeCasterReturn = R extends BushArgumentTypeCaster ? S : R; +/** ```ts + * = ArgumentTypeCaster + * ``` */ +type ATC = BushArgumentTypeCaster; +/** ```ts + * keyof BaseArgumentType + * ``` */ +type KBAT = keyof BaseBushArgumentType; +/** ```ts + * = ArgumentTypeCasterReturn + * ``` */ +type ATCR = ArgumentTypeCasterReturn; +/** ```ts + * keyof BaseBushArgumentType | string + * ``` */ +type AT = BushArgumentTypeCaster | keyof BaseBushArgumentType | string; +/** ```ts + * BaseArgumentType + * ``` */ +type BAT = BaseBushArgumentType; + +/** ```ts + * = ArgumentTypeCaster> + * ``` */ +type ATCATCR = BushArgumentTypeCaster>; +/** ```ts + * = ArgumentTypeCaster + * ``` */ +type ATCBAT = BushArgumentTypeCaster; diff --git a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts index f27fb89..7a9a3db 100644 --- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts +++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts @@ -1,3 +1,3 @@ import { type BushMessage } from '#lib'; -export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => any; +export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => R; diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index e5ce7be..a9e172a 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -187,8 +187,8 @@ export class BushClient extends AkairoClient { if (this.config.isDevelopment) return 'dev '; if (!guild) return this.config.prefix; - const row = await GuildModel.findByPk(guild.id); - return (row?.prefix ?? this.config.prefix) as string; + const prefix = await (guild as BushGuild).getSetting('prefix'); + return (prefix ?? this.config.prefix) as string; }, allowMention: true, handleEdits: true, @@ -348,7 +348,10 @@ export class BushClient extends AkairoClient>, not <<${process.version}>>.`, false)); + process.exit(2); + } this.intercept('ready', async (arg, done) => { await this.guilds.fetch(); const promises = this.guilds.cache.map((guild) => { diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index cded096..ab1f3ed 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -112,7 +112,7 @@ export class BushClientUtil extends ClientUtil { void this.handleError('haste', new Error(`content over 400,000 characters (${content.length.toLocaleString()})`)); return { error: 'content too long' }; } else if (content.length > 400_000) { - content = content.substr(0, 400_000); + content = content.substring(0, 400_000); isSubstr = true; } for (const url of this.#hasteURLs) { diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index d8f0d38..5111c19 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,4 +1,12 @@ -import { type BushClient, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '#lib'; +import { + BushArgumentTypeCaster, + BushUser, + ParsedDuration, + type BushClient, + type BushCommandHandler, + type BushMessage, + type BushSlashMessage +} from '#lib'; import { AkairoApplicationCommandAutocompleteOption, AkairoApplicationCommandChannelOptionData, @@ -13,25 +21,26 @@ import { SlashOption, SlashResolveTypes, type ArgumentOptions, - type ArgumentTypeCaster, type CommandOptions } from 'discord-akairo'; -import { BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; -import { ApplicationCommandOptionChoice, type PermissionResolvable, type Snowflake } from 'discord.js'; - -export type BaseBushArgumentType = - | BaseArgumentType - | 'duration' - | 'contentWithDuration' - | 'permission' - | 'snowflake' - | 'discordEmoji' - | 'roleWithDuration' - | 'abbreviatedNumber' - | 'globalUser' - | 'messageLink'; - -export type BushArgumentType = BaseBushArgumentType | RegExp; +import { ArgumentType, ArgumentTypeCaster, BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; +import { ApplicationCommandOptionChoice, PermissionString, type PermissionResolvable, type Snowflake } from 'discord.js'; +import { DiscordEmojiInfo } from '../../../arguments/discordEmoji'; +import { RoleWithDuration } from '../../../arguments/roleWithDuration'; + +export interface BaseBushArgumentType extends BaseArgumentType { + duration: number | null; + contentWithDuration: ParsedDuration; + permission: PermissionString | null; + snowflake: Snowflake | null; + discordEmoji: DiscordEmojiInfo | null; + roleWithDuration: RoleWithDuration | null; + abbreviatedNumber: number | null; + globalUser: BushUser | null; + messageLink: BushMessage | null; +} + +export type BushArgumentType = keyof BaseBushArgumentType | RegExp; interface BaseBushArgumentOptions extends Omit { id: string; @@ -149,7 +158,7 @@ export interface BushArgumentOptions extends BaseBushArgumentOptions { * - `contentWithDuration` tries to parse duration in milliseconds and returns the remaining content with the duration * removed */ - type?: BushArgumentType | BaseBushArgumentType[]; + type?: BushArgumentType | (keyof BaseBushArgumentType)[] | BushArgumentTypeCaster; } export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { /** @@ -160,7 +169,7 @@ export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { * A regular expression can also be used. * The evaluated argument will be an object containing the `match` and `matches` if global. */ - customType?: ArgumentTypeCaster | (string | string[])[] | RegExp | string | null; + customType?: (string | string[])[] | RegExp | string | null; } export type BushMissingPermissionSupplier = (message: BushMessage | BushSlashMessage) => Promise | any; @@ -344,7 +353,7 @@ export class BushCommand extends Command { if ('retry' in arg) newArg.prompt.retry = arg.retry; if ('optional' in arg) newArg.prompt.optional = arg.optional; } - if ('type' in arg) newArg.type = arg.type; + if ('type' in arg) newArg.type = arg.type as ArgumentType | ArgumentTypeCaster; if ('unordered' in arg) newArg.unordered = arg.unordered; newTextArgs.push(newArg); } diff --git a/src/lib/extensions/discord.js/BushStoreChannel.ts b/src/lib/extensions/discord.js/BushStoreChannel.ts index 8540936..918c27b 100644 --- a/src/lib/extensions/discord.js/BushStoreChannel.ts +++ b/src/lib/extensions/discord.js/BushStoreChannel.ts @@ -2,6 +2,7 @@ import type { BushCategoryChannel, BushClient, BushGuild, BushGuildMember } from import { StoreChannel, type Collection, type Snowflake } from 'discord.js'; import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes'; +// eslint-disable-next-line deprecation/deprecation export class BushStoreChannel extends StoreChannel { public declare guild: BushGuild; public declare readonly members: Collection; diff --git a/src/lib/extensions/global.d.ts b/src/lib/extensions/global.d.ts index 8427873..1df86bb 100644 --- a/src/lib/extensions/global.d.ts +++ b/src/lib/extensions/global.d.ts @@ -3,7 +3,6 @@ import type { BushClient, BushClientUtil } from '#lib'; declare global { var client: BushClient; var util: BushClientUtil; - var __rootdir__: string; // eslint-disable-next-line @typescript-eslint/no-unused-vars interface ReadonlyArray { diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts index 26e1719..ac1fd02 100644 --- a/src/listeners/message/blacklistedFile.ts +++ b/src/listeners/message/blacklistedFile.ts @@ -105,7 +105,9 @@ export default class BlacklistedFileListener extends BushListener { for (const attachment of foundEmojis) { try { const req = await got.get( - `https://cdn.discordapp.com/emojis/${attachment.groups?.id}.${attachment.groups?.animated === 'a' ? 'gif' : 'png'}` + `https://cdn.discordapp.com/emojis/${attachment.groups?.id}.${ + attachment.groups?.animated === 'a' ? 'gif' : 'png' + }` ); const rawHash = crypto.createHash('md5'); rawHash.update(req.rawBody.toString('binary')); @@ -143,7 +145,9 @@ export default class BlacklistedFileListener extends BushListener { ); void client.console.warn( 'blacklistedFile', - `Failed to delete <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${message.author.tag}>> in <<${ + `Failed to delete <<${foundFiles.map((f) => f.description).join(' and ')}>> sent by <<${ + message.author.tag + }>> in <<${ message.channel.type === 'DM' ? `${message.channel.recipient.tag}'s DMs` : message.channel.name }>>.` ); diff --git a/yarn.lock b/yarn.lock index f08e0d1..9f45b41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -88,21 +88,21 @@ __metadata: linkType: hard "@mapbox/node-pre-gyp@npm:^1.0.0": - version: 1.0.7 - resolution: "@mapbox/node-pre-gyp@npm:1.0.7" + version: 1.0.8 + resolution: "@mapbox/node-pre-gyp@npm:1.0.8" dependencies: detect-libc: ^1.0.3 https-proxy-agent: ^5.0.0 make-dir: ^3.1.0 node-fetch: ^2.6.5 nopt: ^5.0.0 - npmlog: ^6.0.0 + npmlog: ^5.0.1 rimraf: ^3.0.2 semver: ^7.3.5 tar: ^6.1.11 bin: node-pre-gyp: bin/node-pre-gyp - checksum: bb6ac315e71649a7991f3a01bc576ef38345c66b58736d756508896fe75f3002bfaaabba76e3a9a9820b2e2e90c751fbdce480dcabe688940722f214eb679617 + checksum: 29a38f39575107fa1665edf14defcfdf62e12bb38e9c27f7457ba42be84060125015171d12b8de3065155a465992f1854a363e2985f071fcbea9ff0701362b05 languageName: node linkType: hard @@ -221,6 +221,18 @@ __metadata: languageName: node linkType: hard +"@sentry/integrations@npm:^6.16.1": + version: 6.16.1 + resolution: "@sentry/integrations@npm:6.16.1" + dependencies: + "@sentry/types": 6.16.1 + "@sentry/utils": 6.16.1 + localforage: ^1.8.1 + tslib: ^1.9.3 + checksum: 966213e0abf463c5a7828dda07ab06db3e25b8934f2e54e3cba4fe8edd384f5dbb0f343a544ee19ae87b6e94601e31a1aef34d6965f44f7d9afaac773665f659 + languageName: node + linkType: hard + "@sentry/minimal@npm:6.16.1": version: 6.16.1 resolution: "@sentry/minimal@npm:6.16.1" @@ -460,10 +472,10 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^16.11.12": - version: 16.11.12 - resolution: "@types/node@npm:16.11.12" - checksum: a3feb346d61a56f5a137c29bb8c63cfa3cc02e184b9dffdc18ef1528dcce55596e570575215a2e39e6ce69343eeb2a5ba71c271938f1dc8db4cc393902855412 +"@types/node@npm:*, @types/node@npm:^17.0.1": + version: 17.0.2 + resolution: "@types/node@npm:17.0.2" + checksum: a827d2542ef7adba5c79ba7f85b7c2ba8256d317bd99d77ed7af237cfebae0034dff5c4182e1845e6fbef29ae4c78186c4b4a7dbf236037a04120783aa30ba74 languageName: node linkType: hard @@ -475,13 +487,13 @@ __metadata: linkType: hard "@types/pg@npm:^8": - version: 8.6.1 - resolution: "@types/pg@npm:8.6.1" + version: 8.6.2 + resolution: "@types/pg@npm:8.6.2" dependencies: "@types/node": "*" pg-protocol: "*" pg-types: ^2.2.0 - checksum: a44710ff06e70f57685ddb88edbb93d4b46e03fed90619f09853ed3868ab28541c4da03eccf6b0b444a7566a0b3c56028543ced43554d51168ca3f8ae15e194f + checksum: 3a57824edfb31cb61cb67abc131b34834c3ce309efba8d95c383a8932c6bf228f2b8fd3dbce7d744fbb869304ddc6f9b5bb9ab5fcf9a04648c3999e9a14c2920 languageName: node linkType: hard @@ -567,12 +579,12 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.7.0" +"@typescript-eslint/eslint-plugin@npm:^5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.8.0" dependencies: - "@typescript-eslint/experimental-utils": 5.7.0 - "@typescript-eslint/scope-manager": 5.7.0 + "@typescript-eslint/experimental-utils": 5.8.0 + "@typescript-eslint/scope-manager": 5.8.0 debug: ^4.3.2 functional-red-black-tree: ^1.0.1 ignore: ^5.1.8 @@ -585,66 +597,66 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: e3674ee680e5dffecdb5d243d6c958ea8003021919d1b2068a3bebfde8e5303b3cecbc28cd144e1bacececb638b3d90fd3e16cd9e1f2e397c0eac8f148b9d3ac + checksum: 96a21a3e19baf57e30c97953e35832b1f4e135c865b2dfd5afe53772bd08556b9ad724e55696dce9acf471553ab66ae45737e82abba6c15152f79a47d2d9f055 languageName: node linkType: hard -"@typescript-eslint/experimental-utils@npm:5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/experimental-utils@npm:5.7.0" +"@typescript-eslint/experimental-utils@npm:5.8.0, @typescript-eslint/experimental-utils@npm:^5.0.0": + version: 5.8.0 + resolution: "@typescript-eslint/experimental-utils@npm:5.8.0" dependencies: "@types/json-schema": ^7.0.9 - "@typescript-eslint/scope-manager": 5.7.0 - "@typescript-eslint/types": 5.7.0 - "@typescript-eslint/typescript-estree": 5.7.0 + "@typescript-eslint/scope-manager": 5.8.0 + "@typescript-eslint/types": 5.8.0 + "@typescript-eslint/typescript-estree": 5.8.0 eslint-scope: ^5.1.1 eslint-utils: ^3.0.0 peerDependencies: - eslint: "*" - checksum: 5e9ca434d834059632bf6f227c9d7f13f143f5a42d8518df6e54db242e971bae09038d9abcc5ff3debab8ecf17c742544ff66778f6bcbc90e94d92ee358d8315 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: c97798bcc3332331a75661e073d38783ee4882803b0247db76df851bc8594c9b7e23fb9de28aa212c331b18ff2e8c23657ae1b9b994eeec528214fcf8d81e9fb languageName: node linkType: hard -"@typescript-eslint/parser@npm:^5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/parser@npm:5.7.0" +"@typescript-eslint/parser@npm:^5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/parser@npm:5.8.0" dependencies: - "@typescript-eslint/scope-manager": 5.7.0 - "@typescript-eslint/types": 5.7.0 - "@typescript-eslint/typescript-estree": 5.7.0 + "@typescript-eslint/scope-manager": 5.8.0 + "@typescript-eslint/types": 5.8.0 + "@typescript-eslint/typescript-estree": 5.8.0 debug: ^4.3.2 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: c57f9ab2001d3fd61776eb8ae7f05d0f5beed9d78fdc1bedaf24bf5f17049b909cbcea79ad58d0059000e29716b04d536ff1522c29441d1865229a3490a95bb2 + checksum: 138b1d20a6c204fdd0c93295b4ec667caf6036e74bfeae0b80cfe14c4d50761bb9f469b30d320d2d85757a1b98c2ae7f30d9a788a293afc1ea10b9f3d9fbc8f7 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/scope-manager@npm:5.7.0" +"@typescript-eslint/scope-manager@npm:5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/scope-manager@npm:5.8.0" dependencies: - "@typescript-eslint/types": 5.7.0 - "@typescript-eslint/visitor-keys": 5.7.0 - checksum: 8323e9787cb21c2e6c3de6bef2eb56e7e37c04f9c19413ad54964545dacc27a59ce6c19d660f4a20c0c6a368eee264d231436e9e8f221ed551abdcaf78596e12 + "@typescript-eslint/types": 5.8.0 + "@typescript-eslint/visitor-keys": 5.8.0 + checksum: 15f365a491c096104d3279617522375b6084117ac21e52cf04935a1cce192d730785a1e47afd8a8ca9aa907f1f9cd34793610406ce93447addf6854cdfa830f3 languageName: node linkType: hard -"@typescript-eslint/types@npm:5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/types@npm:5.7.0" - checksum: 4573250e59ea9e0b163c3e05e44ffb4b1ba4cdcfd6081c1f0b532e4c4bbbc5eb34ff4286c81c815115a1a1690cc8b1ad7b3ed79f3798773bf494b6ed82d0396b +"@typescript-eslint/types@npm:5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/types@npm:5.8.0" + checksum: eda7a2c4620fd0cd56a81af6f44d8de96eb5912dda69907cd422e3fb5845b45c004a2c50f1896b6573b70f41f175208434d13dd744ea23aec2094ba916578a81 languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.7.0" +"@typescript-eslint/typescript-estree@npm:5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.8.0" dependencies: - "@typescript-eslint/types": 5.7.0 - "@typescript-eslint/visitor-keys": 5.7.0 + "@typescript-eslint/types": 5.8.0 + "@typescript-eslint/visitor-keys": 5.8.0 debug: ^4.3.2 globby: ^11.0.4 is-glob: ^4.0.3 @@ -653,17 +665,17 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 0a63186e7b89dc3a1607d2b838ee7b44b4471654f3e77d62687242e5cb9d2a2385312f438dcfdcb70dadcb3638a141e1660483f7bb5d2cf3563cc9a43b0b2d94 + checksum: 67f51754d1dea9eafc8d052b67a2d7a3b20e20d97de03fc49615fe70d0373323619dfa5986a8e71cb9b2ec6079fb050049100763b5dbadae52b30c7d11c57ebd languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.7.0": - version: 5.7.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.7.0" +"@typescript-eslint/visitor-keys@npm:5.8.0": + version: 5.8.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.8.0" dependencies: - "@typescript-eslint/types": 5.7.0 + "@typescript-eslint/types": 5.8.0 eslint-visitor-keys: ^3.0.0 - checksum: 59f7468c37cfcb92eb0de15b7ece47dd64a56c4d03d13167140c980399a4f12f20c1df52534f486cefc46bab65e717689b81decb327d2677063c47c0a26ae875 + checksum: 03a349d4a577aa128b27d13a16e6e365d18e6aa9f297bc2a632bc2ddae8cfed9cb66c227f87fde9924e9f8a58c40c41df6f537016d037a05fe1908bfa0839d18 languageName: node linkType: hard @@ -851,12 +863,13 @@ __metadata: "@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 "@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 @@ -865,16 +878,17 @@ __metadata: "@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 canvas: ^2.8.0 chalk: ^5.0.0 deep-lock: ^1.0.0 discord-akairo: "npm:@notenoughupdates/discord-akairo@dev" discord-api-types: 0.25.2 discord.js: "npm:@notenoughupdates/discord.js@dev" - eslint: ^8.4.1 + eslint: ^8.5.0 eslint-config-prettier: ^8.3.0 + eslint-plugin-deprecation: ^1.3.2 fuse.js: ^6.4.6 got: ^12.0.0 lodash: ^4.17.21 @@ -888,7 +902,7 @@ __metadata: 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 @@ -1175,11 +1189,11 @@ __metadata: linkType: hard "discord-akairo@npm:@notenoughupdates/discord-akairo@dev": - version: 9.0.10-dev.1639356088.96444cd - resolution: "@notenoughupdates/discord-akairo@npm:9.0.10-dev.1639356088.96444cd" + version: 9.0.10-dev.1639527744.5797f7f + resolution: "@notenoughupdates/discord-akairo@npm:9.0.10-dev.1639527744.5797f7f" dependencies: source-map-support: ^0.5.21 - checksum: 606a610d8cf43f939ae2e79817e575b3038048ce2653b3e096ac70dd8bb9e5311b5518a3b6be4a18921d06315b687f0c3924ffebefa5cff0a6c8c5922106904e + checksum: 011634b3173c7c66fab91c85b96dab00ab17b97d1d1c62312a65843527e25821bac7b20eb2f8ca09ecd1ff73d4ab66f9125fc4188563e234995c8fcca7d4ac8c languageName: node linkType: hard @@ -1198,8 +1212,8 @@ __metadata: linkType: hard "discord.js@npm:@notenoughupdates/discord.js@dev": - version: 13.4.0-dev.1639442054.4d0cb81 - resolution: "@notenoughupdates/discord.js@npm:13.4.0-dev.1639442054.4d0cb81" + version: 13.4.0-dev.1640046158.d9880cf + resolution: "@notenoughupdates/discord.js@npm:13.4.0-dev.1640046158.d9880cf" dependencies: "@discordjs/builders": ^0.9.0 "@discordjs/collection": ^0.3.2 @@ -1210,7 +1224,7 @@ __metadata: discord-api-types: ^0.25.2 node-fetch: ^2.6.1 ws: ^8.3.0 - checksum: f75689a8f5a6d195fc28cb701d1525db373d38401457c055cc6707332e5e70a7d72f6dd7f039863ed662f7f117103cf1570827f3fef77d46347040a496741bf6 + checksum: ab01c63406687f9f3bae7c997b93fac6a5e6972d2936d3c30fd8ff16e9ea995b3342090c728354a2619b0b90d15e658dbef0f5de595440f98c4e63ba1325e154 languageName: node linkType: hard @@ -1303,6 +1317,20 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-deprecation@npm:^1.3.2": + version: 1.3.2 + resolution: "eslint-plugin-deprecation@npm:1.3.2" + dependencies: + "@typescript-eslint/experimental-utils": ^5.0.0 + tslib: ^2.3.1 + tsutils: ^3.21.0 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + typescript: ^3.7.5 || ^4.0.0 + checksum: 763776eec6af02ad442bf9ed7e73da198da6969b51418b43f79b3f0a27395e85e9988a3b182e61fab7812a35e17539ba72464d1123a87cc25b195288cbd0c31d + languageName: node + linkType: hard + "eslint-scope@npm:^5.1.1": version: 5.1.1 resolution: "eslint-scope@npm:5.1.1" @@ -1348,9 +1376,9 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.4.1": - version: 8.4.1 - resolution: "eslint@npm:8.4.1" +"eslint@npm:^8.5.0": + version: 8.5.0 + resolution: "eslint@npm:8.5.0" dependencies: "@eslint/eslintrc": ^1.0.5 "@humanwhocodes/config-array": ^0.9.2 @@ -1392,7 +1420,7 @@ __metadata: v8-compile-cache: ^2.0.3 bin: eslint: bin/eslint.js - checksum: d962cd7cd0f68ddc2412f47154b8992ad3af987cf47fa6e60e51a2b7d32a91f934388f7d29e2c45b16b7ac69f0d220d0a483189ec6ba43a8a480110c34f158f9 + checksum: c1a9e26070520a308cc30b62ba0d37d5b115ed23987a93219819537bdea9398e6ebe57c27d97be36ecc83b5162c72e82ecb0a9e5b44b7992980f9be90eb5c4b3 languageName: node linkType: h