From fd675ca9d60cc06d892ebc36a1b9624f15233f20 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 29 Jun 2021 20:48:27 -0400 Subject: don't judge part 1 --- .pnp.js | 20 +- .vscode/extensions.json | 16 +- .vscode/settings.json | 184 +++---- package.json | 3 + src/arguments/duration.ts | 4 +- src/bot.ts | 2 +- src/commands/config/muteRole.ts | 6 +- src/commands/config/prefix.ts | 6 +- src/commands/config/welcomeChannel.ts | 6 +- src/commands/dev/eval.ts | 10 +- src/commands/dev/reload.ts | 6 +- src/commands/dev/setLevel.ts | 6 +- src/commands/dev/superUser.ts | 4 +- src/commands/info/botInfo.ts | 2 +- src/commands/info/help.ts | 6 +- src/commands/info/ping.ts | 4 +- src/commands/info/pronouns.ts | 4 +- src/commands/moderation/ban.ts | 2 +- src/commands/moderation/kick.ts | 4 +- src/commands/moderation/modlog.ts | 2 +- src/commands/moderation/mute.ts | 2 +- src/commands/moderation/role.ts | 2 +- src/commands/moderation/warn.ts | 2 +- src/commands/moulberry-bush/capePerms.ts | 4 +- src/commands/moulberry-bush/giveawayPing.ts | 4 +- src/commands/moulberry-bush/level.ts | 4 +- src/commands/moulberry-bush/rule.ts | 4 +- src/inhibitors/blacklist/guildBlacklist.ts | 6 +- src/inhibitors/blacklist/userBlacklist.ts | 6 +- src/inhibitors/commands/disabledCommand.ts | 8 +- src/inhibitors/noCache.ts | 6 +- src/lib/extensions/BushArgumentOptions.ts | 59 --- src/lib/extensions/BushArgumentTypeCaster.ts | 4 - src/lib/extensions/BushClient.ts | 223 --------- src/lib/extensions/BushClientUtil.ts | 536 --------------------- src/lib/extensions/BushCommand.ts | 57 --- src/lib/extensions/BushCommandHandler.ts | 91 ---- src/lib/extensions/BushCommandUtil.ts | 10 - src/lib/extensions/BushGuild.ts | 22 - src/lib/extensions/BushGuildMember.ts | 15 - src/lib/extensions/BushInhibitor.ts | 15 - src/lib/extensions/BushInhinitorHandler.ts | 6 - src/lib/extensions/BushListener.ts | 6 - src/lib/extensions/BushListenerHandler.ts | 6 - src/lib/extensions/BushMessage.ts | 21 - src/lib/extensions/BushSlashMessage.ts | 20 - src/lib/extensions/BushTask.ts | 6 - src/lib/extensions/BushTaskHandler.ts | 11 - src/lib/extensions/BushUser.ts | 19 - .../discord-akairo/BushArgumentOptions.ts | 59 +++ .../discord-akairo/BushArgumentTypeCaster.ts | 4 + src/lib/extensions/discord-akairo/BushClient.ts | 233 +++++++++ .../extensions/discord-akairo/BushClientUtil.ts | 536 +++++++++++++++++++++ src/lib/extensions/discord-akairo/BushCommand.ts | 57 +++ .../discord-akairo/BushCommandHandler.ts | 90 ++++ .../extensions/discord-akairo/BushCommandUtil.ts | 10 + src/lib/extensions/discord-akairo/BushInhibitor.ts | 15 + .../discord-akairo/BushInhinitorHandler.ts | 6 + src/lib/extensions/discord-akairo/BushListener.ts | 6 + .../discord-akairo/BushListenerHandler.ts | 6 + .../extensions/discord-akairo/BushSlashMessage.ts | 20 + src/lib/extensions/discord-akairo/BushTask.ts | 6 + .../extensions/discord-akairo/BushTaskHandler.ts | 11 + .../extensions/discord.js/BushCategoryChannel.ts | 16 + src/lib/extensions/discord.js/BushDMChannel.ts | 14 + src/lib/extensions/discord.js/BushGuild.ts | 20 + src/lib/extensions/discord.js/BushGuildChannel.ts | 11 + src/lib/extensions/discord.js/BushGuildEmoji.ts | 15 + .../discord.js/BushGuildEmojiRoleManager.ts | 13 + src/lib/extensions/discord.js/BushGuildMember.ts | 13 + src/lib/extensions/discord.js/BushMessage.ts | 26 + .../extensions/discord.js/BushMessageManager.ts | 14 + src/lib/extensions/discord.js/BushNewsChannel.ts | 16 + src/lib/extensions/discord.js/BushRole.ts | 13 + src/lib/extensions/discord.js/BushStoreChannel.ts | 16 + src/lib/extensions/discord.js/BushTextChannel.ts | 13 + src/lib/extensions/discord.js/BushThreadChannel.ts | 23 + src/lib/extensions/discord.js/BushThreadManager.ts | 11 + src/lib/extensions/discord.js/BushThreadMember.ts | 14 + .../discord.js/BushThreadMemberManager.ts | 23 + src/lib/extensions/discord.js/BushUser.ts | 19 + src/lib/extensions/discord.js/BushVoiceChannel.ts | 12 + src/lib/models/Guild.ts | 2 +- src/lib/utils/BushLogger.ts | 2 +- src/listeners/client/ready.ts | 2 +- src/listeners/commands/commandBlocked.ts | 6 +- src/listeners/commands/commandError.ts | 4 +- .../commands/commandMissingPermissions.ts | 6 +- src/listeners/commands/commandStarted.ts | 4 +- src/listeners/commands/slashBlocked.ts | 6 +- src/listeners/commands/slashCommandError.ts | 6 +- src/listeners/commands/slashMissingPermissions.ts | 2 +- src/listeners/commands/slashStarted.ts | 6 +- src/listeners/guild/syncUnban.ts | 4 +- src/listeners/message/level.ts | 2 +- src/listeners/other/consoleListener.ts | 2 +- src/listeners/other/promiseRejection.ts | 2 +- src/tasks/unban.ts | 2 +- src/tasks/unmute.ts | 2 +- src/tasks/updateCache.ts | 4 +- yarn.lock | 24 +- 101 files changed, 1580 insertions(+), 1341 deletions(-) delete mode 100644 src/lib/extensions/BushArgumentOptions.ts delete mode 100644 src/lib/extensions/BushArgumentTypeCaster.ts delete mode 100644 src/lib/extensions/BushClient.ts delete mode 100644 src/lib/extensions/BushClientUtil.ts delete mode 100644 src/lib/extensions/BushCommand.ts delete mode 100644 src/lib/extensions/BushCommandHandler.ts delete mode 100644 src/lib/extensions/BushCommandUtil.ts delete mode 100644 src/lib/extensions/BushGuild.ts delete mode 100644 src/lib/extensions/BushGuildMember.ts delete mode 100644 src/lib/extensions/BushInhibitor.ts delete mode 100644 src/lib/extensions/BushInhinitorHandler.ts delete mode 100644 src/lib/extensions/BushListener.ts delete mode 100644 src/lib/extensions/BushListenerHandler.ts delete mode 100644 src/lib/extensions/BushMessage.ts delete mode 100644 src/lib/extensions/BushSlashMessage.ts delete mode 100644 src/lib/extensions/BushTask.ts delete mode 100644 src/lib/extensions/BushTaskHandler.ts delete mode 100644 src/lib/extensions/BushUser.ts create mode 100644 src/lib/extensions/discord-akairo/BushArgumentOptions.ts create mode 100644 src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts create mode 100644 src/lib/extensions/discord-akairo/BushClient.ts create mode 100644 src/lib/extensions/discord-akairo/BushClientUtil.ts create mode 100644 src/lib/extensions/discord-akairo/BushCommand.ts create mode 100644 src/lib/extensions/discord-akairo/BushCommandHandler.ts create mode 100644 src/lib/extensions/discord-akairo/BushCommandUtil.ts create mode 100644 src/lib/extensions/discord-akairo/BushInhibitor.ts create mode 100644 src/lib/extensions/discord-akairo/BushInhinitorHandler.ts create mode 100644 src/lib/extensions/discord-akairo/BushListener.ts create mode 100644 src/lib/extensions/discord-akairo/BushListenerHandler.ts create mode 100644 src/lib/extensions/discord-akairo/BushSlashMessage.ts create mode 100644 src/lib/extensions/discord-akairo/BushTask.ts create mode 100644 src/lib/extensions/discord-akairo/BushTaskHandler.ts create mode 100644 src/lib/extensions/discord.js/BushCategoryChannel.ts create mode 100644 src/lib/extensions/discord.js/BushDMChannel.ts create mode 100644 src/lib/extensions/discord.js/BushGuild.ts create mode 100644 src/lib/extensions/discord.js/BushGuildChannel.ts create mode 100644 src/lib/extensions/discord.js/BushGuildEmoji.ts create mode 100644 src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts create mode 100644 src/lib/extensions/discord.js/BushGuildMember.ts create mode 100644 src/lib/extensions/discord.js/BushMessage.ts create mode 100644 src/lib/extensions/discord.js/BushMessageManager.ts create mode 100644 src/lib/extensions/discord.js/BushNewsChannel.ts create mode 100644 src/lib/extensions/discord.js/BushRole.ts create mode 100644 src/lib/extensions/discord.js/BushStoreChannel.ts create mode 100644 src/lib/extensions/discord.js/BushTextChannel.ts create mode 100644 src/lib/extensions/discord.js/BushThreadChannel.ts create mode 100644 src/lib/extensions/discord.js/BushThreadManager.ts create mode 100644 src/lib/extensions/discord.js/BushThreadMember.ts create mode 100644 src/lib/extensions/discord.js/BushThreadMemberManager.ts create mode 100644 src/lib/extensions/discord.js/BushUser.ts create mode 100644 src/lib/extensions/discord.js/BushVoiceChannel.ts diff --git a/.pnp.js b/.pnp.js index 4cf4865..977d0de 100755 --- a/.pnp.js +++ b/.pnp.js @@ -47,9 +47,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["body-parser", "npm:1.19.0"], ["chalk", "npm:4.1.1"], ["common-tags", "npm:1.8.0"], - ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=36611850e2ebe5458be535448a2f4df30d3680e3"], + ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=58e5a8610d9cb47257cb163a94e284113a39a62b"], ["discord-api-types", "npm:0.18.1"], - ["discord.js", "npm:13.0.0-dev.5ad83a6a65e5944ceb3a41fee2df40ba1f5b03e4"], + ["discord.js", "npm:13.0.0-dev.edab5af.1624996138"], ["esbuild", "npm:0.12.12"], ["eslint", "npm:7.29.0"], ["eslint-config-prettier", "virtual:d7ae587dddcefd495158f5c047acecbca3203324d75e681c7d8657c07f901f74e152f0b39978f7428d3a91daad7b5020c47ece28de69c22fcbd49d04707bf15c#npm:8.3.0"], @@ -785,9 +785,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["body-parser", "npm:1.19.0"], ["chalk", "npm:4.1.1"], ["common-tags", "npm:1.8.0"], - ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=36611850e2ebe5458be535448a2f4df30d3680e3"], + ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=58e5a8610d9cb47257cb163a94e284113a39a62b"], ["discord-api-types", "npm:0.18.1"], - ["discord.js", "npm:13.0.0-dev.5ad83a6a65e5944ceb3a41fee2df40ba1f5b03e4"], + ["discord.js", "npm:13.0.0-dev.edab5af.1624996138"], ["esbuild", "npm:0.12.12"], ["eslint", "npm:7.29.0"], ["eslint-config-prettier", "virtual:d7ae587dddcefd495158f5c047acecbca3203324d75e681c7d8657c07f901f74e152f0b39978f7428d3a91daad7b5020c47ece28de69c22fcbd49d04707bf15c#npm:8.3.0"], @@ -1059,10 +1059,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }] ]], ["discord-akairo", [ - ["https://github.com/NotEnoughUpdates/discord-akairo.git#commit=36611850e2ebe5458be535448a2f4df30d3680e3", { - "packageLocation": "./.yarn/unplugged/discord-akairo-https-9825cfb3ed/node_modules/discord-akairo/", + ["https://github.com/NotEnoughUpdates/discord-akairo.git#commit=58e5a8610d9cb47257cb163a94e284113a39a62b", { + "packageLocation": "./.yarn/unplugged/discord-akairo-https-10183ac4c6/node_modules/discord-akairo/", "packageDependencies": [ - ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=36611850e2ebe5458be535448a2f4df30d3680e3"] + ["discord-akairo", "https://github.com/NotEnoughUpdates/discord-akairo.git#commit=58e5a8610d9cb47257cb163a94e284113a39a62b"] ], "linkType": "HARD", }] @@ -1084,10 +1084,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }] ]], ["discord.js", [ - ["npm:13.0.0-dev.5ad83a6a65e5944ceb3a41fee2df40ba1f5b03e4", { - "packageLocation": "./.yarn/unplugged/discord.js-npm-13.0.0-dev.5ad83a6a65e5944ceb3a41fee2df40ba1f5b03e4-a4083f1125/node_modules/discord.js/", + ["npm:13.0.0-dev.edab5af.1624996138", { + "packageLocation": "./.yarn/unplugged/discord.js-npm-13.0.0-dev.edab5af.1624996138-7dc41aa565/node_modules/discord.js/", "packageDependencies": [ - ["discord.js", "npm:13.0.0-dev.5ad83a6a65e5944ceb3a41fee2df40ba1f5b03e4"], + ["discord.js", "npm:13.0.0-dev.edab5af.1624996138"], ["@discordjs/collection", "npm:0.1.6"], ["@discordjs/form-data", "npm:3.0.1"], ["@sapphire/async-queue", "npm:1.1.4"], diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 94a8b5c..d3de569 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,10 @@ { - "recommendations": [ - "aaron-bond.better-comments", - "arcanis.vscode-zipfs", - "dbaeumer.vscode-eslint", - "eamodio.gitlens", - "esbenp.prettier-vscode", - "streetsidesoftware.code-spell-checker" - ] + "recommendations": [ + "aaron-bond.better-comments", + "arcanis.vscode-zipfs", + "dbaeumer.vscode-eslint", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 31f0057..02155ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,94 +1,94 @@ { - "files.exclude": { - "**/.git": true, - "**/.svn": true, - "**/.hg": true, - "**/CVS": true, - "**/.DS_Store": true, - "node_modules": true, - // "dist": true, - ".pnp.js": true - }, - "javascript.preferences.importModuleSpecifier": "project-relative", - "typescript.preferences.importModuleSpecifier": "project-relative", - "typescript.preferences.importModuleSpecifierEnding": "minimal", - "search.exclude": { - "**/.yarn": true, - "**/.pnp.*": true - }, - "editor.codeActionsOnSave": { - "source.organizeImports": true, - "source.fixAll.eslint": true, - "source.format": true - }, - "editor.formatOnSave": true, - "diffEditor.wordWrap": "on", - "editor.insertSpaces": false, - "editor.wordWrap": "on", - "editor.tabSize": 2, - "prettier.configPath": "package.json", - "prettier.prettierPath": ".yarn/sdks/prettier/index.js", - "prettier.withNodeModules": true, - "prettier.useEditorConfig": false, - "eslint.nodePath": ".yarn/sdks", - "typescript.tsdk": ".yarn/sdks/typescript/lib", - "typescript.enablePromptUseWorkspaceTsdk": true, - "better-comments.highlightPlainText": false, - "better-comments.multilineComments": true, - "better-comments.tags": [ - { - "tag": "!", - "color": "#FF2D00", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "?", - "color": "#3498DB", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "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", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "*", - "color": "#98C379", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - } - ] + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "node_modules": true, + // "dist": true, + ".pnp.js": true + }, + "javascript.preferences.importModuleSpecifier": "project-relative", + "typescript.preferences.importModuleSpecifier": "project-relative", + "typescript.preferences.importModuleSpecifierEnding": "minimal", + "search.exclude": { + "**/.yarn": true, + "**/.pnp.*": true + }, + "editor.codeActionsOnSave": { + "source.organizeImports": true, + "source.fixAll.eslint": true, + "source.format": true + }, + "editor.formatOnSave": true, + "diffEditor.wordWrap": "on", + "editor.insertSpaces": false, + "editor.wordWrap": "on", + "editor.tabSize": 2, + "prettier.configPath": "package.json", + "prettier.prettierPath": ".yarn/sdks/prettier/index.js", + "prettier.withNodeModules": true, + "prettier.useEditorConfig": false, + "eslint.nodePath": ".yarn/sdks", + "typescript.tsdk": ".yarn/sdks/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, + "better-comments.highlightPlainText": false, + "better-comments.multilineComments": true, + "better-comments.tags": [ + { + "tag": "!", + "color": "#FF2D00", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "?", + "color": "#3498DB", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "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", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "*", + "color": "#98C379", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + } + ] } diff --git a/package.json b/package.json index 875b52e..07f0810 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,9 @@ "discord.js@13.0.0-dev.e37ef3af2151e556527ccd8e98ec531bdcc0ed70": { "unplugged": true }, + "discord.js@13.0.0-dev.edab5af.1624996138": { + "unplugged": true + }, "prettier@2.3.1": { "unplugged": true } diff --git a/src/arguments/duration.ts b/src/arguments/duration.ts index 7b7a922..6007b4e 100644 --- a/src/arguments/duration.ts +++ b/src/arguments/duration.ts @@ -1,5 +1,5 @@ -import { BushArgumentTypeCaster } from '../lib/extensions/BushArgumentTypeCaster'; -import { BushMessage } from '../lib/extensions/BushMessage'; +import { BushArgumentTypeCaster } from '../lib/extensions/discord-akairo/BushArgumentTypeCaster'; +import { BushMessage } from '../lib/extensions/discord.js/BushMessage'; import { BushConstants } from '../lib/utils/BushConstants'; export const durationTypeCaster: BushArgumentTypeCaster = async (_message: BushMessage, phrase): Promise => { diff --git a/src/bot.ts b/src/bot.ts index ee7ce92..5e2d10c 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,5 @@ -import { BushClient } from './lib/extensions/BushClient'; import * as config from './config/options'; +import { BushClient } from './lib/extensions/discord-akairo/BushClient'; const client: BushClient = new BushClient(config); client.start(); diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index 2dc34c3..2b2f938 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -1,7 +1,7 @@ import { Role } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class MuteRoleCommand extends BushCommand { diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index b788d17..1551205 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -1,6 +1,6 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class PrefixCommand extends BushCommand { constructor() { diff --git a/src/commands/config/welcomeChannel.ts b/src/commands/config/welcomeChannel.ts index d531c7d..2d66a25 100644 --- a/src/commands/config/welcomeChannel.ts +++ b/src/commands/config/welcomeChannel.ts @@ -1,7 +1,7 @@ import { Channel } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class WelcomeChannelCommand extends BushCommand { public constructor() { diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index a1c2d87..fc6e7e8 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -4,9 +4,9 @@ import { Constants } from 'discord-akairo'; import { CommandInteraction, MessageEmbed, MessageEmbedOptions, Util } from 'discord.js'; import { transpile } from 'typescript'; import { inspect, promisify } from 'util'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; const clean = (text) => { if (typeof text === 'string') { @@ -135,8 +135,8 @@ export default class EvalCommand extends BushCommand { show_proto: boolean; } ): Promise { - // if (!message.author.isOwner()) - // return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + if (!message.author.isOwner()) + return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); if (message.util.isSlash) { await (message as BushSlashMessage).interaction.defer({ ephemeral: args.silent }); } diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 656bb34..82dde4c 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,6 +1,6 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class ReloadCommand extends BushCommand { constructor() { diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index 6c8131a..9903013 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -1,7 +1,7 @@ import { User } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import { Level } from '../../lib/models'; import AllowedMentions from '../../lib/utils/AllowedMentions'; diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 773209c..8bbc391 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -1,7 +1,7 @@ import { Constants } from 'discord-akairo'; import { User } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import { Global } from '../../lib/models'; export default class SuperUserCommand extends BushCommand { diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 3db4151..b77a271 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,6 +1,6 @@ import { Message, MessageEmbed } from 'discord.js'; import { duration } from 'moment'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; export default class BotInfoCommand extends BushCommand { constructor() { diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index b58d73c..6e14d96 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,7 +1,7 @@ import { MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class HelpCommand extends BushCommand { constructor() { diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 6584ab5..45cfd22 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,6 +1,6 @@ import { Message, MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; export default class PingCommand extends BushCommand { constructor() { diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 60d0c1a..538ec64 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,7 +1,7 @@ import { Message, MessageEmbed, User } from 'discord.js'; import got, { HTTPError } from 'got'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; export const pronounMapping = { unspecified: 'Unspecified', diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 7ce222a..9df1c2a 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,7 +1,7 @@ import { Argument } from 'discord-akairo'; import { CommandInteraction, Message, User } from 'discord.js'; import moment from 'moment'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { Ban, Guild, ModLog, ModLogType } from '../../lib/models'; /* const durationAliases: Record = { diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 748753f..a666c8e 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,6 +1,6 @@ import { CommandInteraction, GuildMember, Message } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; import { Guild, ModLog, ModLogType } from '../../lib/models'; export default class KickCommand extends BushCommand { diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index e32df42..27018f1 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -2,7 +2,7 @@ import { stripIndent } from 'common-tags'; import { Argument } from 'discord-akairo'; import { Message, MessageEmbed } from 'discord.js'; import moment from 'moment'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { ModLog } from '../../lib/models'; export default class ModlogCommand extends BushCommand { diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 9b6ad70..88fcc69 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,7 +1,7 @@ import { Argument } from 'discord-akairo'; import { CommandInteraction, Message, User } from 'discord.js'; import moment from 'moment'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { Guild, ModLog, ModLogType, Mute } from '../../lib/models'; export default class MuteCommand extends BushCommand { diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index f0918f0..d1f8e00 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import { GuildMember, Message, Role } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class RoleCommand extends BushCommand { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index d48049b..c146db0 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,5 +1,5 @@ import { GuildMember, Message } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { Guild, ModLog, ModLogType } from '../../lib/models'; export default class WarnCommand extends BushCommand { diff --git a/src/commands/moulberry-bush/capePerms.ts b/src/commands/moulberry-bush/capePerms.ts index d1850c8..b6508d0 100644 --- a/src/commands/moulberry-bush/capePerms.ts +++ b/src/commands/moulberry-bush/capePerms.ts @@ -1,8 +1,8 @@ import { Constants } from 'discord-akairo'; import { MessageEmbed } from 'discord.js'; import got from 'got'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class CapePermissionsCommand extends BushCommand { private nameMap = { diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts index 19163d7..40f782d 100644 --- a/src/commands/moulberry-bush/giveawayPing.ts +++ b/src/commands/moulberry-bush/giveawayPing.ts @@ -1,5 +1,5 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class GiveawayPingCommand extends BushCommand { diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts index e37fa2e..c81c555 100644 --- a/src/commands/moulberry-bush/level.ts +++ b/src/commands/moulberry-bush/level.ts @@ -1,6 +1,6 @@ import { Message, User } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; import { Level } from '../../lib/models'; /* import canvas from 'canvas'; diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index 9aa41e0..2bcbb8d 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -1,7 +1,7 @@ import { Argument, Constants } from 'discord-akairo'; import { MessageEmbed, User } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushMessage } from '../../lib/extensions/BushMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; const rules = [ diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index 4c541e8..103e89b 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -1,6 +1,6 @@ -import { BushInhibitor } from '../../lib/extensions/BushInhibitor'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushInhibitor } from '../../lib/extensions/discord-akairo/BushInhibitor'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class GuildBlacklistInhibitor extends BushInhibitor { constructor() { diff --git a/src/inhibitors/blacklist/userBlacklist.ts b/src/inhibitors/blacklist/userBlacklist.ts index 73ad846..6772188 100644 --- a/src/inhibitors/blacklist/userBlacklist.ts +++ b/src/inhibitors/blacklist/userBlacklist.ts @@ -1,6 +1,6 @@ -import { BushInhibitor } from '../../lib/extensions/BushInhibitor'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushInhibitor } from '../../lib/extensions/discord-akairo/BushInhibitor'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class UserBlacklistInhibitor extends BushInhibitor { constructor() { diff --git a/src/inhibitors/commands/disabledCommand.ts b/src/inhibitors/commands/disabledCommand.ts index caf7bf7..5b47ce3 100644 --- a/src/inhibitors/commands/disabledCommand.ts +++ b/src/inhibitors/commands/disabledCommand.ts @@ -1,7 +1,7 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { BushInhibitor } from '../../lib/extensions/BushInhibitor'; -import { BushMessage } from '../../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage'; +import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; +import { BushInhibitor } from '../../lib/extensions/discord-akairo/BushInhibitor'; +import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class DisabledCommandInhibitor extends BushInhibitor { constructor() { diff --git a/src/inhibitors/noCache.ts b/src/inhibitors/noCache.ts index a8f52d7..fe2e522 100644 --- a/src/inhibitors/noCache.ts +++ b/src/inhibitors/noCache.ts @@ -1,6 +1,6 @@ -import { BushInhibitor } from '../lib/extensions/BushInhibitor'; -import { BushMessage } from '../lib/extensions/BushMessage'; -import { BushSlashMessage } from '../lib/extensions/BushSlashMessage'; +import { BushInhibitor } from '../lib/extensions/discord-akairo/BushInhibitor'; +import { BushSlashMessage } from '../lib/extensions/discord-akairo/BushSlashMessage'; +import { BushMessage } from '../lib/extensions/discord.js/BushMessage'; export default class noCacheInhibitor extends BushInhibitor { constructor() { diff --git a/src/lib/extensions/BushArgumentOptions.ts b/src/lib/extensions/BushArgumentOptions.ts deleted file mode 100644 index bbbc04b..0000000 --- a/src/lib/extensions/BushArgumentOptions.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { ArgumentOptions, ArgumentTypeCaster } from 'discord-akairo'; - -type BushArgumentType = - | 'string' - | 'lowercase' - | 'uppercase' - | 'charCodes' - | 'number' - | 'integer' - | 'bigint' - | 'emojint' - | 'url' - | 'date' - | 'color' - | 'user' - | 'users' - | 'member' - | 'members' - | 'relevant' - | 'relevants' - | 'channel' - | 'channels' - | 'textChannel' - | 'textChannels' - | 'voiceChannel' - | 'voiceChannels' - | 'categoryChannel' - | 'categoryChannels' - | 'newsChannel' - | 'newsChannels' - | 'storeChannel' - | 'storeChannels' - | 'role' - | 'roles' - | 'emoji' - | 'emojis' - | 'guild' - | 'guilds' - | 'message' - | 'guildMessage' - | 'relevantMessage' - | 'invite' - | 'userMention' - | 'memberMention' - | 'channelMention' - | 'roleMention' - | 'emojiMention' - | 'commandAlias' - | 'command' - | 'inhibitor' - | 'listener' - | 'duration' - | (string | string[])[] - | RegExp - | string; - -export interface BushArgumentOptions extends ArgumentOptions { - type?: BushArgumentType | ArgumentTypeCaster; -} diff --git a/src/lib/extensions/BushArgumentTypeCaster.ts b/src/lib/extensions/BushArgumentTypeCaster.ts deleted file mode 100644 index e000063..0000000 --- a/src/lib/extensions/BushArgumentTypeCaster.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { BushMessage } from './BushMessage'; - -export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => any; diff --git a/src/lib/extensions/BushClient.ts b/src/lib/extensions/BushClient.ts deleted file mode 100644 index 8dd8277..0000000 --- a/src/lib/extensions/BushClient.ts +++ /dev/null @@ -1,223 +0,0 @@ -import chalk from 'chalk'; -import { AkairoClient } from 'discord-akairo'; -import { - Guild, - Intents, - Message, - MessageEditOptions, - MessageOptions, - MessagePayload, - ReplyMessageOptions, - Snowflake, - UserResolvable -} from 'discord.js'; -import * as path from 'path'; -import { exit } from 'process'; -import readline from 'readline'; -import { Sequelize } from 'sequelize'; -import { durationTypeCaster } from '../../arguments/duration'; -import * as config from '../../config/options'; -import UpdateCacheTask from '../../tasks/updateCache'; -import * as Models from '../models'; -import AllowedMentions from '../utils/AllowedMentions'; -import { BushCache } from '../utils/BushCache'; -import { BushConstants } from '../utils/BushConstants'; -import { BushLogger } from '../utils/BushLogger'; -import { BushClientUtil } from './BushClientUtil'; -import { BushCommandHandler } from './BushCommandHandler'; -import { BushInhibitorHandler } from './BushInhinitorHandler'; -import { BushListenerHandler } from './BushListenerHandler'; -import { BushTaskHandler } from './BushTaskHandler'; - -export type BotConfig = typeof config; -export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions; -export type BushEditMessageType = string | MessageEditOptions | MessagePayload; -export type BushSendMessageType = string | MessagePayload | MessageOptions; - -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: false -}); - -export class BushClient extends AkairoClient { - public config: BotConfig; - public listenerHandler: BushListenerHandler; - public inhibitorHandler: BushInhibitorHandler; - public commandHandler: BushCommandHandler; - public taskHandler: BushTaskHandler; - public declare util: BushClientUtil; - public declare ownerID: Snowflake[]; - public db: Sequelize; - public logger: BushLogger; - public constants = BushConstants; - public cache = BushCache; - constructor(config: BotConfig) { - super( - { - ownerID: config.owners, - intents: Intents.ALL - }, - { - allowedMentions: AllowedMentions.users(), // No everyone or role mentions by default - intents: Intents.ALL - } - ); - - // Set token - this.token = config.credentials.token; - - // Set config - this.config = config; - - // Create listener handler - this.listenerHandler = new BushListenerHandler(this, { - directory: path.join(__dirname, '..', '..', 'listeners'), - automateCategories: true - }); - - // Create inhibitor handler - this.inhibitorHandler = new BushInhibitorHandler(this, { - directory: path.join(__dirname, '..', '..', 'inhibitors'), - automateCategories: true - }); - - // Create task handler - this.taskHandler = new BushTaskHandler(this, { - directory: path.join(__dirname, '..', '..', 'tasks') - }); - - // Create command handler - this.commandHandler = new BushCommandHandler(this, { - directory: path.join(__dirname, '..', '..', 'commands'), - prefix: async ({ guild }: { guild: Guild }) => { - if (this.config.dev) return 'dev '; - const row = await Models.Guild.findByPk(guild.id); - return (row?.prefix || this.config.prefix) as string; - }, - allowMention: true, - handleEdits: true, - commandUtil: true, - commandUtilLifetime: 300_000, - argumentDefaults: { - prompt: { - start: 'Placeholder argument prompt. If you see this please tell the devs.', - retry: 'Placeholder failed argument prompt. If you see this please tell the devs.', - modifyStart: (_: Message, str: string): string => `${str}\n\n Type \`cancel\` to cancel the command`, - modifyRetry: (_: Message, str: string): string => - `${str.replace('{error}', this.util.emojis.error)}\n\n Type \`cancel\` to cancel the command`, - timeout: 'You took too long the command has been cancelled', - ended: 'You exceeded the maximum amount of tries the command has been cancelled', - cancel: 'The command has been cancelled', - retries: 3, - time: 3e4 - }, - otherwise: '' - }, - - automateCategories: false, - autoRegisterSlashCommands: true - }); - - this.util = new BushClientUtil(this); - this.db = new Sequelize(this.config.dev ? 'bushbot-dev' : 'bushbot', this.config.db.username, this.config.db.password, { - dialect: 'postgres', - host: this.config.db.host, - port: this.config.db.port, - logging: this.config.logging.db ? (a) => this.logger.debug(a) : false - }); - this.logger = new BushLogger(this); - } - - get console(): BushLogger { - return this.logger; - } - - get consts(): typeof BushConstants { - return this.constants; - } - - // Initialize everything - private async _init(): Promise { - this.commandHandler.useListenerHandler(this.listenerHandler); - this.commandHandler.useInhibitorHandler(this.inhibitorHandler); - this.commandHandler.ignorePermissions = this.config.owners; - this.commandHandler.ignoreCooldown = this.config.owners.concat(this.cache.global.superUsers); - this.listenerHandler.setEmitters({ - client: this, - commandHandler: this.commandHandler, - listenerHandler: this.listenerHandler, - inhibitorHandler: this.inhibitorHandler, - taskHandler: this.taskHandler, - process, - stdin: rl, - gateway: this.ws - }); - this.commandHandler.resolver.addTypes({ - duration: durationTypeCaster - }); - // loads all the handlers - const loaders = { - commands: this.commandHandler, - listeners: this.listenerHandler, - inhibitors: this.inhibitorHandler, - tasks: this.taskHandler - }; - for (const loader of Object.keys(loaders)) { - try { - loaders[loader].loadAll(); - await this.logger.success('Startup', `Successfully loaded <<${loader}>>.`, false); - } catch (e) { - await this.logger.error('Startup', `Unable to load loader <<${loader}>> with error:\n${e?.stack}`, false); - } - } - await this.dbPreInit(); - await new UpdateCacheTask().init(this); - this.console.success('Startup', `Successfully created <>.`, false); - this.taskHandler.startAll(); - } - - public async dbPreInit(): Promise { - try { - await this.db.authenticate(); - Models.Global.initModel(this.db); - Models.Guild.initModel(this.db, this); - Models.ModLog.initModel(this.db); - Models.Ban.initModel(this.db); - Models.Mute.initModel(this.db); - Models.Level.initModel(this.db); - Models.StickyRole.initModel(this.db); - await this.db.sync({ alter: true }); // Sync all tables to fix everything if updated - await this.console.success('Startup', `Successfully connected to <>.`, false); - } catch (error) { - await this.console.error('Startup', `Failed to connect to <> with error:\n` + error?.stack, false); - } - } - - /** Starts the bot */ - public async start(): Promise { - try { - await this._init(); - await this.login(this.token); - } catch (e) { - await this.console.error('Start', chalk.red(e.stack), false); - exit(2); - } - } - - /** Logs out, terminates the connection to Discord, and destroys the client. */ - public destroy(relogin = false): void | Promise { - super.destroy(); - if (relogin) { - return this.login(this.token); - } - } - - public isOwner(user: UserResolvable): boolean { - return this.config.owners.includes(this.users.resolveID(user)); - } - public isSuperUser(user: UserResolvable): boolean { - const userID = this.users.resolveID(user); - return !!BushCache?.global?.superUsers?.includes(userID) || this.config.owners.includes(userID); - } -} diff --git a/src/lib/extensions/BushClientUtil.ts b/src/lib/extensions/BushClientUtil.ts deleted file mode 100644 index 680f6af..0000000 --- a/src/lib/extensions/BushClientUtil.ts +++ /dev/null @@ -1,536 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { exec } from 'child_process'; -import { ClientUtil } from 'discord-akairo'; -import { APIMessage } from 'discord-api-types'; -import { - ButtonInteraction, - ColorResolvable, - CommandInteraction, - Constants, - GuildMember, - Message, - MessageActionRow, - MessageButton, - MessageComponentInteraction, - MessageEditOptions, - MessageEmbed, - MessageOptions, - MessagePayload, - Snowflake, - TextChannel, - User, - Util, - WebhookEditMessageOptions -} from 'discord.js'; -import got from 'got'; -import { promisify } from 'util'; -import { Global } from '../models'; -import { BushCache } from '../utils/BushCache'; -import { BushClient } from './BushClient'; -import { BushMessage } from './BushMessage'; - -interface hastebinRes { - key: string; -} - -export interface uuidRes { - uuid: string; - username: string; - username_history?: { username: string }[] | null; - textures: { - custom: boolean; - slim: boolean; - skin: { - url: string; - data: string; - }; - raw: { - value: string; - signature: string; - }; - }; - created_at: string; -} - -interface bushColors { - default: '#1FD8F1'; - error: '#EF4947'; - warn: '#FEBA12'; - success: '#3BB681'; - info: '#3B78FF'; - red: '#ff0000'; - blue: '#0055ff'; - aqua: '#00bbff'; - purple: '#8400ff'; - blurple: '#5440cd'; - pink: '#ff00e6'; - green: '#00ff1e'; - darkGreen: '#008f11'; - gold: '#b59400'; - yellow: '#ffff00'; - white: '#ffffff'; - gray: '#a6a6a6'; - lightGray: '#cfcfcf'; - darkGray: '#7a7a7a'; - black: '#000000'; - orange: '#E86100'; -} -export class BushClientUtil extends ClientUtil { - /** The client of this ClientUtil */ - public declare client: BushClient; - /** The hastebin urls used to post to hastebin, attempts to post in order */ - public hasteURLs: string[] = [ - 'https://hst.sh', - 'https://hasteb.in', - 'https://hastebin.com', - 'https://mystb.in', - 'https://haste.clicksminuteper.net', - 'https://paste.pythondiscord.com', - 'https://haste.unbelievaboat.com', - 'https://haste.tyman.tech' - ]; - public paginateEmojis = { - beginning: '853667381335162910', - back: '853667410203770881', - stop: '853667471110570034', - forward: '853667492680564747', - end: '853667514915225640' - }; - - /** A simple promise exec method */ - private exec = promisify(exec); - - /** - * Creates this client util - * @param client The client to initialize with - */ - constructor(client: BushClient) { - super(client); - } - - /** - * Maps an array of user ids to user objects. - * @param ids The list of IDs to map - * @returns The list of users mapped - */ - public async mapIDs(ids: Snowflake[]): Promise { - return await Promise.all(ids.map((id) => this.client.users.fetch(id))); - } - - /** - * Capitalizes the first letter of the given text - * @param text The text to capitalize - * @returns The capitalized text - */ - public capitalize(text: string): string { - return text.charAt(0).toUpperCase() + text.slice(1); - } - - /** - * Runs a shell command and gives the output - * @param command The shell command to run - * @returns The stdout and stderr of the shell command - */ - public async shell(command: string): Promise<{ - stdout: string; - stderr: string; - }> { - return await this.exec(command); - } - - /** - * Posts text to hastebin - * @param content The text to post - * @returns The url of the posted text - */ - public async haste(content: string): Promise { - for (const url of this.hasteURLs) { - try { - const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json(); - return `${url}/${res.key}`; - } catch (e) { - this.client.console.error('Haste', `Unable to upload haste to ${url}`); - } - } - return 'Unable to post'; - } - - /** - * Resolves a user-provided string into a user object, if possible - * @param text The text to try and resolve - * @returns The user resolved or null - */ - public async resolveUserAsync(text: string): Promise { - const idReg = /\d{17,19}/; - const idMatch = text.match(idReg); - if (idMatch) { - try { - return await this.client.users.fetch(text as Snowflake); - } catch { - // pass - } - } - const mentionReg = /<@!?(?\d{17,19})>/; - const mentionMatch = text.match(mentionReg); - if (mentionMatch) { - try { - return await this.client.users.fetch(mentionMatch.groups.id as Snowflake); - } catch { - // pass - } - } - const user = this.client.users.cache.find((u) => u.username === text); - if (user) return user; - return null; - } - - /** - * Appends the correct ordinal to the given number - * @param n The number to append an ordinal to - * @returns The number with the ordinal - */ - public ordinal(n: number): string { - const s = ['th', 'st', 'nd', 'rd'], - v = n % 100; - return n + (s[(v - 20) % 10] || s[v] || s[0]); - } - - /** - * Chunks an array to the specified size - * @param arr The array to chunk - * @param perChunk The amount of items per chunk - * @returns The chunked array - */ - public chunk(arr: T[], perChunk: number): T[][] { - return arr.reduce((all, one, i) => { - const ch = Math.floor(i / perChunk); - all[ch] = [].concat(all[ch] || [], one); - return all; - }, []); - } - - /** Commonly Used Colors */ - public colors: bushColors = { - default: '#1FD8F1', - error: '#EF4947', - warn: '#FEBA12', - success: '#3BB681', - info: '#3B78FF', - red: '#ff0000', - blue: '#0055ff', - aqua: '#00bbff', - purple: '#8400ff', - blurple: '#5440cd', - pink: '#ff00e6', - green: '#00ff1e', - darkGreen: '#008f11', - gold: '#b59400', - yellow: '#ffff00', - white: '#ffffff', - gray: '#a6a6a6', - lightGray: '#cfcfcf', - darkGray: '#7a7a7a', - black: '#000000', - orange: '#E86100' - }; - - /** Commonly Used Emojis */ - public emojis = { - success: '<:checkmark:837109864101707807>', - warn: '<:warn:848726900876247050>', - error: '<:error:837123021016924261>', - successFull: '<:checkmark_full:850118767576088646>', - warnFull: '<:warn_full:850118767391539312>', - errorFull: '<:error_full:850118767295201350>', - mad: '<:mad:783046135392239626>', - join: '<:join:850198029809614858>', - leave: '<:leave:850198048205307919>', - loading: '' - }; - - /** - * A simple utility to create and embed with the needed style for the bot - */ - public createEmbed(color?: ColorResolvable, author?: User | GuildMember): MessageEmbed { - if (author instanceof GuildMember) { - author = author.user; // Convert to User if GuildMember - } - let embed = new MessageEmbed().setTimestamp(); - if (author) - embed = embed.setAuthor( - author.username, - author.displayAvatarURL({ dynamic: true }), - `https://discord.com/users/${author.id}` - ); - if (color) embed = embed.setColor(color); - return embed; - } - - public async mcUUID(username: string): Promise { - const apiRes = (await got.get(`https://api.ashcon.app/mojang/v2/user/${username}`).json()) as uuidRes; - return apiRes.uuid.replace(/-/g, ''); - } - - /** Paginates an array of embeds using buttons. */ - public async buttonPaginate( - message: BushMessage, - embeds: MessageEmbed[], - text: string | null = null, - deleteOnExit?: boolean - ): Promise { - if (deleteOnExit === undefined) deleteOnExit = true; - - embeds.forEach((_e, i) => { - embeds[i] = embeds[i].setFooter(`Page ${i + 1}/${embeds.length}`); - }); - - const style = Constants.MessageButtonStyles.PRIMARY; - let curPage = 0; - if (typeof embeds !== 'object') throw 'embeds must be an object'; - const msg: Message = await message.util.reply({ - content: text, - embeds: [embeds[curPage]], - components: [getPaginationRow()] - }); - const filter = (interaction: ButtonInteraction) => - interaction.customID.startsWith('paginate_') && interaction.message == msg; - const collector = msg.createMessageComponentInteractionCollector({ filter, time: 300000 }); - collector.on('collect', async (interaction: MessageComponentInteraction) => { - if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { - switch (interaction.customID) { - case 'paginate_beginning': { - curPage = 0; - await edit(interaction); - break; - } - case 'paginate_back': { - curPage--; - await edit(interaction); - break; - } - case 'paginate_stop': { - if (deleteOnExit) { - await interaction.deferUpdate().catch(() => undefined); - if (msg.deletable && !msg.deleted) { - await msg.delete(); - } - } else { - await interaction - ?.update({ content: `${text ? text + '\n' : ''}Command closed by user.`, embeds: [], components: [] }) - .catch(() => undefined); - } - return; - } - case 'paginate_next': { - curPage++; - await edit(interaction); - break; - } - case 'paginate_end': { - curPage = embeds.length - 1; - await edit(interaction); - break; - } - } - } else { - return await interaction?.deferUpdate().catch(() => undefined); - } - }); - - collector.on('end', async () => { - await msg.edit({ content: text, embeds: [embeds[curPage]], components: [getPaginationRow(true)] }).catch(() => undefined); - }); - - async function edit(interaction: MessageComponentInteraction): Promise { - return await interaction - ?.update({ content: text, embeds: [embeds[curPage]], components: [getPaginationRow()] }) - .catch(() => undefined); - } - const paginateEmojis = this.paginateEmojis; - function getPaginationRow(disableAll = false): MessageActionRow { - return new MessageActionRow().addComponents( - new MessageButton({ - style, - customID: 'paginate_beginning', - emoji: paginateEmojis.beginning, - disabled: disableAll || curPage == 0 - }), - new MessageButton({ - style, - customID: 'paginate_back', - emoji: paginateEmojis.back, - disabled: disableAll || curPage == 0 - }), - new MessageButton({ style, customID: 'paginate_stop', emoji: paginateEmojis.stop, disabled: disableAll }), - new MessageButton({ - style, - customID: 'paginate_next', - emoji: paginateEmojis.forward, - disabled: disableAll || curPage == embeds.length - 1 - }), - new MessageButton({ - style, - customID: 'paginate_end', - emoji: paginateEmojis.end, - disabled: disableAll || curPage == embeds.length - 1 - }) - ); - } - } - - /** Sends a message with a button for the user to delete it. */ - public async sendWithDeleteButton(message: BushMessage, options: MessageOptions): Promise { - updateOptions(); - const msg = await message.util.reply(options as MessageOptions & { split?: false }); - const filter = (interaction: ButtonInteraction) => interaction.customID == 'paginate__stop' && interaction.message == msg; - const collector = msg.createMessageComponentInteractionCollector({ filter, time: 300000 }); - collector.on('collect', async (interaction: MessageComponentInteraction) => { - if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { - await interaction.deferUpdate().catch(() => undefined); - if (msg.deletable && !msg.deleted) { - await msg.delete(); - } - return; - } else { - return await interaction?.deferUpdate().catch(() => undefined); - } - }); - - collector.on('end', async () => { - updateOptions(true, true); - await msg.edit(options as MessageEditOptions).catch(() => undefined); - }); - - const paginateEmojis = this.paginateEmojis; - function updateOptions(edit?: boolean, disable?: boolean) { - if (edit == undefined) edit = false; - if (disable == undefined) disable = false; - options.components = [ - new MessageActionRow().addComponents( - new MessageButton({ - style: Constants.MessageButtonStyles.PRIMARY, - customID: 'paginate__stop', - emoji: paginateEmojis.stop, - disabled: disable - }) - ) - ]; - if (edit) { - options.reply = undefined; - } - } - } - - /** - * Surrounds text in a code block with the specified language and puts it in a hastebin if its too long. - * - * * Embed Description Limit = 2048 characters - * * Embed Field Limit = 1024 characters - */ - public async codeblock(code: string, length: number, language: 'ts' | 'js' | 'sh' | 'json' | '' = ''): Promise { - let hasteOut = ''; - const tildes = '```'; - const formattingLength = 2 * tildes.length + language.length + 2 * '\n'.length; - if (code.length + formattingLength > length) hasteOut = 'Too large to display. Hastebin: ' + (await this.haste(code)); - - const code2 = code.length > length ? code.substring(0, length - (hasteOut.length + '\n'.length + formattingLength)) : code; - return ( - tildes + language + '\n' + Util.cleanCodeBlockContent(code2) + '\n' + tildes + (hasteOut.length ? '\n' + hasteOut : '') - ); - } - - public async slashRespond( - interaction: CommandInteraction, - responseOptions: string | MessagePayload | WebhookEditMessageOptions - ): Promise { - let newResponseOptions: string | MessagePayload | WebhookEditMessageOptions = {}; - if (typeof responseOptions === 'string') { - newResponseOptions.content = responseOptions; - } else { - newResponseOptions = responseOptions; - } - if (interaction.replied || interaction.deferred) { - //@ts-expect-error: stop being dumb - delete newResponseOptions.ephemeral; // Cannot change a preexisting message to be ephemeral - return (await interaction.editReply(newResponseOptions)) as Message | APIMessage; - } else { - await interaction.reply(newResponseOptions); - return await interaction.fetchReply().catch(() => undefined); - } - } - - /** Gets the channel configs as a TextChannel */ - public async getConfigChannel(channel: 'log' | 'error' | 'dm'): Promise { - return (await this.client.channels.fetch(this.client.config.channels[channel])) as TextChannel; - } - - /** - * Takes an array and combines the elements using the supplied conjunction. - * - * @param {string[]} array The array to combine. - * @param {string} conjunction The conjunction to use. - * @param {string} ifEmpty What to return if the array is empty. - * @returns The combined elements or `ifEmpty` - * - * @example - * const permissions = oxford(['ADMINISTRATOR', 'SEND_MESSAGES', 'MANAGE_MESSAGES'], 'and', 'none'); - * console.log(permissions); // ADMINISTRATOR, SEND_MESSAGES and MANAGE_MESSAGES - */ - public oxford(array: string[], conjunction: string, ifEmpty: string): string { - const l = array.length; - if (!l) return ifEmpty; - if (l < 2) return array[0]; - if (l < 3) return array.join(` ${conjunction} `); - array = array.slice(); - array[l - 1] = `${conjunction} ${array[l - 1]}`; - return array.join(', '); - } - - public async insertOrRemoveFromGlobal( - action: 'add' | 'remove', - key: keyof typeof BushCache['global'], - value: any - ): Promise { - const environment = this.client.config.dev ? 'development' : 'production'; - const row = await Global.findByPk(environment); - const oldValue: any[] = row[key]; - let newValue: any[]; - if (action === 'add') { - if (!oldValue.includes(action)) oldValue.push(value); - newValue = oldValue; - } else { - newValue = oldValue.filter((ae) => ae !== value); - } - row[key] = newValue; - this.client.cache.global[key] = newValue; - return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e)); - } - - /** - * Surrounds a string to the begging an end of each element in an array. - * - * @param {string[]} array The array you want to surround. - * @param {string} surroundChar1 The character placed in the beginning of the element (or end if surroundChar2 isn't supplied). - * @param {string} [surroundChar2=surroundChar1] The character placed in the end of the element. - * @returns {string[]} - */ - public surroundArray(array: string[], surroundChar1: string, surroundChar2?: string): string[] { - const newArray = []; - array.forEach((a) => { - newArray.push(`${surroundChar1}${a}${surroundChar2 || surroundChar1}`); - }); - return newArray; - } - - // public createModLogEntry( - // user: User | Snowflake, - // guild: Guild | Snowflake, - // reason?: string, - // type?: ModLogType, - // duration?: number, - // moderator: User | Snowflake - // ): ModLog { - - // } -} diff --git a/src/lib/extensions/BushCommand.ts b/src/lib/extensions/BushCommand.ts deleted file mode 100644 index f22a628..0000000 --- a/src/lib/extensions/BushCommand.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* eslint-disable @typescript-eslint/explicit-