From fce1fc87feb3e6dad1a956d757d856833c9ea5f6 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 22 Nov 2021 19:01:46 -0500 Subject: update contributors, fix formatting, added a bunch of repo forks --- .github/workflows/checks.yml | 2 +- .vscode/settings.json | 32 +- package.json | 49 +- src/arguments/permission.ts | 2 +- src/commands/config/config.ts | 2 +- src/commands/config/features.ts | 7 +- src/commands/dev/test.ts | 12 +- src/commands/fun/minesweeper.ts | 2 +- src/commands/info/botInfo.ts | 2 +- src/commands/info/guildInfo.ts | 46 +- src/commands/info/help.ts | 76 +- src/commands/info/pronouns.ts | 2 +- src/commands/info/snowflake.ts | 16 +- src/commands/info/userInfo.ts | 9 +- src/commands/leveling/level.ts | 11 +- src/commands/moderation/slowmode.ts | 9 +- src/commands/moderation/unmute.ts | 10 +- src/commands/moderation/warn.ts | 10 +- src/commands/utilities/uuid.ts | 2 +- src/commands/utilities/wolframAlpha.ts | 2 +- src/inhibitors/blacklist/channelGlobalBlacklist.ts | 5 +- src/inhibitors/blacklist/channelGuildBlacklist.ts | 5 +- src/inhibitors/blacklist/guildBlacklist.ts | 5 +- src/inhibitors/blacklist/userGlobalBlacklist.ts | 7 +- src/inhibitors/blacklist/userGuildBlacklist.ts | 5 +- src/inhibitors/checks/fatal.ts | 5 +- src/inhibitors/checks/guildUnavailable.ts | 5 +- src/inhibitors/command/dm.ts | 5 +- src/inhibitors/command/globalDisabledCommand.ts | 5 +- src/inhibitors/command/guild.ts | 5 +- src/inhibitors/command/guildDisabledCommand.ts | 5 +- src/inhibitors/command/nsfw.ts | 5 +- src/inhibitors/command/owner.ts | 5 +- src/inhibitors/command/restrictedChannel.ts | 5 +- src/inhibitors/command/restrictedGuild.ts | 5 +- src/inhibitors/command/superUser.ts | 5 +- src/lib/badwords.ts | 1 - src/lib/common/ButtonPaginator.ts | 26 +- src/lib/common/DeleteButton.ts | 2 +- src/lib/common/Moderation.ts | 16 +- src/lib/common/typings/BushInspectOptions.d.ts | 4 +- src/lib/extensions/discord-akairo/BushClient.ts | 26 +- .../extensions/discord-akairo/BushClientUtil.ts | 36 +- src/lib/extensions/discord-akairo/BushCommand.ts | 12 +- .../discord.js/BushBaseGuildTextChannel.ts | 9 +- src/lib/extensions/discord.js/BushGuild.ts | 6 +- .../extensions/discord.js/BushGuildManager.d.ts | 3 +- .../discord.js/BushGuildMemberManager.d.ts | 9 +- .../extensions/discord.js/BushMessageManager.d.ts | 39 +- .../extensions/discord.js/BushThreadManager.d.ts | 42 +- .../discord.js/BushThreadMemberManager.d.ts | 10 +- src/lib/models/ActivePunishment.ts | 28 +- src/lib/models/Global.ts | 24 +- src/lib/models/Guild.ts | 74 +- src/lib/models/Level.ts | 14 +- src/lib/models/ModLog.ts | 44 +- src/lib/models/Stat.ts | 12 +- src/lib/models/StickyRole.ts | 18 +- src/lib/models/__helpers.ts | 2 +- src/lib/utils/BushCache.ts | 4 +- src/lib/utils/BushConstants.ts | 198 +-- src/listeners/commands/commandBlocked.ts | 4 +- src/listeners/guild/guildMemberRemove.ts | 9 +- src/listeners/message/autoThread.ts | 12 +- src/listeners/message/directMessage.ts | 13 +- yarn.lock | 1851 +++++++++++++++----- 66 files changed, 2016 insertions(+), 917 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ad87154..bbaa22f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -49,7 +49,7 @@ jobs: git config --local user.name "github-actions[bot]" - name: Format and Commit run: | - yarn format || true + yarn format git commit -am "Automatically format code" || true - name: Push Changes uses: NotEnoughUpdates/github-push-action@master diff --git a/.vscode/settings.json b/.vscode/settings.json index 1dd2bce..6413fdc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,7 +23,6 @@ "source.fixAll.eslint": true, "source.format": true }, - "editor.formatOnSave": true, "diffEditor.wordWrap": "on", "editor.insertSpaces": false, "editor.wordWrap": "on", @@ -32,11 +31,10 @@ "prettier.prettierPath": ".yarn/sdks/prettier/index.js", "prettier.withNodeModules": true, "prettier.useEditorConfig": false, - "eslint.nodePath": ".yarn/sdks", // "typescript.tsdk": ".yarn/sdks/typescript/lib", "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, - "better-comments.highlightPlainText": true, + "better-comments.highlightPlainText": false, "better-comments.multilineComments": true, "better-comments.tags": [ { @@ -57,24 +55,6 @@ "bold": false, "italic": false }, - // { - // "tag": "#", - // "color": "#f003fc", - // "strikethrough": false, - // "underline": false, - // "backgroundColor": "transparent", - // "bold": false, - // "italic": false - // }, - // { - // "tag": "//", - // "color": "#474747", - // "strikethrough": true, - // "underline": false, - // "backgroundColor": "transparent", - // "bold": false, - // "italic": false - // }, { "tag": "todo", "color": "#FF8C00", @@ -84,15 +64,6 @@ "bold": false, "italic": false }, - // { - // "tag": "*", - // "color": "#98C379", - // "strikethrough": false, - // "underline": false, - // "backgroundColor": "transparent", - // "bold": false, - // "italic": false - // }, { "tag": "@ts-", "color": "#f54242", @@ -121,5 +92,4 @@ "italic": false } ], - "compile-hero.disable-compile-files-on-did-save-code": true } \ No newline at end of file diff --git a/package.json b/package.json index bb59bec..e6acde6 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,14 @@ "contributors": [ "Tyman#5998 (@TymanWasTaken)", "TrashCan#8913 (@TrashCan69420)", - "tricked#3777 (@SkyBlockDev)", + "tricked#3777 (@Tricked-dev)", "rioho#0001 (@riohorealhk)", "Proudmuslim#2900 (@proudmuslim-dev)", - "Zordlan#3560 (@Zordlan)" + "katherine🌺#0668 (@Lisenaaaa)", + "jani270#0119 (@jani270)", + "pjones123#6025 (@pjones123)", + "Angry_Pineapple#6926 (@Angry-Pineapple3121)", + "EthanDevelops#5366 (@EthanDevelops)" ], "license": "CC-BY-NC-SA-4.0", "imports": { @@ -34,26 +38,28 @@ "format": "yarn prettier . --write", "lint": "yarn eslint --ext js,jsx,ts,tsx src", "format:check": "yarn prettier . --check", - "upgrade": "yarn rimraf yarn.lock && yarn cache clean && yarn install && yarn up && yarn up -R", + "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/humanize-duration @notenoughupdates/wolfram-alpha-api @sentry/node @sentry/tracing canvas chalk discord-akairo@npm:@notenoughupdates/discord-akairo@dev discord.js@npm:@notenoughupdates/discord.js@dev events-intercept fuse.js got lodash mathjs moment nanoid node-os-utils numeral pg pg-hstore prettier@prettier/prettier pretty-bytes rimraf sequelize simplify-number 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.24.0 eslint eslint-config-prettier", "beta": "git push && git checkout beta && git merge master && git push && git checkout master", "deploy:beta": "wsl /bin/bash -c \"pm2 deploy ecosystem.config.cjs beta\"", "deploy:production": "wsl /bin/bash -c \"pm2 deploy ecosystem.config.cjs production\"", "deploy:all": "yarn beta && wsl /bin/bash -c \"pm2 deploy ecosystem.config.cjs production && pm2 deploy ecosystem.config.cjs beta\"" }, "dependencies": { - "@notenoughupdates/wolfram-alpha-api": "^1.0.0", - "@sentry/node": "^6.14.3", - "@sentry/tracing": "^6.14.3", + "@notenoughupdates/discord.js-minesweeper": "^1.0.8", + "@notenoughupdates/events-intercept": "^3.0.1", + "@notenoughupdates/humanize-duration": "^4.0.1", + "@notenoughupdates/wolfram-alpha-api": "^1.0.1", + "@sentry/node": "^6.15.0", + "@sentry/tracing": "^6.15.0", "canvas": "^2.8.0", "chalk": "^4.1.2", "discord-akairo": "npm:@notenoughupdates/discord-akairo@dev", "discord.js": "npm:@notenoughupdates/discord.js@dev", - "discord.js-minesweeper": "^1.0.6", "events-intercept": "^2.0.0", "fuse.js": "^6.4.6", - "got": "^11.8.2", - "humanize-duration": "^3.27.0", + "got": "^11.8.3", "lodash": "^4.17.21", "mathjs": "^10.0.0", "moment": "^2.29.1", @@ -62,30 +68,29 @@ "numeral": "^2.0.6", "pg": "^8.7.1", "pg-hstore": "^2.3.4", - "prettier": "^2.4.1", + "prettier": "prettier/prettier", "pretty-bytes": "^5.6.0", "rimraf": "^3.0.2", - "sequelize": "^6.9.0", + "sequelize": "^6.12.0-alpha.1", "simplify-number": "^1.0.0", - "source-map-support": "^0.5.20", + "source-map-support": "^0.5.21", "tinycolor2": "^1.4.2", "tslib": "^2.3.1", - "typescript": "rc", + "typescript": "^4.5.2", "vm2": "^3.9.5" }, "devDependencies": { "@types/express": "^4.17.13", - "@types/humanize-duration": "^3.27.0", - "@types/lodash": "^4.14.176", - "@types/node": "^16.11.7", + "@types/lodash": "^4.14.177", + "@types/node": "^16.11.9", "@types/node-os-utils": "^1.2.0", "@types/numeral": "^2.0.2", "@types/tinycolor2": "^1.4.3", - "@types/validator": "^13.6.6", - "@typescript-eslint/eslint-plugin": "^5.3.1", - "@typescript-eslint/parser": "^5.3.1", + "@types/validator": "^13.7.0", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "@typescript-eslint/parser": "^5.4.0", "discord-api-types": "0.24.0", - "eslint": "^8.2.0", + "eslint": "^8.3.0", "eslint-config-prettier": "^8.3.0" }, "eslintConfig": { @@ -155,6 +160,10 @@ { "argsIgnorePattern": "^_" } + ], + "no-implied-eval": "off", + "@typescript-eslint/no-implied-eval": [ + "error" ] } }, diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts index 36c8fcb..8c09072 100644 --- a/src/arguments/permission.ts +++ b/src/arguments/permission.ts @@ -4,7 +4,7 @@ import { Permissions } from 'discord.js'; export const permission: BushArgumentTypeCaster = (_, phrase) => { if (!phrase) return null; phrase = phrase.toUpperCase().replace(/ /g, '_'); - if (!Reflect.has(Permissions.FLAGS, phrase)) { + if (!(phrase in Permissions.FLAGS)) { return null; } else { return phrase; diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 00c6a69..2ce4246 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -229,7 +229,7 @@ export default class SettingsCommand extends BushCommand { } const collector = msg.createMessageComponentCollector({ time: 300_000, - filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id + filter: (i) => i.guildId === msg.guildId && i.message?.id === msg.id }); collector.on('collect', async (interaction: MessageComponentInteraction) => { diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 8c9351d..d0f9c5c 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -1,6 +1,7 @@ import { BushCommand, - guildFeaturesArr, guildFeaturesObj, + guildFeaturesArr, + guildFeaturesObj, type BushMessage, type BushSlashMessage, type GuildFeatures @@ -36,7 +37,7 @@ export default class FeaturesCommand extends BushCommand { const collector = msg.createMessageComponentCollector({ componentType: 'SELECT_MENU', time: 300_000, - filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id + filter: (i) => i.guildId === msg.guildId && i.message?.id === msg.id }); collector.on('collect', async (interaction: SelectMenuInteraction) => { @@ -78,7 +79,7 @@ export default class FeaturesCommand extends BushCommand { return new MessageActionRow().addComponents( new MessageSelectMenu({ customId: 'command_selectFeature', - disabled: disable, + disabled: disable, maxValues: 1, minValues: 2, options: guildFeatures.map((f) => ({ diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index d4109f4..5120a34 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -1,11 +1,11 @@ import { BushCommand, ButtonPaginator, type BushMessage } from '#lib'; import { - Constants as jsConstants, - MessageActionRow, - MessageButton, - MessageEmbed, - type ApplicationCommand, - type Collection + Constants as jsConstants, + MessageActionRow, + MessageButton, + MessageEmbed, + type ApplicationCommand, + type Collection } from 'discord.js'; export default class TestCommand extends BushCommand { diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts index 71c5055..9b511a3 100644 --- a/src/commands/fun/minesweeper.ts +++ b/src/commands/fun/minesweeper.ts @@ -1,5 +1,5 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import Minesweeper from 'discord.js-minesweeper'; +import Minesweeper from '@notenoughupdates/discord.js-minesweeper'; export default class MinesweeperCommand extends BushCommand { public constructor() { diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 04a1b14..833ed96 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,7 +1,7 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { MessageEmbed, version as discordJSVersion } from 'discord.js'; import * as os from 'os'; -const {default: prettyBytes} = await import('pretty-bytes') +const { default: prettyBytes } = await import('pretty-bytes'); export default class BotInfoCommand extends BushCommand { public constructor() { diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index ef1c232..47a8281 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -1,5 +1,13 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Constants, Guild, MessageEmbed, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, type Vanity } from 'discord.js'; +import { + Constants, + Guild, + MessageEmbed, + type BaseGuildVoiceChannel, + type GuildPreview, + type Snowflake, + type Vanity +} from 'discord.js'; export default class GuildInfoCommand extends BushCommand { public constructor() { @@ -66,17 +74,17 @@ export default class GuildInfoCommand extends BushCommand { await guild.fetch(); const channels = guild.channels.cache; - type ChannelType = 'GUILD_TEXT'|'GUILD_NEWS'|'GUILD_VOICE'|'GUILD_STAGE_VOICE'|'GUILD_STORE'|'GUILD_CATEGORY'|'THREAD' - const channelTypes = ([ - 'GUILD_TEXT', - 'GUILD_VOICE', - 'GUILD_STAGE_VOICE', - 'GUILD_STORE', - 'GUILD_CATEGORY', - 'THREAD', - ] as ChannelType[]).map( - (type)=>`${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}` - ) + type ChannelType = + | 'GUILD_TEXT' + | 'GUILD_NEWS' + | 'GUILD_VOICE' + | 'GUILD_STAGE_VOICE' + | 'GUILD_STORE' + | 'GUILD_CATEGORY' + | 'THREAD'; + const channelTypes = ( + ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as ChannelType[] + ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`); const guildRegions = [ ...new Set( @@ -105,8 +113,18 @@ export default class GuildInfoCommand extends BushCommand { if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`); if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`); - enum EmojiTierMap { TIER_3 = 500, TIER_2 = 300, TIER_1 = 100, NONE = 50 } - enum StickerTierMap { TIER_3 = 60, TIER_2 = 30, TIER_1 = 15, NONE = 0 } + enum EmojiTierMap { + TIER_3 = 500, + TIER_2 = 300, + TIER_1 = 100, + NONE = 50 + } + enum StickerTierMap { + TIER_3 = 60, + TIER_2 = 30, + TIER_1 = 15, + NONE = 0 + } guildStats.push( `**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`, diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index f956405..3bf8f5e 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -44,35 +44,7 @@ export default class HelpCommand extends BushCommand { args: { command: BushCommand | string; showHidden?: boolean } ) { const prefix = util.prefix(message); - const row = new MessageActionRow(); - - if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${ - client.user!.id - }&permissions=5368709119918&scope=bot%20applications.commands` - }) - ); - } - if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Support Server', - url: client.config.supportGuild.invite - }) - ); - } - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'GitHub', - url: packageDotJSON.repository - }) - ); + const row = this.addLinks(message); const isOwner = client.isOwner(message.author); const isSuperUser = client.isSuperUser(message.author); @@ -91,17 +63,13 @@ export default class HelpCommand extends BushCommand { if (command.hidden && !args.showHidden) return false; if (command.channel == 'guild' && !message.guild && !args.showHidden) return false; if (command.ownerOnly && !isOwner) return false; - if (command.superUserOnly && !isSuperUser) { - return false; - } + if (command.superUserOnly && !isSuperUser) return false; return !(command.restrictedGuilds?.includes(message.guild?.id ?? '') === false && !args.showHidden); }); const categoryNice = category.id - .replace(/(\b\w)/gi, (lc): string => lc.toUpperCase()) - .replace(/'(S)/g, (letter): string => letter.toLowerCase()); - const categoryCommands = categoryFilter - .filter((cmd): boolean => cmd.aliases.length > 0) - .map((cmd): string => `\`${cmd.aliases[0]}\``); + .replace(/(\b\w)/gi, (lc) => lc.toUpperCase()) + .replace(/'(S)/g, (letter) => letter.toLowerCase()); + const categoryCommands = categoryFilter.filter((cmd) => cmd.aliases.length > 0).map((cmd) => `\`${cmd.aliases[0]}\``); if (categoryCommands.length > 0) { embed.addField(`${categoryNice}`, `${categoryCommands.join(' ')}`); } @@ -153,4 +121,38 @@ export default class HelpCommand extends BushCommand { return await message.util.reply({ embeds: [embed], components: [row] }); } + + private addLinks(message: BushMessage | BushSlashMessage) { + const row = new MessageActionRow(); + + if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Invite Me', + url: `https://discord.com/api/oauth2/authorize?client_id=${ + client.user!.id + }&permissions=5368709119918&scope=bot%20applications.commands` + }) + ); + } + if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Support Server', + url: client.config.supportGuild.invite + }) + ); + } + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'GitHub', + url: packageDotJSON.repository + }) + ); + + return row; + } } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index a7df5aa..3cf27b6 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -39,7 +39,7 @@ export default class PronounsCommand extends BushCommand { const user = args.user ?? message.author; const author = user.id === message.author.id; - if (message.util.isSlashMessage(message)) await message.interaction.deferReply() + if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); const pronouns = await util.getPronounsOf(user); if (!pronouns) { diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index 3b1a073..deb5692 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -6,7 +6,8 @@ import { type CategoryChannel, type Channel, type DeconstructedSnowflake, - type DMChannel, type Guild, + type DMChannel, + type Guild, type NewsChannel, type Role, type Snowflake, @@ -60,7 +61,9 @@ export default class SnowflakeCommand extends BushCommand { if (['dm', 'group'].includes(channel.type)) { const _channel = channel as DMChannel; channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(_channel.recipient.tag)} (${_channel.recipient.id})`); - snowflakeEmbed.setTitle(`:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\``); + snowflakeEmbed.setTitle( + `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\`` + ); } else if ( [ 'GUILD_CATEGORY', @@ -89,7 +92,9 @@ export default class SnowflakeCommand extends BushCommand { const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = [ `**Name:** ${util.discord.escapeMarkdown(guild.name)}`, - `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId})`, + `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${ + guild.ownerId + })`, `**Members:** ${guild.memberCount?.toLocaleString()}` ]; if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!); @@ -110,7 +115,10 @@ export default class SnowflakeCommand extends BushCommand { // Emoji if (client.emojis.cache.has(snowflake)) { const emoji = client.emojis.cache.get(snowflake)!; - const emojiInfo = [`**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, `**Animated:** ${emoji.animated}`]; + const emojiInfo = [ + `**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, + `**Animated:** ${emoji.animated}` + ]; if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} \`[Emoji]\``); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 49c23c9..601e044 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -53,9 +53,7 @@ export default class UserInfoCommand extends BushCommand { const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(util.discord.escapeMarkdown(user.tag)) - .setThumbnail( - user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true }) - ) + .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true })) .setTimestamp(); // Flags @@ -95,7 +93,7 @@ export default class UserInfoCommand extends BushCommand { const generalInfo = [`**Mention:** <@${user.id}>`, `**ID:** ${user.id}`, `**Created:** ${createdAt} (${createdAtDelta} ago)`]; if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`); if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ dynamic: true, format: 'png', size: 4096 })})`); - const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); + const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`); userEmbed.addField('» General Info', generalInfo.join('\n')); @@ -137,7 +135,8 @@ export default class UserInfoCommand extends BushCommand { presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`); if (activitiesNames.length) presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`); - if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); + if (customStatus && customStatus.length) + presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); userEmbed.addField('» Presence', presenceInfo.join('\n')); enum statusEmojis { diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index ea77124..eb86155 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -15,7 +15,7 @@ import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; // idk why I need to do default twice, it is being weird -const { default: SimplifyNumber } = ((await import('simplify-number')).default as unknown as typeof import('simplify-number')); +const { default: SimplifyNumber } = (await import('simplify-number')).default as unknown as typeof import('simplify-number'); export default class LevelCommand extends BushCommand { public constructor() { @@ -92,9 +92,12 @@ export default class LevelCommand extends BushCommand { gray = '#23272A', highlight = user.hexAccentColor ?? '#5865F2'; // Load roboto font - canvas.registerFont(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), { - family: 'Roboto' - }); + canvas.registerFont( + join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), + { + family: 'Roboto' + } + ); // Create image canvas const levelCard = canvas.createCanvas(800, 200), ctx = levelCard.getContext('2d'); diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 5b77096..e05a409 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -1,4 +1,11 @@ -import { BushCommand, type BushMessage, type BushNewsChannel, type BushSlashMessage, type BushTextChannel, type BushThreadChannel } from '#lib'; +import { + BushCommand, + type BushMessage, + type BushNewsChannel, + type BushSlashMessage, + type BushTextChannel, + type BushThreadChannel +} from '#lib'; import { Argument } from 'discord-akairo'; import { TextChannel, ThreadChannel, type NewsChannel } from 'discord.js'; diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index e1bda63..c31ce21 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,4 +1,12 @@ -import { AllowedMentions, BushCommand, Moderation, type BushGuildMember, type BushMessage, type BushSlashMessage, type BushUser } from '#lib'; +import { + AllowedMentions, + BushCommand, + Moderation, + type BushGuildMember, + type BushMessage, + type BushSlashMessage, + type BushUser +} from '#lib'; export default class UnmuteCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 25b47ec..9b58cf6 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,4 +1,12 @@ -import { AllowedMentions, BushCommand, Moderation, type BushGuildMember, type BushMessage, type BushSlashMessage, type BushUser } from '#lib'; +import { + AllowedMentions, + BushCommand, + Moderation, + type BushGuildMember, + type BushMessage, + type BushSlashMessage, + type BushUser +} from '#lib'; export default class WarnCommand extends BushCommand { public constructor() { diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index 1be6079..556a4de 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -2,7 +2,7 @@ import { BushCommand, type BushMessage } from '#lib'; export default class UuidCommand extends BushCommand { public constructor() { - super('uuid', { + super('uuid', { aliases: ['uuid'], category: 'utilities', description: { diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts index 13512bb..f64fd4f 100644 --- a/src/commands/utilities/wolframAlpha.ts +++ b/src/commands/utilities/wolframAlpha.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { initializeClass as WolframAlphaAPI } from "@notenoughupdates/wolfram-alpha-api"; import { MessageEmbed, type MessageOptions } from 'discord.js'; -const { default: WolframAlphaAPI } = (await import("@notenoughupdates/wolfram-alpha-api")).default as unknown as typeof import("@notenoughupdates/wolfram-alpha-api") export default class WolframAlphaCommand extends BushCommand { public constructor() { diff --git a/src/inhibitors/blacklist/channelGlobalBlacklist.ts b/src/inhibitors/blacklist/channelGlobalBlacklist.ts index 5a0f0f1..b9d7240 100644 --- a/src/inhibitors/blacklist/channelGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/channelGlobalBlacklist.ts @@ -15,7 +15,10 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || /* client.isSuperUser(message.author) ||*/ client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedChannels.includes(message.channel!.id) && !command.bypassChannelBlacklist) { - void client.console.verbose('channelGlobalBlacklist', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'channelGlobalBlacklist', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/blacklist/channelGuildBlacklist.ts b/src/inhibitors/blacklist/channelGuildBlacklist.ts index a2c50e3..e881ebb 100644 --- a/src/inhibitors/blacklist/channelGuildBlacklist.ts +++ b/src/inhibitors/blacklist/channelGuildBlacklist.ts @@ -24,7 +24,10 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { (await message.guild.getSetting('blacklistedChannels'))?.includes(message.channel!.id) && !command.bypassChannelBlacklist ) { - void client.console.verbose('channelGuildBlacklist', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'channelGuildBlacklist', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index 4fb7b5a..b319475 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -18,7 +18,10 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { ) return false; if (client.cache.global.blacklistedGuilds.includes(message.guild.id)) { - void client.console.verbose('guildBlacklist', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'guildBlacklist', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/blacklist/userGlobalBlacklist.ts b/src/inhibitors/blacklist/userGlobalBlacklist.ts index 5d07ddb..0f8cea7 100644 --- a/src/inhibitors/blacklist/userGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/userGlobalBlacklist.ts @@ -15,7 +15,12 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedUsers.includes(message.author.id)) { - void client.console.verbose('userGlobalBlacklist', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.inGuild() ? message.guild?.name : message.author.tag}>>.`) + void client.console.verbose( + 'userGlobalBlacklist', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${ + message.inGuild() ? message.guild?.name : message.author.tag + }>>.` + ); return true; } return false; diff --git a/src/inhibitors/blacklist/userGuildBlacklist.ts b/src/inhibitors/blacklist/userGuildBlacklist.ts index e1c40ce..a87e47c 100644 --- a/src/inhibitors/blacklist/userGuildBlacklist.ts +++ b/src/inhibitors/blacklist/userGuildBlacklist.ts @@ -15,7 +15,10 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedUsers'))?.includes(message.author.id)) { - void client.console.verbose('userGuildBlacklist', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'userGuildBlacklist', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/checks/fatal.ts b/src/inhibitors/checks/fatal.ts index 68e1371..2521b2f 100644 --- a/src/inhibitors/checks/fatal.ts +++ b/src/inhibitors/checks/fatal.ts @@ -14,7 +14,10 @@ export default class FatalInhibitor extends BushInhibitor { if (client.isOwner(message.author)) return false; for (const property in client.cache.global) { if (!client.cache.global[property as keyof typeof client.cache.global]) { - void client.console.verbose('fatal', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'fatal', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } } diff --git a/src/inhibitors/checks/guildUnavailable.ts b/src/inhibitors/checks/guildUnavailable.ts index 38d0ffa..eb85fb7 100644 --- a/src/inhibitors/checks/guildUnavailable.ts +++ b/src/inhibitors/checks/guildUnavailable.ts @@ -12,7 +12,10 @@ export default class GuildUnavailableInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage): Promise { if (message.guild && !message.guild.available) { - void client.console.verbose('guildUnavailable', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'guildUnavailable', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/dm.ts b/src/inhibitors/command/dm.ts index 34fcb12..ebcd647 100644 --- a/src/inhibitors/command/dm.ts +++ b/src/inhibitors/command/dm.ts @@ -12,7 +12,10 @@ export default class DMInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.channel === 'dm' && message.guild) { - void client.console.verbose('dm', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'dm', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/globalDisabledCommand.ts b/src/inhibitors/command/globalDisabledCommand.ts index da267ef..82163f0 100644 --- a/src/inhibitors/command/globalDisabledCommand.ts +++ b/src/inhibitors/command/globalDisabledCommand.ts @@ -13,7 +13,10 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (message.author.isOwner()) return false; if (client.cache.global.disabledCommands?.includes(command?.id)) { - void client.console.verbose('disabledGlobalCommand', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'disabledGlobalCommand', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/guild.ts b/src/inhibitors/command/guild.ts index 9843972..69b5df9 100644 --- a/src/inhibitors/command/guild.ts +++ b/src/inhibitors/command/guild.ts @@ -12,7 +12,10 @@ export default class GuildInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.channel === 'guild' && !message.guild) { - void client.console.verbose('guild', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.author.tag}>>.`) + void client.console.verbose( + 'guild', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.author.tag}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/guildDisabledCommand.ts b/src/inhibitors/command/guildDisabledCommand.ts index 4343b1a..a04984d 100644 --- a/src/inhibitors/command/guildDisabledCommand.ts +++ b/src/inhibitors/command/guildDisabledCommand.ts @@ -15,7 +15,10 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { - void client.console.verbose('disabledGuildCommand', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.`) + void client.console.verbose( + 'disabledGuildCommand', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/nsfw.ts b/src/inhibitors/command/nsfw.ts index 7f0f3e7..fb4e51f 100644 --- a/src/inhibitors/command/nsfw.ts +++ b/src/inhibitors/command/nsfw.ts @@ -13,7 +13,10 @@ export default class NsfwInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.onlyNsfw && !(message.channel as TextChannel).nsfw) { - void client.console.verbose('notNsfw', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'notNsfw', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } return false; diff --git a/src/inhibitors/command/owner.ts b/src/inhibitors/command/owner.ts index 86bab76..8eee1e0 100644 --- a/src/inhibitors/command/owner.ts +++ b/src/inhibitors/command/owner.ts @@ -13,7 +13,10 @@ export default class OwnerInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.ownerOnly) { if (!client.isOwner(message.author)) { - void client.console.verbose('owner', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'owner', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } } diff --git a/src/inhibitors/command/restrictedChannel.ts b/src/inhibitors/command/restrictedChannel.ts index 265200e..c8f2e1e 100644 --- a/src/inhibitors/command/restrictedChannel.ts +++ b/src/inhibitors/command/restrictedChannel.ts @@ -13,7 +13,10 @@ export default class RestrictedChannelInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.restrictedChannels?.length && message.channel) { if (!command.restrictedChannels.includes(message.channel.id)) { - void client.console.verbose('restrictedChannel', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'restrictedChannel', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } } diff --git a/src/inhibitors/command/restrictedGuild.ts b/src/inhibitors/command/restrictedGuild.ts index a27220c..a8a5097 100644 --- a/src/inhibitors/command/restrictedGuild.ts +++ b/src/inhibitors/command/restrictedGuild.ts @@ -13,7 +13,10 @@ export default class RestrictedGuildInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.restrictedChannels?.length && message.channel) { if (!command.restrictedChannels.includes(message.channel.id)) { - void client.console.verbose('restrictedGuild', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'restrictedGuild', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } } diff --git a/src/inhibitors/command/superUser.ts b/src/inhibitors/command/superUser.ts index a34df6d..a7c1f47 100644 --- a/src/inhibitors/command/superUser.ts +++ b/src/inhibitors/command/superUser.ts @@ -13,7 +13,10 @@ export default class SuperUserInhibitor extends BushInhibitor { public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise { if (command.superUserOnly) { if (!client.isSuperUser(message.author)) { - void client.console.verbose('superUser', `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`) + void client.console.verbose( + 'superUser', + `Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.` + ); return true; } } diff --git a/src/lib/badwords.ts b/src/lib/badwords.ts index 20ca29d..cab7cec 100644 --- a/src/lib/badwords.ts +++ b/src/lib/badwords.ts @@ -359,7 +359,6 @@ export default { regex: false, }, - /* -------------------------------------------------------------------------- */ /* Misc Scams */ /* -------------------------------------------------------------------------- */ diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts index 6a2dba2..b8ae249 100644 --- a/src/lib/common/ButtonPaginator.ts +++ b/src/lib/common/ButtonPaginator.ts @@ -1,11 +1,11 @@ import { DeleteButton, type BushMessage, type BushSlashMessage } from '#lib'; import { - Constants, - MessageActionRow, - MessageButton, - MessageEmbed, - type MessageComponentInteraction, - type MessageEmbedOptions + Constants, + MessageActionRow, + MessageButton, + MessageEmbed, + type MessageComponentInteraction, + type MessageEmbedOptions } from 'discord.js'; export class ButtonPaginator { @@ -75,7 +75,7 @@ export class ButtonPaginator { })) as BushMessage; const collector = this.sentMessage.createMessageComponentCollector({ - filter: (i) => i.customId.startsWith('paginate_') && i.message.id === this.sentMessage!.id, + filter: (i) => i.customId.startsWith('paginate_') && i.message?.id === this.sentMessage!.id, time: 300000 }); @@ -128,11 +128,13 @@ export class ButtonPaginator { } protected async edit(interaction: MessageComponentInteraction) { - return interaction?.update({ - content: this.text, - embeds: [this.embeds[this.curPage]], - components: [this.getPaginationRow()] - }).catch(() => null); + return interaction + ?.update({ + content: this.text, + embeds: [this.embeds[this.curPage]], + components: [this.getPaginationRow()] + }) + .catch(() => null); } protected getPaginationRow(disableAll = false): MessageActionRow { diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts index 4792cf7..38ce6df 100644 --- a/src/lib/common/DeleteButton.ts +++ b/src/lib/common/DeleteButton.ts @@ -25,7 +25,7 @@ export class DeleteButton { const msg = (await this.message.util.reply(this.messageOptions)) as BushMessage; const collector = msg.createMessageComponentCollector({ - filter: (interaction) => interaction.customId == 'paginate__stop' && interaction.message.id == msg.id, + filter: (interaction) => interaction.customId == 'paginate__stop' && interaction.message?.id == msg.id, time: 300000 }); diff --git a/src/lib/common/Moderation.ts b/src/lib/common/Moderation.ts index 13ebf69..a7a037f 100644 --- a/src/lib/common/Moderation.ts +++ b/src/lib/common/Moderation.ts @@ -1,12 +1,12 @@ import { - ActivePunishment, - ActivePunishmentType, - Guild, - ModLog, - ModLogType, - type BushGuildMember, - type BushGuildMemberResolvable, - type BushGuildResolvable + ActivePunishment, + ActivePunishmentType, + Guild, + ModLog, + ModLogType, + type BushGuildMember, + type BushGuildMemberResolvable, + type BushGuildResolvable } from '#lib'; import { type Snowflake } from 'discord.js'; diff --git a/src/lib/common/typings/BushInspectOptions.d.ts b/src/lib/common/typings/BushInspectOptions.d.ts index e51e758..38c70b1 100644 --- a/src/lib/common/typings/BushInspectOptions.d.ts +++ b/src/lib/common/typings/BushInspectOptions.d.ts @@ -42,7 +42,7 @@ export interface BushInspectOptions extends InspectOptions { * **Default**: `false`. */ showProxy?: boolean | undefined; - + /** * Specifies the maximum number of `Array`, [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) elements to include when formatting. Set to `null` or `Infinity` to @@ -88,7 +88,7 @@ export interface BushInspectOptions extends InspectOptions { * **Default**: `false`. */ sorted?: boolean | ((a: string, b: string) => number) | undefined; - + /** * If set to `true`, getters are inspected. If set to `'get'`, only getters without a * corresponding setter are inspected. If set to `'set'`, only getters with a diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 93ed9d7..59aea26 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -10,6 +10,7 @@ import type { BushUserManager, Config } from '#lib'; +import { patch, type PatchedElements } from '@notenoughupdates/events-intercept'; import * as Sentry from '@sentry/node'; import { AkairoClient, ContextMenuCommandHandler, version as akairoVersion } from 'discord-akairo'; import { @@ -18,7 +19,9 @@ import { Structures, version as discordJsVersion, type Awaitable, - type Collection, type DMChannel, type InteractionReplyOptions, + type Collection, + type DMChannel, + type InteractionReplyOptions, type Message, type MessageEditOptions, type MessageOptions, @@ -28,8 +31,6 @@ import { type Snowflake, type WebhookEditMessageOptions } from 'discord.js'; -//@ts-ignore: no typings -import eventsIntercept from 'events-intercept'; import path from 'path'; import readline from 'readline'; import type { Sequelize as SequelizeType } from 'sequelize'; @@ -92,7 +93,7 @@ export type BushThreadMemberResolvable = BushThreadMember | BushUserResolvable; export type BushUserResolvable = BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember; export type BushGuildMemberResolvable = BushGuildMember | BushUserResolvable; export type BushRoleResolvable = BushRole | Snowflake; -export type BushMessageResolvable = Message| BushMessage | Snowflake; +export type BushMessageResolvable = Message | BushMessage | Snowflake; export type BushEmojiResolvable = Snowflake | BushGuildEmoji | BushReactionEmoji; export type BushEmojiIdentifierResolvable = string | BushEmojiResolvable; export type BushThreadChannelResolvable = BushThreadChannel | Snowflake; @@ -157,6 +158,7 @@ export class BushClient extends AkairoClient; this.config = config; @@ -344,8 +346,6 @@ export class BushClient extends AkairoClient { await this.guilds.fetch(); const promises = this.guilds.cache.map((guild) => { @@ -386,23 +386,21 @@ export class BushClient extends AkairoClient(event: K, listener: (...args: BushClientEvents[K]) => Awaitable): this; - on(event: Exclude, listener: (...args: any[]) => Awaitable): this + on(event: Exclude, listener: (...args: any[]) => Awaitable): this; once(event: K, listener: (...args: BushClientEvents[K]) => Awaitable): this; - once(event: Exclude, listener: (...args: any[]) => Awaitable): this + once(event: Exclude, listener: (...args: any[]) => Awaitable): this; emit(event: K, ...args: BushClientEvents[K]): boolean; - emit(event: Exclude, ...args: unknown[]): boolean + emit(event: Exclude, ...args: unknown[]): boolean; off(event: K, listener: (...args: BushClientEvents[K]) => Awaitable): this; - off(event: Exclude, listener: (...args: any[]) => Awaitable): this + off(event: Exclude, listener: (...args: any[]) => Awaitable): this; removeAllListeners(event?: K): this; - removeAllListeners(event?: Exclude): this + removeAllListeners(event?: Exclude): this; } diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index f21d104..8f1e67a 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -16,6 +16,7 @@ import { type Pronoun, type PronounCode } from '#lib'; +import { humanizeDuration } from '@notenoughupdates/humanize-duration'; import { exec } from 'child_process'; import { ClientUtil, Util as AkairoUtil } from 'discord-akairo'; import { APIMessage } from 'discord-api-types'; @@ -40,7 +41,6 @@ import moment from 'moment'; import { inspect, promisify } from 'util'; import CommandErrorListener from '../../../listeners/commands/commandError.js'; import { Format } from '../../common/Format.js'; -const { default: humanizeDuration } = await import ('humanize-duration') export class BushClientUtil extends ClientUtil { /** @@ -255,11 +255,11 @@ export class BushClientUtil extends ClientUtil { * @param options - The options you would like to use to inspect the object */ public inspect(object: any, options?: BushInspectOptions): string { - const optionsWithDefaults = this.getDefaultInspectOptions(options) + const optionsWithDefaults = this.getDefaultInspectOptions(options); return inspect(object, optionsWithDefaults); } - private getDefaultInspectOptions(options?:BushInspectOptions): BushInspectOptions { + private getDefaultInspectOptions(options?: BushInspectOptions): BushInspectOptions { const { showHidden = false, depth = 2, @@ -274,18 +274,18 @@ export class BushClientUtil extends ClientUtil { getters = true } = options ?? {}; return { - showHidden, - depth, - colors, - customInspect, - showProxy, - maxArrayLength, - maxStringLength, - breakLength, - compact, - sorted, + showHidden, + depth, + colors, + customInspect, + showProxy, + maxArrayLength, + maxStringLength, + breakLength, + compact, + sorted, getters - } + }; } #mapCredential(old: string): string { @@ -331,9 +331,7 @@ export class BushClientUtil extends ClientUtil { length = 1024 ) { input = - !inspectOptions?.inspectStrings && typeof input === 'string' - ? input - : this.inspect(input, inspectOptions ?? undefined); + !inspectOptions?.inspectStrings && typeof input === 'string' ? input : this.inspect(input, inspectOptions ?? undefined); if (inspectOptions) inspectOptions.inspectStrings = undefined; input = this.discord.cleanCodeBlockContent(input); input = this.redact(input); @@ -449,8 +447,8 @@ export class BushClientUtil extends ClientUtil { } public humanizeDuration(duration: number, largest?: number): string { - if (largest) return humanizeDuration(duration, { language: 'en', maxDecimalPoints: 2, largest }); - else return humanizeDuration(duration, { language: 'en', maxDecimalPoints: 2 }); + if (largest) return humanizeDuration(duration, { language: 'en', maxDecimalPoints: 2, largest })!; + else return humanizeDuration(duration, { language: 'en', maxDecimalPoints: 2 })!; } public timestampDuration(duration: number): string { diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 03f6606..11f5ee3 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,10 +1,16 @@ import { type BushClient, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '#lib'; -import { Command, type ArgumentOptions, type ArgumentPromptOptions, type ArgumentTypeCaster, type CommandOptions } from 'discord-akairo'; +import { + Command, + type ArgumentOptions, + type ArgumentPromptOptions, + type ArgumentTypeCaster, + type CommandOptions +} from 'discord-akairo'; import { BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; import { type PermissionResolvable, type Snowflake } from 'discord.js'; -export type BaseBushArgumentType = - | BaseArgumentType +export type BaseBushArgumentType = + | BaseArgumentType | 'duration' | 'contentWithDuration' | 'permission' diff --git a/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts b/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts index 652a50f..c3c279e 100644 --- a/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts +++ b/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts @@ -1,11 +1,4 @@ -import type { - BushCategoryChannel, - BushClient, - BushGuild, - BushGuildMember, - BushMessageManager, - BushThreadManager -} from '#lib'; +import type { BushCategoryChannel, BushClient, BushGuild, BushGuildMember, BushMessageManager, BushThreadManager } from '#lib'; import { BaseGuildTextChannel, type AllowedThreadTypeForNewsChannel, diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index 5849749..ff920ce 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -191,7 +191,11 @@ export class BushGuild extends Guild { const userObject = client.users.cache.get(user.id); const dmSuccess = await userObject - ?.send(`You have been unbanned from **${util.discord.escapeMarkdown(this.toString())}** for **${options.reason ?? 'No reason provided'}**.`) + ?.send( + `You have been unbanned from **${util.discord.escapeMarkdown(this.toString())}** for **${ + options.reason ?? 'No reason provided' + }**.` + ) .catch(() => false); dmSuccessEvent = !!dmSuccess; diff --git a/src/lib/extensions/discord.js/BushGuildManager.d.ts b/src/lib/extensions/discord.js/BushGuildManager.d.ts index 5bb8822..4dd0750 100644 --- a/src/lib/extensions/discord.js/BushGuildManager.d.ts +++ b/src/lib/extensions/discord.js/BushGuildManager.d.ts @@ -3,7 +3,8 @@ import { CachedManager, type Collection, type FetchGuildOptions, - type FetchGuildsOptions, type GuildCreateOptions, + type FetchGuildsOptions, + type GuildCreateOptions, type OAuth2Guild, type Snowflake } from 'discord.js'; diff --git a/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts b/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts index 8b1248c..0866fce 100644 --- a/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts +++ b/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts @@ -1,11 +1,4 @@ -import type { - BushClient, - BushGuild, - BushGuildMember, - BushGuildMemberResolvable, - BushUser, - BushUserResolvable -} from '#lib'; +import type { BushClient, BushGuild, BushGuildMember, BushGuildMemberResolvable, BushUser, BushUserResolvable } from '#lib'; import { CachedManager, type AddGuildMemberOptions, diff --git a/src/lib/extensions/discord.js/BushMessageManager.d.ts b/src/lib/extensions/discord.js/BushMessageManager.d.ts index 9ded94c..f6bc8e7 100644 --- a/src/lib/extensions/discord.js/BushMessageManager.d.ts +++ b/src/lib/extensions/discord.js/BushMessageManager.d.ts @@ -1,26 +1,27 @@ import { BushMessageResolvable, type BushMessage, type BushTextBasedChannels } from '#lib'; import { - CachedManager, - type BaseFetchOptions, - type ChannelLogsQueryOptions, - type Collection, - type EmojiIdentifierResolvable, - type MessageEditOptions, - type MessagePayload, type Snowflake + CachedManager, + type BaseFetchOptions, + type ChannelLogsQueryOptions, + type Collection, + type EmojiIdentifierResolvable, + type MessageEditOptions, + type MessagePayload, + type Snowflake } from 'discord.js'; import type { RawMessageData } from 'discord.js/typings/rawDataTypes'; export class BushMessageManager extends CachedManager { - public constructor(channel: BushTextBasedChannels, iterable?: Iterable); - public channel: BushTextBasedChannels; - public cache: Collection; - public crosspost(message: BushMessageResolvable): Promise; - public delete(message: BushMessageResolvable): Promise; - public edit(message: BushMessageResolvable, options: MessagePayload | MessageEditOptions): Promise; - public fetch(message: Snowflake, options?: BaseFetchOptions): Promise; - public fetch(options?: ChannelLogsQueryOptions, cacheOptions?: BaseFetchOptions): Promise>; - public fetchPinned(cache?: boolean): Promise>; - public react(message: BushMessageResolvable, emoji: EmojiIdentifierResolvable): Promise; - public pin(message: BushMessageResolvable): Promise; - public unpin(message: BushMessageResolvable): Promise; + public constructor(channel: BushTextBasedChannels, iterable?: Iterable); + public channel: BushTextBasedChannels; + public cache: Collection; + public crosspost(message: BushMessageResolvable): Promise; + public delete(message: BushMessageResolvable): Promise; + public edit(message: BushMessageResolvable, options: MessagePayload | MessageEditOptions): Promise; + public fetch(message: Snowflake, options?: BaseFetchOptions): Promise; + public fetch(options?: ChannelLogsQueryOptions, cacheOptions?: BaseFetchOptions): Promise>; + public fetchPinned(cache?: boolean): Promise>; + public react(message: BushMessageResolvable, emoji: EmojiIdentifierResolvable): Promise; + public pin(message: BushMessageResolvable): Promise; + public unpin(message: BushMessageResolvable): Promise; } diff --git a/src/lib/extensions/discord.js/BushThreadManager.d.ts b/src/lib/extensions/discord.js/BushThreadManager.d.ts index 6822a80..c824ae7 100644 --- a/src/lib/extensions/discord.js/BushThreadManager.d.ts +++ b/src/lib/extensions/discord.js/BushThreadManager.d.ts @@ -1,27 +1,25 @@ -import type { - BushThreadChannel -} from '#lib'; +import type { BushThreadChannel } from '#lib'; import { - CachedManager, - FetchedThreads, - NewsChannel, - TextChannel, - ThreadChannel, - type BaseFetchOptions, - type FetchArchivedThreadOptions, - type FetchThreadsOptions, - type Snowflake, - type ThreadChannelResolvable, - type ThreadCreateOptions + CachedManager, + FetchedThreads, + NewsChannel, + TextChannel, + ThreadChannel, + type BaseFetchOptions, + type FetchArchivedThreadOptions, + type FetchThreadsOptions, + type Snowflake, + type ThreadChannelResolvable, + type ThreadCreateOptions } from 'discord.js'; import type { RawThreadChannelData } from 'discord.js/typings/rawDataTypes'; export class BushThreadManager extends CachedManager { - public constructor(channel: TextChannel | NewsChannel, iterable?: Iterable); - public channel: TextChannel | NewsChannel; - public create(options: ThreadCreateOptions): Promise; - public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise; - public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise; - public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise; - public fetchActive(cache?: boolean): Promise; -} \ No newline at end of file + public constructor(channel: TextChannel | NewsChannel, iterable?: Iterable