From 0caccda67d97dd74405aa4ece5d3f07e7c7dfc66 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 26 May 2021 21:36:50 -0400 Subject: some rebranding --- src/bot.ts | 4 +- src/commands/admin/prefix.ts | 70 ---------- src/commands/dev/eval.ts | 138 ++++++++++++++++++++ src/commands/dev/reload.ts | 44 +++++++ src/commands/dev/setlevel.ts | 91 +++++++++++++ src/commands/info/botinfo.ts | 4 +- src/commands/info/help.ts | 10 +- src/commands/info/ping.ts | 4 +- src/commands/info/pronouns.ts | 4 +- src/commands/moderation/ban.ts | 4 +- src/commands/moderation/kick.ts | 4 +- src/commands/moderation/modlog.ts | 4 +- src/commands/moderation/role.ts | 4 +- src/commands/moderation/warn.ts | 4 +- src/commands/moulberry-bush/capeperms.ts | 4 +- src/commands/moulberry-bush/giveawayping.ts | 4 +- src/commands/moulberry-bush/level.ts | 5 +- src/commands/moulberry-bush/rule.ts | 4 +- src/commands/owner/eval.ts | 138 -------------------- src/commands/owner/reload.ts | 43 ------- src/commands/owner/setlevel.ts | 90 ------------- src/commands/server-config/prefix.ts | 71 +++++++++++ src/inhibitors/blacklist/BlacklistInhibitor.ts | 4 +- src/lib/extensions/BotClient.ts | 169 ------------------------- src/lib/extensions/BotCommand.ts | 20 --- src/lib/extensions/BotInhibitor.ts | 6 - src/lib/extensions/BotListener.ts | 6 - src/lib/extensions/BotTask.ts | 6 - src/lib/extensions/BushClient.ts | 169 +++++++++++++++++++++++++ src/lib/extensions/BushCommand.ts | 20 +++ src/lib/extensions/BushInhibitor.ts | 6 + src/lib/extensions/BushListener.ts | 6 + src/lib/extensions/BushTask.ts | 6 + src/lib/extensions/Util.ts | 24 ++-- src/lib/models/Guild.ts | 4 +- src/lib/utils/Logger.ts | 6 +- src/listeners/client/ready.ts | 4 +- src/listeners/client/syncslashcommands.ts | 4 +- src/listeners/commands/commandblocked.ts | 4 +- src/listeners/commands/commandstarted.ts | 8 +- src/listeners/commands/error.ts | 8 +- src/listeners/commands/slashError.ts | 8 +- src/listeners/guild/syncunban.ts | 4 +- src/listeners/message/levels.ts | 4 +- src/tasks/Unban.ts | 4 +- 45 files changed, 626 insertions(+), 622 deletions(-) delete mode 100644 src/commands/admin/prefix.ts create mode 100644 src/commands/dev/eval.ts create mode 100644 src/commands/dev/reload.ts create mode 100644 src/commands/dev/setlevel.ts delete mode 100644 src/commands/owner/eval.ts delete mode 100644 src/commands/owner/reload.ts delete mode 100644 src/commands/owner/setlevel.ts create mode 100644 src/commands/server-config/prefix.ts delete mode 100644 src/lib/extensions/BotClient.ts delete mode 100644 src/lib/extensions/BotCommand.ts delete mode 100644 src/lib/extensions/BotInhibitor.ts delete mode 100644 src/lib/extensions/BotListener.ts delete mode 100644 src/lib/extensions/BotTask.ts create mode 100644 src/lib/extensions/BushClient.ts create mode 100644 src/lib/extensions/BushCommand.ts create mode 100644 src/lib/extensions/BushInhibitor.ts create mode 100644 src/lib/extensions/BushListener.ts create mode 100644 src/lib/extensions/BushTask.ts diff --git a/src/bot.ts b/src/bot.ts index a7b555c..ee7ce92 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,5 @@ -import { BotClient } from './lib/extensions/BotClient'; +import { BushClient } from './lib/extensions/BushClient'; import * as config from './config/options'; -const client: BotClient = new BotClient(config); +const client: BushClient = new BushClient(config); client.start(); diff --git a/src/commands/admin/prefix.ts b/src/commands/admin/prefix.ts deleted file mode 100644 index 112f6b8..0000000 --- a/src/commands/admin/prefix.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { CommandInteraction, Message, Guild as DiscordGuild } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { SlashCommandOption } from '../../lib/extensions/Util'; -import { Guild } from '../../lib/models'; - -export default class PrefixCommand extends BotCommand { - constructor() { - super('prefix', { - aliases: ['prefix'], - args: [ - { - id: 'prefix' - } - ], - userPermissions: ['MANAGE_GUILD'], - description: { - content: - 'Set the prefix of the current server (resets to default if prefix is not given)', - usage: 'prefix [prefix]', - examples: ['prefix', 'prefix +'] - }, - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.STRING, - name: 'prefix', - description: 'The prefix to set for this server', - required: false - } - ] - }); - } - - async changePrefix(guild: DiscordGuild, prefix?: string): Promise { - if (prefix) { - const row = await Guild.findByPk(guild.id); - row.prefix = prefix; - await row.save(); - } else { - const row = await Guild.findByPk(guild.id); - row.prefix = this.client.config.prefix; - await row.save(); - } - } - - async exec(message: Message, { prefix }: { prefix?: string }): Promise { - await this.changePrefix(message.guild, prefix); - if (prefix) { - await message.util.send(`Sucessfully set prefix to \`${prefix}\``); - } else { - await message.util.send( - `Sucessfully reset prefix to \`${this.client.config.prefix}\`` - ); - } - } - - async execSlash( - message: CommandInteraction, - { prefix }: { prefix?: SlashCommandOption } - ): Promise { - await this.changePrefix(message.guild, prefix?.value); - if (prefix) { - await message.reply(`Sucessfully set prefix to \`${prefix.value}\``); - } else { - await message.reply( - `Sucessfully reset prefix to \`${this.client.config.prefix}\`` - ); - } - } -} diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts new file mode 100644 index 0000000..83e63f6 --- /dev/null +++ b/src/commands/dev/eval.ts @@ -0,0 +1,138 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { MessageEmbed, Message } from 'discord.js'; +import { inspect, promisify } from 'util'; +import { exec } from 'child_process'; + +const clean = (text) => { + if (typeof text === 'string') + return text + .replace(/`/g, '`' + String.fromCharCode(8203)) + .replace(/@/g, '@' + String.fromCharCode(8203)); + else return text; +}; + +export default class EvalCommand extends BushCommand { + public constructor() { + super('eval', { + aliases: ['eval', 'ev'], + category: 'dev', + description: { + content: 'Use the command to eval stuff in the bot.', + usage: 'eval [--silent] [--depth #]', + examples: ['eval message.guild.name', 'eval this.client.ownerID'] + }, + args: [ + { + id: 'depth', + match: 'option', + type: 'number', + flag: '--depth', + default: 0 + }, + { + id: 'silent', + match: 'flag', + flag: '--silent' + }, + { + id: 'code', + match: 'rest', + type: 'string', + prompt: { + start: 'What would you like to eval?', + retry: 'Invalid code to eval. What would you like to eval?' + } + } + ], + ownerOnly: true, + clientPermissions: ['EMBED_LINKS'] + }); + } + + public async exec( + message: Message, + { depth, code, silent }: { depth: number; code: string; silent: boolean } + ): Promise { + const embed: MessageEmbed = new MessageEmbed(); + + try { + let output; + const me = message.member, + member = message.member, + bot = this.client, + guild = message.guild, + channel = message.channel, + config = this.client.config, + sh = promisify(exec), + models = this.client.db.models, + got = require('got'); // eslint-disable-line @typescript-eslint/no-var-requires + output = eval(code); + output = await output; + if (typeof output !== 'string') output = inspect(output, { depth }); + output = output.replace( + new RegExp(this.client.token, 'g'), + '[token omitted]' + ); + output = clean(output); + embed + .setTitle('✅ Evaled code successfully') + .addField( + '📥 Input', + code.length > 1012 + ? 'Too large to display. Hastebin: ' + + (await this.client.util.haste(code)) + : '```js\n' + code + '```' + ) + .addField( + '📤 Output', + output.length > 1012 + ? 'Too large to display. Hastebin: ' + + (await this.client.util.haste(output)) + : '```js\n' + output + '```' + ) + .setColor('#66FF00') + .setFooter( + message.author.username, + message.author.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + } catch (e) { + embed + .setTitle('❌ Code was not able to be evaled') + .addField( + '📥 Input', + code.length > 1012 + ? 'Too large to display. Hastebin: ' + + (await this.client.util.haste(code)) + : '```js\n' + code + '```' + ) + .addField( + '📤 Output', + e.length > 1012 + ? 'Too large to display. Hastebin: ' + + (await this.client.util.haste(e)) + : '```js\n' + + e + + '```Full stack:' + + (await this.client.util.haste(e.stack)) + ) + .setColor('#FF0000') + .setFooter( + message.author.username, + message.author.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + } + if (!silent) { + await message.util.send(embed); + } else { + try { + await message.author.send(embed); + await message.react(''); + } catch (e) { + await message.react('❌'); + } + } + } +} diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts new file mode 100644 index 0000000..64e5745 --- /dev/null +++ b/src/commands/dev/reload.ts @@ -0,0 +1,44 @@ +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { stripIndent } from 'common-tags'; +import { Message } from 'discord.js'; +import { CommandInteraction } from 'discord.js'; + +export default class ReloadCommand extends BushCommand { + constructor() { + super('reload', { + aliases: ['reload'], + category: 'dev', + description: { + content: 'Reloads the bot', + usage: 'reload', + examples: ['reload'] + }, + ownerOnly: true, + typing: true + }); + } + + private async getResponse(): Promise { + try { + await this.client.util.shell('yarn rimraf dist/'); + await this.client.util.shell('yarn tsc'); + this.client.commandHandler.reloadAll(); + this.client.listenerHandler.reloadAll(); + this.client.inhibitorHandler.reloadAll(); + return '🔁 Successfully reloaded!'; + } catch (e) { + return stripIndent` + An error occured while reloading: + ${await this.client.util.haste(e.stack)} + `; + } + } + + public async exec(message: Message): Promise { + await message.util.send(await this.getResponse()); + } + + public async execSlash(message: CommandInteraction): Promise { + await message.reply(await this.getResponse()); + } +} diff --git a/src/commands/dev/setlevel.ts b/src/commands/dev/setlevel.ts new file mode 100644 index 0000000..d1701c5 --- /dev/null +++ b/src/commands/dev/setlevel.ts @@ -0,0 +1,91 @@ +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { CommandInteraction } from 'discord.js'; +import { User } from 'discord.js'; +import { Message } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { SlashCommandOption } from '../../lib/extensions/Util'; +import { Level } from '../../lib/models'; +import AllowedMentions from '../../lib/utils/AllowedMentions'; + +export default class SetLevelCommand extends BushCommand { + constructor() { + super('setlevel', { + aliases: ['setlevel'], + category: 'dev', + description: { + content: 'Sets the level of a user', + usage: 'setlevel ', + examples: ['setlevel @Moulberry 69'] //nice + }, + args: [ + { + id: 'user', + type: 'user', + prompt: { + start: 'What user would you like to change the level of?', + retry: + 'Invalid user. What user would you like to change the level of?' + } + }, + { + id: 'level', + type: 'number', + prompt: { + start: 'What level would you like to set?', + retry: 'Invalid user. What level would you like to set?' + } + } + ], + ownerOnly: true, + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.USER, + name: 'user', + description: 'The user to change the level of', + required: true + }, + { + type: ApplicationCommandOptionType.INTEGER, + name: 'level', + description: 'The level to set the user to', + required: true + } + ] + }); + } + + private async setLevel(user: User, level: number): Promise { + const [levelEntry] = await Level.findOrBuild({ + where: { + id: user.id + }, + defaults: { + id: user.id + } + }); + levelEntry.xp = Level.convertLevelToXp(level); + await levelEntry.save(); + return `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`; + } + + async exec( + message: Message, + { user, level }: { user: User; level: number } + ): Promise { + await message.util.send(await this.setLevel(user, level), { + allowedMentions: AllowedMentions.none() + }); + } + + async execSlash( + message: CommandInteraction, + { + user, + level + }: { user: SlashCommandOption; level: SlashCommandOption } + ): Promise { + await message.reply(await this.setLevel(user.user, level.value), { + allowedMentions: AllowedMentions.none() + }); + } +} diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botinfo.ts index 8f5f055..e6a4fbb 100644 --- a/src/commands/info/botinfo.ts +++ b/src/commands/info/botinfo.ts @@ -1,8 +1,8 @@ import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { duration } from 'moment'; -export default class BotInfoCommand extends BotCommand { +export default class BotInfoCommand extends BushCommand { constructor() { super('botinfo', { aliases: ['botinfo'], diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 116669c..30c2a21 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,11 +1,11 @@ import { Message, MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { stripIndent } from 'common-tags'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; import { SlashCommandOption } from '../../lib/extensions/Util'; -export default class HelpCommand extends BotCommand { +export default class HelpCommand extends BushCommand { constructor() { super('help', { aliases: ['help'], @@ -32,7 +32,7 @@ export default class HelpCommand extends BotCommand { }); } - private generateEmbed(command?: BotCommand): MessageEmbed { + private generateEmbed(command?: BushCommand): MessageEmbed { const prefix = this.handler.prefix; if (!command) { const embed = new MessageEmbed() @@ -85,7 +85,7 @@ export default class HelpCommand extends BotCommand { public async exec( message: Message, - { command }: { command: BotCommand } + { command }: { command: BushCommand } ): Promise { await message.util.send(this.generateEmbed(command)); } @@ -97,7 +97,7 @@ export default class HelpCommand extends BotCommand { if (command) { await message.reply( this.generateEmbed( - this.handler.findCommand(command.value) as BotCommand + this.handler.findCommand(command.value) as BushCommand ) ); } else { diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index e51867f..62b8e60 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,9 +1,9 @@ import { CommandInteraction } from 'discord.js'; import { Message } from 'discord.js'; import { MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; -export default class PingCommand extends BotCommand { +export default class PingCommand extends BushCommand { constructor() { super('ping', { aliases: ['ping'], diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 97cca34..f30a981 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,4 +1,4 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { User, Message, MessageEmbed } from 'discord.js'; import got, { HTTPError } from 'got'; import { CommandInteraction } from 'discord.js'; @@ -30,7 +30,7 @@ export const pronounMapping = { }; export type pronounsType = keyof typeof pronounMapping; -export default class PronounsCommand extends BotCommand { +export default class PronounsCommand extends BushCommand { constructor() { super('pronouns', { aliases: ['pronouns', 'pronoun'], diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 556dd6b..1c3b074 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,6 +1,6 @@ import { User } from 'discord.js'; import { Guild } from '../../lib/models'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Ban, Modlog, ModlogType } from '../../lib/models'; import moment from 'moment'; import { Message } from 'discord.js'; @@ -18,7 +18,7 @@ const durationAliases: Record = { const durationRegex = /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g; -export default class PrefixCommand extends BotCommand { +export default class PrefixCommand extends BushCommand { constructor() { super('ban', { aliases: ['ban'], diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index f31047e..c21352f 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,10 +1,10 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Guild, Modlog, ModlogType } from '../../lib/models'; import { GuildMember, Message } from 'discord.js'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; -export default class KickCommand extends BotCommand { +export default class KickCommand extends BushCommand { constructor() { super('kick', { aliases: ['kick'], diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 320c6b4..b7923ca 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,4 +1,4 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Message } from 'discord.js'; import { Modlog } from '../../lib/models'; import { MessageEmbed } from 'discord.js'; @@ -6,7 +6,7 @@ import moment from 'moment'; import { stripIndent } from 'common-tags'; import { Argument } from 'discord-akairo'; -export default class ModlogCommand extends BotCommand { +export default class ModlogCommand extends BushCommand { constructor() { super('modlog', { aliases: ['modlog', 'modlogs'], diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 2a67e5b..29339a3 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import AllowedMentions from '../../lib/utils/AllowedMentions'; import { Message, Role, GuildMember } from 'discord.js'; import { ApplicationCommandOptionType } from 'discord-api-types'; -export default class RoleCommand extends BotCommand { +export default class RoleCommand extends BushCommand { private roleWhitelist: Record = { 'Partner': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'], 'Suggester': [ diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 41e0032..e8b1401 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,8 +1,8 @@ import { GuildMember, Message } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Guild, Modlog, ModlogType } from '../../lib/models'; -export default class WarnCommand extends BotCommand { +export default class WarnCommand extends BushCommand { public constructor() { super('warn', { aliases: ['warn'], diff --git a/src/commands/moulberry-bush/capeperms.ts b/src/commands/moulberry-bush/capeperms.ts index 5b3dc10..9832083 100644 --- a/src/commands/moulberry-bush/capeperms.ts +++ b/src/commands/moulberry-bush/capeperms.ts @@ -3,7 +3,7 @@ import { MessageEmbed } from 'discord.js'; import { CommandInteraction } from 'discord.js'; import { Message } from 'discord.js'; import got from 'got'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { SlashCommandOption } from '../../lib/extensions/Util'; interface Capeperms { @@ -15,7 +15,7 @@ interface User { perms: string[]; } -export default class CapePermsCommand extends BotCommand { +export default class CapePermsCommand extends BushCommand { private nameMap = { patreon1: 'Patreon Tier 1', patreon2: 'Patreon Tier 2', diff --git a/src/commands/moulberry-bush/giveawayping.ts b/src/commands/moulberry-bush/giveawayping.ts index d99f475..e6fdd9a 100644 --- a/src/commands/moulberry-bush/giveawayping.ts +++ b/src/commands/moulberry-bush/giveawayping.ts @@ -1,10 +1,10 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import AllowedMentions from '../../lib/utils/AllowedMentions'; import { Message, WebhookClient } from 'discord.js'; import { TextChannel } from 'discord.js'; import { NewsChannel } from 'discord.js'; -export default class GiveawayPingCommand extends BotCommand { +export default class GiveawayPingCommand extends BushCommand { constructor() { super('giveawayping', { aliases: ['giveawayping', 'giveawaypong'], diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts index ab08361..decac8a 100644 --- a/src/commands/moulberry-bush/level.ts +++ b/src/commands/moulberry-bush/level.ts @@ -3,13 +3,14 @@ import { Message } from 'discord.js'; import { CommandInteractionOption } from 'discord.js'; import { CommandInteraction } from 'discord.js'; import { User } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Level } from '../../lib/models'; -export default class LevelCommand extends BotCommand { +export default class LevelCommand extends BushCommand { constructor() { super('level', { aliases: ['level', 'rank'], + category: "Moulberry's Bush", description: { content: 'Shows the level of a user', usage: 'level [user]', diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index bd8b08a..69dcb6e 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -1,11 +1,11 @@ import { Argument } from 'discord-akairo'; import { Message, MessageEmbed, User } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; import { SlashCommandOption } from '../../lib/extensions/Util'; -export default class RuleCommand extends BotCommand { +export default class RuleCommand extends BushCommand { private rules = [ { title: "Follow Discord's TOS", diff --git a/src/commands/owner/eval.ts b/src/commands/owner/eval.ts deleted file mode 100644 index a63b977..0000000 --- a/src/commands/owner/eval.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { MessageEmbed, Message } from 'discord.js'; -import { inspect, promisify } from 'util'; -import { exec } from 'child_process'; - -const clean = (text) => { - if (typeof text === 'string') - return text - .replace(/`/g, '`' + String.fromCharCode(8203)) - .replace(/@/g, '@' + String.fromCharCode(8203)); - else return text; -}; - -export default class EvalCommand extends BotCommand { - public constructor() { - super('eval', { - aliases: ['eval', 'ev'], - category: 'dev', - description: { - content: 'Use the command to eval stuff in the bot.', - usage: 'eval [--silent] [--depth #]', - examples: ['eval message.guild.name', 'eval this.client.ownerID'] - }, - args: [ - { - id: 'depth', - match: 'option', - type: 'number', - flag: '--depth', - default: 0 - }, - { - id: 'silent', - match: 'flag', - flag: '--silent' - }, - { - id: 'code', - match: 'rest', - type: 'string', - prompt: { - start: 'What would you like to eval?', - retry: 'Invalid code to eval. What would you like to eval?' - } - } - ], - ownerOnly: true, - clientPermissions: ['EMBED_LINKS'] - }); - } - - public async exec( - message: Message, - { depth, code, silent }: { depth: number; code: string; silent: boolean } - ): Promise { - const embed: MessageEmbed = new MessageEmbed(); - - try { - let output; - const me = message.member, - member = message.member, - bot = this.client, - guild = message.guild, - channel = message.channel, - config = this.client.config, - sh = promisify(exec), - models = this.client.db.models, - got = require('got'); // eslint-disable-line @typescript-eslint/no-var-requires - output = eval(code); - output = await output; - if (typeof output !== 'string') output = inspect(output, { depth }); - output = output.replace( - new RegExp(this.client.token, 'g'), - '[token omitted]' - ); - output = clean(output); - embed - .setTitle('✅ Evaled code successfully') - .addField( - '📥 Input', - code.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(code)) - : '```js\n' + code + '```' - ) - .addField( - '📤 Output', - output.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(output)) - : '```js\n' + output + '```' - ) - .setColor('#66FF00') - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - } catch (e) { - embed - .setTitle('❌ Code was not able to be evaled') - .addField( - '📥 Input', - code.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(code)) - : '```js\n' + code + '```' - ) - .addField( - '📤 Output', - e.length > 1012 - ? 'Too large to display. Hastebin: ' + - (await this.client.util.haste(e)) - : '```js\n' + - e + - '```Full stack:' + - (await this.client.util.haste(e.stack)) - ) - .setColor('#FF0000') - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - } - if (!silent) { - await message.util.send(embed); - } else { - try { - await message.author.send(embed); - await message.react(''); - } catch (e) { - await message.react('❌'); - } - } - } -} diff --git a/src/commands/owner/reload.ts b/src/commands/owner/reload.ts deleted file mode 100644 index 0330b27..0000000 --- a/src/commands/owner/reload.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { stripIndent } from 'common-tags'; -import { Message } from 'discord.js'; -import { CommandInteraction } from 'discord.js'; - -export default class ReloadCommand extends BotCommand { - constructor() { - super('reload', { - aliases: ['reload'], - description: { - content: 'Reloads the bot', - usage: 'reload', - examples: ['reload'] - }, - ownerOnly: true, - typing: true - }); - } - - private async getResponse(): Promise { - try { - await this.client.util.shell('yarn rimraf dist/'); - await this.client.util.shell('yarn tsc'); - this.client.commandHandler.reloadAll(); - this.client.listenerHandler.reloadAll(); - this.client.inhibitorHandler.reloadAll(); - return '🔁 Successfully reloaded!'; - } catch (e) { - return stripIndent` - An error occured while reloading: - ${await this.client.util.haste(e.stack)} - `; - } - } - - public async exec(message: Message): Promise { - await message.util.send(await this.getResponse()); - } - - public async execSlash(message: CommandInteraction): Promise { - await message.reply(await this.getResponse()); - } -} diff --git a/src/commands/owner/setlevel.ts b/src/commands/owner/setlevel.ts deleted file mode 100644 index 6987385..0000000 --- a/src/commands/owner/setlevel.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { CommandInteraction } from 'discord.js'; -import { User } from 'discord.js'; -import { Message } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { SlashCommandOption } from '../../lib/extensions/Util'; -import { Level } from '../../lib/models'; -import AllowedMentions from '../../lib/utils/AllowedMentions'; - -export default class SetLevelCommand extends BotCommand { - constructor() { - super('setlevel', { - aliases: ['setlevel'], - description: { - content: 'Sets the level of a user', - usage: 'setlevel ', - examples: ['setlevel @Moulberry 69'] - }, - args: [ - { - id: 'user', - type: 'user', - prompt: { - start: 'What user would you like to change the level of?', - retry: - 'Invalid user. What user would you like to change the level of?' - } - }, - { - id: 'level', - type: 'number', - prompt: { - start: 'What level would you like to set?', - retry: 'Invalid user. What level would you like to set?' - } - } - ], - ownerOnly: true, - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.USER, - name: 'user', - description: 'The user to change the level of', - required: true - }, - { - type: ApplicationCommandOptionType.INTEGER, - name: 'level', - description: 'The level to set the user to', - required: true - } - ] - }); - } - - private async setLevel(user: User, level: number): Promise { - const [levelEntry] = await Level.findOrBuild({ - where: { - id: user.id - }, - defaults: { - id: user.id - } - }); - levelEntry.xp = Level.convertLevelToXp(level); - await levelEntry.save(); - return `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`; - } - - async exec( - message: Message, - { user, level }: { user: User; level: number } - ): Promise { - await message.util.send(await this.setLevel(user, level), { - allowedMentions: AllowedMentions.none() - }); - } - - async execSlash( - message: CommandInteraction, - { - user, - level - }: { user: SlashCommandOption; level: SlashCommandOption } - ): Promise { - await message.reply(await this.setLevel(user.user, level.value), { - allowedMentions: AllowedMentions.none() - }); - } -} diff --git a/src/commands/server-config/prefix.ts b/src/commands/server-config/prefix.ts new file mode 100644 index 0000000..ac85922 --- /dev/null +++ b/src/commands/server-config/prefix.ts @@ -0,0 +1,71 @@ +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { CommandInteraction, Message, Guild as DiscordGuild } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { SlashCommandOption } from '../../lib/extensions/Util'; +import { Guild } from '../../lib/models'; + +export default class PrefixCommand extends BushCommand { + constructor() { + super('prefix', { + aliases: ['prefix'], + category: "server config", + args: [ + { + id: 'prefix' + } + ], + userPermissions: ['MANAGE_GUILD'], + description: { + content: + 'Set the prefix of the current server (resets to default if prefix is not given)', + usage: 'prefix [prefix]', + examples: ['prefix', 'prefix +'] + }, + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.STRING, + name: 'prefix', + description: 'The prefix to set for this server', + required: false + } + ] + }); + } + + async changePrefix(guild: DiscordGuild, prefix?: string): Promise { + if (prefix) { + const row = await Guild.findByPk(guild.id); + row.prefix = prefix; + await row.save(); + } else { + const row = await Guild.findByPk(guild.id); + row.prefix = this.client.config.prefix; + await row.save(); + } + } + + async exec(message: Message, { prefix }: { prefix?: string }): Promise { + await this.changePrefix(message.guild, prefix); + if (prefix) { + await message.util.send(`Sucessfully set prefix to \`${prefix}\``); + } else { + await message.util.send( + `Sucessfully reset prefix to \`${this.client.config.prefix}\`` + ); + } + } + + async execSlash( + message: CommandInteraction, + { prefix }: { prefix?: SlashCommandOption } + ): Promise { + await this.changePrefix(message.guild, prefix?.value); + if (prefix) { + await message.reply(`Sucessfully set prefix to \`${prefix.value}\``); + } else { + await message.reply( + `Sucessfully reset prefix to \`${this.client.config.prefix}\`` + ); + } + } +} diff --git a/src/inhibitors/blacklist/BlacklistInhibitor.ts b/src/inhibitors/blacklist/BlacklistInhibitor.ts index 82db4c2..309815f 100644 --- a/src/inhibitors/blacklist/BlacklistInhibitor.ts +++ b/src/inhibitors/blacklist/BlacklistInhibitor.ts @@ -1,6 +1,6 @@ -import { BotInhibitor } from '../../lib/extensions/BotInhibitor'; +import { BushInhibitor } from '../../lib/extensions/BushInhibitor'; -export default class BlacklistInhibitor extends BotInhibitor { +export default class BlacklistInhibitor extends BushInhibitor { constructor() { super('blacklist', { reason: 'blacklist' diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BotClient.ts deleted file mode 100644 index c98f50d..0000000 --- a/src/lib/extensions/BotClient.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { - AkairoClient, - CommandHandler, - InhibitorHandler, - ListenerHandler, - TaskHandler -} from 'discord-akairo'; -import { Guild } from 'discord.js'; -import * as path from 'path'; -import { Sequelize } from 'sequelize'; -import * as Models from '../models'; -import { Util } from './Util'; -import { exit } from 'process'; -import { Intents } from 'discord.js'; -import * as config from '../../config/options'; -import { Logger } from '../utils/Logger'; -import chalk from 'chalk'; - -export type BotConfig = typeof config; - -export class BotClient extends AkairoClient { - public config: BotConfig; - public listenerHandler: ListenerHandler; - public inhibitorHandler: InhibitorHandler; - public commandHandler: CommandHandler; - public taskHandler: TaskHandler; - public util: Util; - public ownerID: string[]; - public db: Sequelize; - public logger: Logger; - constructor(config: BotConfig) { - super( - { - ownerID: config.owners, - intents: Intents.NON_PRIVILEGED - }, - { - allowedMentions: { parse: ['users'] }, // No everyone or role mentions by default - intents: Intents.NON_PRIVILEGED - } - ); - - // Set token - this.token = config.credentials.botToken; - - // Set config - this.config = config; - - // Create listener handler - this.listenerHandler = new ListenerHandler(this, { - directory: path.join(__dirname, '..', '..', 'listeners'), - automateCategories: true - }); - - // Create inhibitor handler - this.inhibitorHandler = new InhibitorHandler(this, { - directory: path.join(__dirname, '..', '..', 'inhibitors'), - automateCategories: true - }); - - // Create task handler - this.taskHandler = new TaskHandler(this, { - directory: path.join(__dirname, '..', '..', 'tasks') - }); - - // Create command handler - this.commandHandler = new CommandHandler(this, { - directory: path.join(__dirname, '..', '..', 'commands'), - prefix: async ({ guild }: { guild: Guild }) => { - const row = await Models.Guild.findByPk(guild.id); - if (!row) return this.config.prefix; - return row.prefix as string; - }, - allowMention: true, - handleEdits: true, - commandUtil: true, - commandUtilLifetime: 3e5, - argumentDefaults: { - prompt: { - timeout: 'Timed out.', - ended: 'Too many tries.', - cancel: 'Canceled.', - time: 3e4 - } - }, - ignorePermissions: this.config.owners, - ignoreCooldown: this.config.owners, - automateCategories: true - }); - - this.util = new Util(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: false - } - ); - this.logger = new Logger(this); - } - - // Initialize everything - private async _init(): Promise { - this.commandHandler.useListenerHandler(this.listenerHandler); - this.commandHandler.useInhibitorHandler(this.inhibitorHandler); - this.listenerHandler.setEmitters({ - commandHandler: this.commandHandler, - listenerHandler: this.listenerHandler, - process - }); - // 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(); - this.logger.log( - chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.') - ); - } catch (e) { - console.error( - chalk.red( - 'Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e - ) - ); - } - } - this.taskHandler.startAll(); - await this.dbPreInit(); - } - - public async dbPreInit(): Promise { - await this.db.authenticate(); - Models.Guild.initModel(this.db, this); - Models.Modlog.initModel(this.db); - Models.Ban.initModel(this.db); - Models.Level.initModel(this.db); - try { - await this.db.sync(); // Sync all tables to fix everything if updated - } catch { - // Ignore error - } - } - - public async start(): Promise { - try { - await this._init(); - await this.login(this.token); - } catch (e) { - console.error(chalk.red(e.stack)); - exit(2); - } - } - - public destroy(relogin = true): void | Promise { - super.destroy(); - if (relogin) { - return this.login(this.token); - } - } -} diff --git a/src/lib/extensions/BotCommand.ts b/src/lib/extensions/BotCommand.ts deleted file mode 100644 index c5d31e9..0000000 --- a/src/lib/extensions/BotCommand.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Command, CommandOptions } from 'discord-akairo'; -import { APIApplicationCommandOption } from 'discord-api-types'; -import { BotClient } from './BotClient'; - -export interface BotCommandOptions extends CommandOptions { - slashCommandOptions?: APIApplicationCommandOption[]; - description: { - content: string; - usage: string; - examples: string[]; - }; -} - -export class BotCommand extends Command { - public client: BotClient; - constructor(id: string, options?: BotCommandOptions) { - super(id, options); - this.options = options; - } -} diff --git a/src/lib/extensions/BotInhibitor.ts b/src/lib/extensions/BotInhibitor.ts deleted file mode 100644 index 960aade..0000000 --- a/src/lib/extensions/BotInhibitor.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Inhibitor } from 'discord-akairo'; -import { BotClient } from './BotClient'; - -export class BotInhibitor extends Inhibitor { - public client: BotClient; -} diff --git a/src/lib/extensions/BotListener.ts b/src/lib/extensions/BotListener.ts deleted file mode 100644 index 9ec17b2..0000000 --- a/src/lib/extensions/BotListener.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Listener } from 'discord-akairo'; -import { BotClient } from './BotClient'; - -export class BotListener extends Listener { - public client: BotClient; -} diff --git a/src/lib/extensions/BotTask.ts b/src/lib/extensions/BotTask.ts deleted file mode 100644 index 4d5cdcd..0000000 --- a/src/lib/extensions/BotTask.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Task } from 'discord-akairo'; -import { BotClient } from './BotClient'; - -export class BotTask extends Task { - public client: BotClient; -} diff --git a/src/lib/extensions/BushClient.ts b/src/lib/extensions/BushClient.ts new file mode 100644 index 0000000..8a8ae91 --- /dev/null +++ b/src/lib/extensions/BushClient.ts @@ -0,0 +1,169 @@ +import { + AkairoClient, + CommandHandler, + InhibitorHandler, + ListenerHandler, + TaskHandler +} from 'discord-akairo'; +import { Guild } from 'discord.js'; +import * as path from 'path'; +import { Sequelize } from 'sequelize'; +import * as Models from '../models'; +import { Util } from './Util'; +import { exit } from 'process'; +import { Intents } from 'discord.js'; +import * as config from '../../config/options'; +import { Logger } from '../utils/Logger'; +import chalk from 'chalk'; + +export type BotConfig = typeof config; + +export class BushClient extends AkairoClient { + public config: BotConfig; + public listenerHandler: ListenerHandler; + public inhibitorHandler: InhibitorHandler; + public commandHandler: CommandHandler; + public taskHandler: TaskHandler; + public util: Util; + public ownerID: string[]; + public db: Sequelize; + public logger: Logger; + constructor(config: BotConfig) { + super( + { + ownerID: config.owners, + intents: Intents.NON_PRIVILEGED + }, + { + allowedMentions: { parse: ['users'] }, // No everyone or role mentions by default + intents: Intents.NON_PRIVILEGED + } + ); + + // Set token + this.token = config.credentials.botToken; + + // Set config + this.config = config; + + // Create listener handler + this.listenerHandler = new ListenerHandler(this, { + directory: path.join(__dirname, '..', '..', 'listeners'), + automateCategories: true + }); + + // Create inhibitor handler + this.inhibitorHandler = new InhibitorHandler(this, { + directory: path.join(__dirname, '..', '..', 'inhibitors'), + automateCategories: true + }); + + // Create task handler + this.taskHandler = new TaskHandler(this, { + directory: path.join(__dirname, '..', '..', 'tasks') + }); + + // Create command handler + this.commandHandler = new CommandHandler(this, { + directory: path.join(__dirname, '..', '..', 'commands'), + prefix: async ({ guild }: { guild: Guild }) => { + const row = await Models.Guild.findByPk(guild.id); + if (!row) return this.config.prefix; + return row.prefix as string; + }, + allowMention: true, + handleEdits: true, + commandUtil: true, + commandUtilLifetime: 3e5, + argumentDefaults: { + prompt: { + timeout: 'Timed out.', + ended: 'Too many tries.', + cancel: 'Canceled.', + time: 3e4 + } + }, + ignorePermissions: this.config.owners, + ignoreCooldown: this.config.owners, + automateCategories: true + }); + + this.util = new Util(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: false + } + ); + this.logger = new Logger(this); + } + + // Initialize everything + private async _init(): Promise { + this.commandHandler.useListenerHandler(this.listenerHandler); + this.commandHandler.useInhibitorHandler(this.inhibitorHandler); + this.listenerHandler.setEmitters({ + commandHandler: this.commandHandler, + listenerHandler: this.listenerHandler, + process + }); + // 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(); + this.logger.log( + chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.') + ); + } catch (e) { + console.error( + chalk.red( + 'Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e + ) + ); + } + } + this.taskHandler.startAll(); + await this.dbPreInit(); + } + + public async dbPreInit(): Promise { + await this.db.authenticate(); + Models.Guild.initModel(this.db, this); + Models.Modlog.initModel(this.db); + Models.Ban.initModel(this.db); + Models.Level.initModel(this.db); + try { + await this.db.sync(); // Sync all tables to fix everything if updated + } catch { + // Ignore error + } + } + + public async start(): Promise { + try { + await this._init(); + await this.login(this.token); + } catch (e) { + console.error(chalk.red(e.stack)); + exit(2); + } + } + + public destroy(relogin = true): void | Promise { + super.destroy(); + if (relogin) { + return this.login(this.token); + } + } +} diff --git a/src/lib/extensions/BushCommand.ts b/src/lib/extensions/BushCommand.ts new file mode 100644 index 0000000..4f9dc6e --- /dev/null +++ b/src/lib/extensions/BushCommand.ts @@ -0,0 +1,20 @@ +import { Command, CommandOptions } from 'discord-akairo'; +import { APIApplicationCommandOption } from 'discord-api-types'; +import { BushClient } from './BushClient'; + +export interface BushCommandOptions extends CommandOptions { + slashCommandOptions?: APIApplicationCommandOption[]; + description: { + content: string; + usage: string; + examples: string[]; + }; +} + +export class BushCommand extends Command { + public client: BushClient; + constructor(id: string, options?: BushCommandOptions) { + super(id, options); + this.options = options; + } +} diff --git a/src/lib/extensions/BushInhibitor.ts b/src/lib/extensions/BushInhibitor.ts new file mode 100644 index 0000000..d9a9b68 --- /dev/null +++ b/src/lib/extensions/BushInhibitor.ts @@ -0,0 +1,6 @@ +import { Inhibitor } from 'discord-akairo'; +import { BushClient } from './BushClient'; + +export class BushInhibitor extends Inhibitor { + public client: BushClient; +} diff --git a/src/lib/extensions/BushListener.ts b/src/lib/extensions/BushListener.ts new file mode 100644 index 0000000..6a13210 --- /dev/null +++ b/src/lib/extensions/BushListener.ts @@ -0,0 +1,6 @@ +import { Listener } from 'discord-akairo'; +import { BushClient } from './BushClient'; + +export class BushListener extends Listener { + public client: BushClient; +} diff --git a/src/lib/extensions/BushTask.ts b/src/lib/extensions/BushTask.ts new file mode 100644 index 0000000..21655e9 --- /dev/null +++ b/src/lib/extensions/BushTask.ts @@ -0,0 +1,6 @@ +import { Task } from 'discord-akairo'; +import { BushClient } from './BushClient'; + +export class BushTask extends Task { + public client: BushClient; +} diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts index 54df670..7c1d4b2 100644 --- a/src/lib/extensions/Util.ts +++ b/src/lib/extensions/Util.ts @@ -1,5 +1,5 @@ import { ClientUtil } from 'discord-akairo'; -import { BotClient } from './BotClient'; +import { BushClient } from './BushClient'; import { promisify } from 'util'; import { exec } from 'child_process'; import got from 'got'; @@ -57,9 +57,9 @@ export interface SlashCommandOption { export class Util extends ClientUtil { /** * The client of this ClientUtil - * @type {BotClient} + * @type {BushClient} */ - public client: BotClient; + public client: BushClient; /** * The hastebin urls used to post to hastebin, attempts to post in order * @type {string[]} @@ -83,7 +83,7 @@ export class Util extends ClientUtil { * Creates this client util * @param client The client to initialize with */ - constructor(client: BotClient) { + constructor(client: BushClient) { super(client); } @@ -273,14 +273,14 @@ export class Util extends ClientUtil { } } - for (const [, botCommand] of this.client.commandHandler.modules) { - if (botCommand.execSlash) { - const found = registered.find((i) => i.name == botCommand.id); + for (const [, BushCommand] of this.client.commandHandler.modules) { + if (BushCommand.execSlash) { + const found = registered.find((i) => i.name == BushCommand.id); const slashdata = { - name: botCommand.id, - description: botCommand.description.content, - options: botCommand.options.slashCommandOptions + name: BushCommand.id, + description: BushCommand.description.content, + options: BushCommand.options.slashCommandOptions }; if (found?.id && !force) { @@ -292,7 +292,7 @@ export class Util extends ClientUtil { ) : fetchedGuild.commands.edit(found.id, slashdata); this.client.logger.verbose( - chalk`{yellow Edited slash command ${botCommand.id}${ + chalk`{yellow Edited slash command ${BushCommand.id}${ guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' }}` ); @@ -302,7 +302,7 @@ export class Util extends ClientUtil { ? await this.client.application.commands.create(slashdata) : fetchedGuild.commands.create(slashdata); this.client.logger.verbose( - chalk`{green Created slash command ${botCommand.id}${ + chalk`{green Created slash command ${BushCommand.id}${ guild !== undefined ? ` in guild ${fetchedGuild.name}` : '' }}` ); diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 1cb3abb..c224bf5 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -1,5 +1,5 @@ import { DataTypes, Optional, Sequelize } from 'sequelize'; -import { BotClient } from '../extensions/BotClient'; +import { BushClient } from '../extensions/BushClient'; import { BaseModel } from './BaseModel'; export interface GuildModel { @@ -14,7 +14,7 @@ export class Guild { id: string; prefix: string; - static initModel(seqeulize: Sequelize, client: BotClient): void { + static initModel(seqeulize: Sequelize, client: BushClient): void { Guild.init( { id: { diff --git a/src/lib/utils/Logger.ts b/src/lib/utils/Logger.ts index f38365e..604b45e 100644 --- a/src/lib/utils/Logger.ts +++ b/src/lib/utils/Logger.ts @@ -1,10 +1,10 @@ import { TextChannel } from 'discord.js'; -import { BotClient } from '../extensions/BotClient'; +import { BushClient } from '../extensions/BushClient'; import chalk from 'chalk'; export class Logger { - private client: BotClient; - public constructor(client: BotClient) { + private client: BushClient; + public constructor(client: BushClient) { this.client = client; } private stripColor(text: string): string { diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts index fc43f3c..b13dd36 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -1,7 +1,7 @@ import chalk from 'chalk'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushListener } from '../../lib/extensions/BushListener'; -export default class CommandBlockedListener extends BotListener { +export default class CommandBlockedListener extends BushListener { public constructor() { super('ready', { emitter: 'client', diff --git a/src/listeners/client/syncslashcommands.ts b/src/listeners/client/syncslashcommands.ts index febdd1b..d734507 100644 --- a/src/listeners/client/syncslashcommands.ts +++ b/src/listeners/client/syncslashcommands.ts @@ -1,6 +1,6 @@ -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushListener } from '../../lib/extensions/BushListener'; -export default class CreateSlashCommands extends BotListener { +export default class CreateSlashCommands extends BushListener { constructor() { super('createslashcommands', { emitter: 'client', diff --git a/src/listeners/commands/commandblocked.ts b/src/listeners/commands/commandblocked.ts index 82e53a9..dee1319 100644 --- a/src/listeners/commands/commandblocked.ts +++ b/src/listeners/commands/commandblocked.ts @@ -1,8 +1,8 @@ -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushListener } from '../../lib/extensions/BushListener'; import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; -export default class CommandBlockedListener extends BotListener { +export default class CommandBlockedListener extends BushListener { public constructor() { super('commandBlocked', { emitter: 'commandHandler', diff --git a/src/listeners/commands/commandstarted.ts b/src/listeners/commands/commandstarted.ts index 15eea9d..d81ed59 100644 --- a/src/listeners/commands/commandstarted.ts +++ b/src/listeners/commands/commandstarted.ts @@ -1,16 +1,16 @@ import chalk from 'chalk'; import { Message, DMChannel } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushListener } from '../../lib/extensions/BushListener'; -export default class CommandStartedListener extends BotListener { +export default class CommandStartedListener extends BushListener { constructor() { super('logCommands', { emitter: 'commandHandler', event: 'commandStarted' }); } - exec(message: Message, command: BotCommand): void { + exec(message: Message, command: BushCommand): void { this.client.logger.verbose( chalk`{cyan {green ${message.author.tag}} is running {green ${ command.aliases[0] diff --git a/src/listeners/commands/error.ts b/src/listeners/commands/error.ts index 37179e7..518545a 100644 --- a/src/listeners/commands/error.ts +++ b/src/listeners/commands/error.ts @@ -1,11 +1,11 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushListener } from '../../lib/extensions/BushListener'; import { stripIndents } from 'common-tags'; import { Message } from 'discord.js'; import { MessageEmbed } from 'discord.js'; import { TextChannel } from 'discord.js'; -export default class CommandErrorListener extends BotListener { +export default class CommandErrorListener extends BushListener { constructor() { super('error', { emitter: 'commandHandler', @@ -15,7 +15,7 @@ export default class CommandErrorListener extends BotListener { async exec( error: Error, message: Message, - command?: BotCommand + command?: BushCommand ): Promise { const errorNumber = Math.floor(Math.random() * 6969696969) + 69; // hehe funy numbers const errorDevEmbed = this.client.util diff --git a/src/listeners/commands/slashError.ts b/src/listeners/commands/slashError.ts index 3b174a3..3f2260d 100644 --- a/src/listeners/commands/slashError.ts +++ b/src/listeners/commands/slashError.ts @@ -1,11 +1,11 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushListener } from '../../lib/extensions/BushListener'; import { stripIndents } from 'common-tags'; import { MessageEmbed } from 'discord.js'; import { TextChannel } from 'discord.js'; import { CommandInteraction } from 'discord.js'; -export default class CommandErrorListener extends BotListener { +export default class CommandErrorListener extends BushListener { constructor() { super('slashError', { emitter: 'commandHandler', @@ -15,7 +15,7 @@ export default class CommandErrorListener extends BotListener { async exec( error: Error, message: CommandInteraction, - command: BotCommand + command: BushCommand ): Promise { const errorNumber = Math.floor(Math.random() * 6969696969) + 69; // hehe funy numbers const errorDevEmbed = this.client.util diff --git a/src/listeners/guild/syncunban.ts b/src/listeners/guild/syncunban.ts index 14f8820..b8a1419 100644 --- a/src/listeners/guild/syncunban.ts +++ b/src/listeners/guild/syncunban.ts @@ -1,8 +1,8 @@ import { User, Guild } from 'discord.js'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushListener } from '../../lib/extensions/BushListener'; import { Ban } from '../../lib/models'; -export default class CommandBlockedListener extends BotListener { +export default class CommandBlockedListener extends BushListener { public constructor() { super('guildBanRemove', { emitter: 'client', diff --git a/src/listeners/message/levels.ts b/src/listeners/message/levels.ts index 9a5fbe8..3503584 100644 --- a/src/listeners/message/levels.ts +++ b/src/listeners/message/levels.ts @@ -1,9 +1,9 @@ import chalk from 'chalk'; import { Message } from 'discord.js'; -import { BotListener } from '../../lib/extensions/BotListener'; +import { BushListener } from '../../lib/extensions/BushListener'; import { Level } from '../../lib/models'; -export default class LevelListener extends BotListener { +export default class LevelListener extends BushListener { private levelCooldowns: Set = new Set(); private blacklistedChannels = ['702456294874808330']; constructor() { diff --git a/src/tasks/Unban.ts b/src/tasks/Unban.ts index c6f9a01..6b9d82e 100644 --- a/src/tasks/Unban.ts +++ b/src/tasks/Unban.ts @@ -1,10 +1,10 @@ import chalk from 'chalk'; import { DiscordAPIError } from 'discord.js'; import { Op } from 'sequelize'; -import { BotTask } from '../lib/extensions/BotTask'; +import { BushTask } from '../lib/extensions/BushTask'; import { Ban } from '../lib/models'; -export default class UnbanTask extends BotTask { +export default class UnbanTask extends BushTask { constructor() { super('unban', { delay: 30_000, // 1/2 min -- cgit