diff options
56 files changed, 208 insertions, 227 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index 00d37c3..c397855 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -78,7 +78,7 @@ export default class ChannelPermissionsCommand extends BushCommand { { reason: 'Changing overwrites for mass channel channel perms command' } ); } catch (e) { - this.client.console.debug(e.stack); + client.console.debug(e.stack); failedChannels.push(channel); } } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index 33bff35..8093d83 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -69,16 +69,16 @@ export default class BlacklistCommand extends BushCommand { const global = args.global && message.author.isOwner(); const target = typeof args.target === 'string' - ? (await Argument.cast('channel', this.client.commandHandler.resolver, message as BushMessage, args.target)) ?? - (await Argument.cast('user', this.client.commandHandler.resolver, message as BushMessage, args.target)) + ? (await Argument.cast('channel', client.commandHandler.resolver, message as BushMessage, args.target)) ?? + (await Argument.cast('user', client.commandHandler.resolver, message as BushMessage, args.target)) : args.target; if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`); const targetID = target.id; if (global) { if (action === 'toggle') { - const blacklistedUsers = (await Global.findByPk(this.client.config.environment)).blacklistedUsers; - const blacklistedChannels = (await Global.findByPk(this.client.config.environment)).blacklistedChannels; + const blacklistedUsers = (await Global.findByPk(client.config.environment)).blacklistedUsers; + const blacklistedChannels = (await Global.findByPk(client.config.environment)).blacklistedChannels; action = blacklistedUsers.includes(targetID) || blacklistedChannels.includes(targetID) ? 'unblacklist' : 'blacklist'; } const success = await util diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index 27e7311..41ca8a4 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -72,7 +72,7 @@ export default class DisableCommand extends BushCommand { if (global) { if (action === 'toggle') { - const disabledCommands = (await Global.findByPk(this.client.config.environment)).disabledCommands; + const disabledCommands = (await Global.findByPk(client.config.environment)).disabledCommands; action = disabledCommands.includes(commandID) ? 'disable' : 'enable'; } const success = await util diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 26ae5c4..9c1ce92 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -38,7 +38,7 @@ export default class PrefixCommand extends BushCommand { async exec(message: BushMessage | BushSlashMessage, args: { prefix?: string }): Promise<unknown> { const oldPrefix = await message.guild.getSetting('prefix'); - await message.guild.setSetting('prefix', args.prefix ?? this.client.config.prefix); + await message.guild.setSetting('prefix', args.prefix ?? client.config.prefix); if (args.prefix) { return await message.util.send({ content: `${util.emojis.success} changed the server's prefix ${oldPrefix ? `from \`${oldPrefix}\`` : ''} to \`${ @@ -48,7 +48,7 @@ export default class PrefixCommand extends BushCommand { }); } else { return await message.util.send({ - content: `${util.emojis.success} reset the server's prefix to \`${this.client.config.prefix}\`.`, + content: `${util.emojis.success} reset the server's prefix to \`${client.config.prefix}\`.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 3966499..abdf2b9 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -80,13 +80,13 @@ export default class EvalCommand extends BushCommand { const sh = promisify(exec), me = message.member, member = message.member, - bot = this.client, + bot = client, guild = message.guild, channel = message.channel, - config = this.client.config, + config = client.config, members = message.guild?.members, roles = message.guild?.roles, - client = this.client, + client = client, emojis = util.emojis, colors = util.colors, util = util, diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index c930118..2be67fa 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -39,12 +39,12 @@ export default class ReloadCommand extends BushCommand { try { const s = new Date(); output = await util.shell(`yarn build-${fast ? 'esbuild' : 'tsc'}`); - this.client.commandHandler.reloadAll(); - this.client.listenerHandler.reloadAll(); - this.client.inhibitorHandler.reloadAll(); + client.commandHandler.reloadAll(); + client.listenerHandler.reloadAll(); + client.inhibitorHandler.reloadAll(); return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`); } catch (e) { - if (output) await this.client.logger.error('reloadCommand', output); + if (output) await client.logger.error('reloadCommand', output); return message.util.send(`An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js')}`); } } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 62ec96a..5042be4 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -37,7 +37,7 @@ export default class SayCommand extends BushCommand { } public async execSlash(message: AkairoMessage, { content }: { content: string }): Promise<unknown> { - if (!this.client.config.owners.includes(message.author.id)) { + if (!client.config.owners.includes(message.author.id)) { return await message.interaction.reply({ content: `${util.emojis.error} Only my developers can run this command.`, ephemeral: true diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index c1bfdb7..dc4562c 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -19,7 +19,7 @@ export default class ServersCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { const maxLength = 10; - const guilds = this.client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).array(); + const guilds = client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).array(); const chunkedGuilds: Guild[][] = []; const embeds: MessageEmbed[] = []; @@ -30,14 +30,14 @@ export default class ServersCommand extends BushCommand { chunkedGuilds.forEach((c: Guild[]) => { const embed = new MessageEmbed(); c.forEach((g: Guild) => { - const owner = this.client.users.cache.get(g.ownerId)?.tag; + const owner = client.users.cache.get(g.ownerId)?.tag; embed .addField( `**${g.name}**`, `**ID:** ${g.id}\n**Owner:** ${owner ? owner : g.ownerId}\n**Members:** ${g.memberCount.toLocaleString()}`, false ) - .setTitle(`Server List [${this.client.guilds.cache.size}]`) + .setTitle(`Server List [${client.guilds.cache.size}]`) .setColor(util.colors.default); }); embeds.push(embed); diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index acbbfdc..ed1dfd7 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -38,7 +38,7 @@ export default class ShCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage, { command }: { command: string }): Promise<unknown> { - if (!this.client.config.owners.includes(message.author.id)) + if (!client.config.owners.includes(message.author.id)) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); const input = clean(command); diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index cc1519f..9071a8d 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -43,7 +43,7 @@ export default class SuperUserCommand extends BushCommand { if (!message.author.isOwner()) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); - const superUsers = (await Global.findByPk(this.client.config.environment)).superUsers; + const superUsers = (await Global.findByPk(client.config.environment)).superUsers; let success; if (args.action === 'add') { if (superUsers.includes(args.user.id)) { diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index f7edda2..3a27be0 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -128,7 +128,7 @@ export default class TestCommand extends BushCommand { return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds }); } else if (['delete slash commands'].includes(args?.feature?.toLowerCase())) { // let guildCommandCount = 0; - // this.client.guilds.cache.forEach(guild => + // client.guilds.cache.forEach(guild => // guild.commands.fetch().then(commands => { // commands.forEach(async command => { // await command.delete(); @@ -138,7 +138,7 @@ export default class TestCommand extends BushCommand { // ); const guildCommands = await message.guild.commands.fetch(); guildCommands.forEach(async (command) => await command.delete()); - const globalCommands = await this.client.application.commands.fetch(); + const globalCommands = await client.application.commands.fetch(); globalCommands.forEach(async (command) => await command.delete()); return await message.util.reply( diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 29ed29a..e47984b 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -18,21 +18,21 @@ export default class BotInfoCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage): Promise<void> { - const developers = (await util.mapIDs(this.client.config.owners)).map((u) => u?.tag).join('\n'); + const developers = (await util.mapIDs(client.config.owners)).map((u) => u?.tag).join('\n'); const currentCommit = (await util.shell('git rev-parse HEAD')).stdout.replace('\n', ''); let repoUrl = (await util.shell('git remote get-url origin')).stdout.replace('\n', ''); repoUrl = repoUrl.substring(0, repoUrl.length - 4); const embed = new MessageEmbed() .setTitle('Bot Info:') - .addField('**Uptime**', util.humanizeDuration(this.client.uptime), true) - .addField('**Servers**', this.client.guilds.cache.size.toLocaleString(), true) - .addField('**Users**', this.client.users.cache.size.toLocaleString(), true) + .addField('**Uptime**', util.humanizeDuration(client.uptime), true) + .addField('**Servers**', client.guilds.cache.size.toLocaleString(), true) + .addField('**Users**', client.users.cache.size.toLocaleString(), true) .addField('**Discord.js Version**', discordJSVersion, true) .addField('**Node.js Version**', process.version.slice(1), true) - .addField('**Commands**', this.client.commandHandler.modules.size.toLocaleString(), true) - .addField('**Listeners**', this.client.listenerHandler.modules.size.toLocaleString(), true) - .addField('**Inhibitors**', this.client.inhibitorHandler.modules.size.toLocaleString(), true) - .addField('**Tasks**', this.client.taskHandler.modules.size.toLocaleString(), true) + .addField('**Commands**', client.commandHandler.modules.size.toLocaleString(), true) + .addField('**Listeners**', client.listenerHandler.modules.size.toLocaleString(), true) + .addField('**Inhibitors**', client.inhibitorHandler.modules.size.toLocaleString(), true) + .addField('**Tasks**', client.taskHandler.modules.size.toLocaleString(), true) .addField('**Current Commit**', `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})`, true) .addField('**Developers**', developers, true) .setTimestamp() diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 2e541f3..e82a5fe 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -47,7 +47,7 @@ export default class GuildInfoCommand extends BushCommand { } let isPreview = false; if (['bigint', 'number', 'string'].includes(typeof args?.guild)) { - const preview = await this.client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {}); + const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {}); if (preview) { args.guild = preview; isPreview = true; @@ -60,31 +60,31 @@ export default class GuildInfoCommand extends BushCommand { const guildAbout: string[] = []; // const guildSecurity = []; if (['516977525906341928', '784597260465995796', '717176538717749358', '767448775450820639'].includes(guild.id)) - emojis.push(this.client.consts.mappings.otherEmojis.BUSH_VERIFIED); + emojis.push(client.consts.mappings.otherEmojis.BUSH_VERIFIED); if (!isPreview && guild instanceof Guild) { - if (guild.premiumTier) emojis.push(this.client.consts.mappings.otherEmojis['BOOST_' + guild.premiumTier]); + if (guild.premiumTier) emojis.push(client.consts.mappings.otherEmojis['BOOST_' + guild.premiumTier]); await guild.fetch(); const channelTypes = [ - `${this.client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.TEXT} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_TEXT') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.NEWS} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.NEWS} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_NEWS') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.VOICE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.VOICE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_VOICE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.STAGE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.STAGE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_STAGE_VOICE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.STORE} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.STORE} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_STORE') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.CATEGORY} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.CATEGORY} ${guild.channels.cache .filter((channel) => channel.type === 'GUILD_CATEGORY') .size.toLocaleString()}`, - `${this.client.consts.mappings.otherEmojis.THREAD} ${guild.channels.cache + `${client.consts.mappings.otherEmojis.THREAD} ${guild.channels.cache .filter((channel) => ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD', 'GUILD_STAGE_VOICE'].includes(channel.type) ) @@ -125,8 +125,8 @@ export default class GuildInfoCommand extends BushCommand { } const guildFeatures = guild.features.sort((a, b) => { - const aWeight = this.client.consts.mappings.features[a]?.weight; - const bWeight = this.client.consts.mappings.features[b]?.weight; + const aWeight = client.consts.mappings.features[a]?.weight; + const bWeight = client.consts.mappings.features[b]?.weight; if (aWeight != undefined && bWeight != undefined) { return aWeight - bWeight; @@ -138,10 +138,10 @@ export default class GuildInfoCommand extends BushCommand { }); if (guildFeatures.length) { guildFeatures.forEach((feature) => { - if (this.client.consts.mappings.features[feature]?.emoji) { - emojis.push(`${this.client.consts.mappings.features[feature].emoji}`); - } else if (this.client.consts.mappings.features[feature]?.name) { - emojis.push(`\`${this.client.consts.mappings.features[feature].name}\``); + if (client.consts.mappings.features[feature]?.emoji) { + emojis.push(`${client.consts.mappings.features[feature].emoji}`); + } else if (client.consts.mappings.features[feature]?.name) { + emojis.push(`\`${client.consts.mappings.features[feature].name}\``); } else { emojis.push(`\`${feature}\``); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index a644755..458b7d0 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -47,24 +47,24 @@ export default class HelpCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { command: BushCommand | string; showHidden?: boolean } ): Promise<unknown> { - const prefix = this.client.config.isDevelopment ? 'dev ' : message.util.parsed.prefix; + const prefix = client.config.isDevelopment ? 'dev ' : message.util.parsed.prefix; const row = new MessageActionRow(); - if (!this.client.config.isDevelopment && !this.client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { + if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { row.addComponents( new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${this.client.user.id}&permissions=2147483647&scope=bot%20applications.commands` + url: `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=2147483647&scope=bot%20applications.commands` }) ); } - if (!this.client.guilds.cache.get(this.client.config.supportGuild.id).members.cache.has(message.author.id)) { + if (!client.guilds.cache.get(client.config.supportGuild.id).members.cache.has(message.author.id)) { row.addComponents( new MessageButton({ style: 'LINK', label: 'Support Server', - url: this.client.config.supportGuild.invite + url: client.config.supportGuild.invite }) ); } @@ -76,11 +76,11 @@ export default class HelpCommand extends BushCommand { }) ); - const isOwner = this.client.isOwner(message.author); - const isSuperUser = this.client.isSuperUser(message.author); + const isOwner = client.isOwner(message.author); + const isSuperUser = client.isSuperUser(message.author); const command = args.command ? typeof args.command === 'string' - ? this.client.commandHandler.modules.get(args.command) || null + ? client.commandHandler.modules.get(args.command) || null : args.command : null; if (!isOwner) args.showHidden = false; diff --git a/src/commands/info/invite.ts b/src/commands/info/invite.ts index 1f65cdc..a2128b3 100644 --- a/src/commands/info/invite.ts +++ b/src/commands/info/invite.ts @@ -19,13 +19,12 @@ export default class InviteCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { - if (this.client.config.isDevelopment) - return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`); + if (client.config.isDevelopment) return await message.util.reply(`${util.emojis.error} The dev bot cannot be invited.`); const ButtonRow = new MessageActionRow().addComponents( new MessageButton({ style: 'LINK', label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${this.client.user.id}&permissions=2147483647&scope=bot%20applications.commands` + url: `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=2147483647&scope=bot%20applications.commands` }) ); return await message.util.reply({ content: 'You can invite me here:', components: [ButtonRow] }); diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 36f3bc7..550c3c7 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -40,7 +40,7 @@ export default class PingCommand extends BushCommand { await message.interaction.reply('Pong!'); const timestamp2 = await message.interaction.fetchReply().then((m) => (m as Message).createdTimestamp); const botLatency = `${'```'}\n ${Math.round(timestamp2 - timestamp1)}ms ${'```'}`; - const apiLatency = `${'```'}\n ${Math.round(this.client.ws.ping)}ms ${'```'}`; + const apiLatency = `${'```'}\n ${Math.round(client.ws.ping)}ms ${'```'}`; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts index b32245c..b6b9e16 100644 --- a/src/commands/info/snowflakeInfo.ts +++ b/src/commands/info/snowflakeInfo.ts @@ -57,8 +57,8 @@ export default class SnowflakeInfoCommand extends BushCommand { const snowflakeEmbed = new MessageEmbed().setTitle('Unknown :snowflake:').setColor(util.colors.default); // Channel - if (this.client.channels.cache.has(snowflake)) { - const channel: Channel = this.client.channels.cache.get(snowflake); + if (client.channels.cache.has(snowflake)) { + const channel: Channel = client.channels.cache.get(snowflake); const channelInfo = [`**Type:** ${channel.type}`]; if (['dm', 'group'].includes(channel.type)) { const _channel = channel as DMChannel; @@ -88,11 +88,11 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Guild - else if (this.client.guilds.cache.has(snowflake)) { - const guild: Guild = this.client.guilds.cache.get(snowflake); + else if (client.guilds.cache.has(snowflake)) { + const guild: Guild = client.guilds.cache.get(snowflake); const guildInfo = [ `**Name:** ${guild.name}`, - `**Owner:** ${this.client.users.cache.get(guild.ownerId)?.tag || '¯\\_(ツ)_/¯'} (${guild.ownerId})`, + `**Owner:** ${client.users.cache.get(guild.ownerId)?.tag || '¯\\_(ツ)_/¯'} (${guild.ownerId})`, `**Members:** ${guild.memberCount?.toLocaleString()}` ]; snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })); @@ -101,8 +101,8 @@ export default class SnowflakeInfoCommand extends BushCommand { } // User - else if (this.client.users.cache.has(snowflake)) { - const user: User = this.client.users.cache.get(snowflake); + else if (client.users.cache.has(snowflake)) { + const user: User = client.users.cache.get(snowflake); const userInfo = [`**Name:** <@${user.id}> (${user.tag})`]; snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })); snowflakeEmbed.addField('» User Info', userInfo.join('\n')); @@ -110,8 +110,8 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Emoji - else if (this.client.emojis.cache.has(snowflake)) { - const emoji: Emoji = this.client.emojis.cache.get(snowflake); + else if (client.emojis.cache.has(snowflake)) { + const emoji: Emoji = client.emojis.cache.get(snowflake); const emojiInfo = [`**Name:** ${emoji.name}`, `**Animated:** ${emoji.animat |
