diff options
Diffstat (limited to 'src')
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.animated}`]; snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 5cfc6f0..87235a9 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -44,7 +44,7 @@ export default class UserInfoCommand extends BushCommand { public async exec(message: BushMessage | BushSlashMessage, args: { user: GuildMember }): Promise<unknown> { const user = args?.user || message.member; const emojis = []; - const superUsers = this.client.cache.global.superUsers; + const superUsers = client.cache.global.superUsers; const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(user.user.tag) @@ -52,13 +52,13 @@ export default class UserInfoCommand extends BushCommand { .setTimestamp(); // Flags - if (this.client.config.owners.includes(user.id)) emojis.push(this.client.consts.mappings.otherEmojis.DEVELOPER); - if (superUsers.includes(user.id)) emojis.push(this.client.consts.mappings.otherEmojis.SUPERUSER); + if (client.config.owners.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.DEVELOPER); + if (superUsers.includes(user.id)) emojis.push(client.consts.mappings.otherEmojis.SUPERUSER); const flags = user.user.flags?.toArray(); if (flags) { flags.forEach((f) => { - if (this.client.consts.mappings.userFlags[f]) { - emojis.push(this.client.consts.mappings.userFlags[f]); + if (client.consts.mappings.userFlags[f]) { + emojis.push(client.consts.mappings.userFlags[f]); } else emojis.push(f); }); } @@ -66,16 +66,16 @@ export default class UserInfoCommand extends BushCommand { // Since discord bald I just guess if someone has nitro if ( Number(user.user.discriminator) < 10 || - this.client.consts.mappings.maybeNitroDiscrims.includes(user.user.discriminator) || + client.consts.mappings.maybeNitroDiscrims.includes(user.user.discriminator) || user.user.displayAvatarURL({ dynamic: true })?.endsWith('.gif') || user.user.flags?.toArray().includes('PARTNERED_SERVER_OWNER') ) { - emojis.push(this.client.consts.mappings.otherEmojis.NITRO); + emojis.push(client.consts.mappings.otherEmojis.NITRO); } - if (message.guild.ownerId == user.id) emojis.push(this.client.consts.mappings.otherEmojis.OWNER); - else if (user.permissions.has('ADMINISTRATOR')) emojis.push(this.client.consts.mappings.otherEmojis.ADMIN); - if (user.premiumSinceTimestamp) emojis.push(this.client.consts.mappings.otherEmojis.BOOSTER); + if (message.guild.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.OWNER); + else if (user.permissions.has('ADMINISTRATOR')) emojis.push(client.consts.mappings.otherEmojis.ADMIN); + if (user.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.BOOSTER); const createdAt = user.user.createdAt.toLocaleString(), createdAtDelta = moment(moment(user.user.createdAt).diff(moment())).toLocaleString(), @@ -100,11 +100,11 @@ export default class UserInfoCommand extends BushCommand { ); if (premiumSince) serverUserInfo.push(`**Boosting Since:** ${premiumSince} (${premiumSinceDelta} ago)`); if (user.displayHexColor) serverUserInfo.push(`**Display Color:** ${user.displayHexColor}`); - if (user.id == '322862723090219008' && message.guild.id == this.client.consts.mappings.guilds.bush) + if (user.id == '322862723090219008' && message.guild.id == client.consts.mappings.guilds.bush) serverUserInfo.push(`**General Deletions:** 2`); if ( ['384620942577369088', '496409778822709251'].includes(user.id) && - message.guild.id == this.client.consts.mappings.guilds.bush + message.guild.id == client.consts.mappings.guilds.bush ) serverUserInfo.push(`**General Deletions:** 1`); if (user.nickname) serverUserInfo.push(`**Nickname** ${user.nickname}`); @@ -141,8 +141,8 @@ export default class UserInfoCommand extends BushCommand { perms.push('`Administrator`'); } else { user.permissions.toArray(true).forEach((permission) => { - if (this.client.consts.mappings.permissions[permission]?.important) { - perms.push(`\`${this.client.consts.mappings.permissions[permission].name}\``); + if (client.consts.mappings.permissions[permission]?.important) { + perms.push(`\`${client.consts.mappings.permissions[permission].name}\``); } }); } diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 27a0ffc..3736165 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -105,7 +105,7 @@ export default class BanCommand extends BushCommand { if (reason) { time = typeof reason === 'string' - ? await Argument.cast('duration', this.client.commandHandler.resolver, message as BushMessage, reason) + ? await Argument.cast('duration', client.commandHandler.resolver, message as BushMessage, reason) : reason.duration; } const parsedReason = reason.contentWithoutTime; diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 0b10ee1..779f60d 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -75,7 +75,7 @@ export default class MuteCommand extends BushCommand { if (reason) { time = typeof reason === 'string' - ? await Argument.cast('duration', this.client.commandHandler.resolver, message as BushMessage, reason) + ? await Argument.cast('duration', client.commandHandler.resolver, message as BushMessage, reason) : reason.duration; } const parsedReason = reason.contentWithoutTime; diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 63fb3a2..fe8724d 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -95,7 +95,7 @@ export default class RoleCommand extends BushCommand { { action, user, role, duration }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration: number } ): Promise<unknown> { if (!message.member.permissions.has('MANAGE_ROLES')) { - const mappings = this.client.consts.mappings; + const mappings = client.consts.mappings; let mappedRole: { name: string; id: string }; for (let i = 0; i < mappings.roleMap.length; i++) { const a = mappings.roleMap[i]; diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 019e545..f9ffbab 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -61,7 +61,7 @@ export default class SlowModeCommand extends BushCommand { if (length) { length = typeof length === 'string' && !['off', 'none', 'disable'].includes(length) - ? await Argument.cast('duration', this.client.commandHandler.resolver, message as BushMessage, length) + ? await Argument.cast('duration', client.commandHandler.resolver, message as BushMessage, length) : length; } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 26878d9..8aa9ef0 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -53,7 +53,7 @@ export default class UnbanCommand extends BushCommand { } async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: User; reason?: string }): Promise<unknown> { if (!(user instanceof User)) { - user = util.resolveUser(user, this.client.users.cache); + user = util.resolveUser(user, client.users.cache); } const responseCode = await message.guild.unban({ user, diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index 11ef269..64dcdff 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -58,7 +58,7 @@ export default class ReportCommand extends BushCommand { } public async exec(message: BushMessage, { member, evidence }: { member: GuildMember; evidence: string }): Promise<unknown> { - if (message.guild.id != this.client.consts.mappings.guilds.bush) + if (message.guild.id != client.consts.mappings.guilds.bush) return await message.util.reply(`${util.emojis.error} This command can only be run in Moulberry's bush.`); if (!member) return await message.util.reply(`${util.emojis.error} Choose someone to report`); if (member.user.id === '322862723090219008') @@ -105,13 +105,13 @@ export default class ReportCommand extends BushCommand { reportEmbed.addField('Attachment', message.attachments.first().url); } } - const reportChannel = <TextChannel>this.client.channels.cache.get('782972723654688848'); + const reportChannel = <TextChannel>client.channels.cache.get('782972723654688848'); await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => { try { await ReportMessage.react(util.emojis.success); await ReportMessage.react(util.emojis.error); } catch { - this.client.console.warn('ReportCommand', 'Could not react to report message.'); + client.console.warn('ReportCommand', 'Could not react to report message.'); } }); return await message.util.reply('Successfully made a report.'); diff --git a/src/commands/skyblock-reborn/chooseColorCommand.ts b/src/commands/skyblock-reborn/chooseColorCommand.ts index f80d2ae..344fa60 100644 --- a/src/commands/skyblock-reborn/chooseColorCommand.ts +++ b/src/commands/skyblock-reborn/chooseColorCommand.ts @@ -120,7 +120,7 @@ export default class ChooseColorCommand extends BushCommand { } public async exec(message: BushMessage | BushSlashMessage, args: { color: Role | RoleResolvable }): Promise<unknown> { - if (message.guild.id != this.client.consts.mappings.guilds.sbr) { + if (message.guild.id != client.consts.mappings.guilds.sbr) { return await message.util.reply(`${util.emojis.error} This command can only be run in Skyblock: Reborn.`); } const allowedRoles: Snowflake[] = [ diff --git a/src/inhibitors/blacklist/channelGlobalBlacklist.ts b/src/inhibitors/blacklist/channelGlobalBlacklist.ts index 9dc5df9..0ddb2bb 100644 --- a/src/inhibitors/blacklist/channelGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/channelGlobalBlacklist.ts @@ -11,14 +11,10 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { public exec(message: BushMessage | BushSlashMessage): boolean { if (!message.author) return false; - if ( - this.client.isOwner(message.author) || - this.client.isSuperUser(message.author) || - this.client.user.id === message.author.id - ) + if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user.id === message.author.id) return false; - if (this.client.cache.global.blacklistedChannels.includes(message.channel.id)) { - this.client.console.debug(`channelGlobalBlacklist blocked message.`); + if (client.cache.global.blacklistedChannels.includes(message.channel.id)) { + client.console.debug(`channelGlobalBlacklist blocked message.`); return true; } } diff --git a/src/inhibitors/blacklist/channelGuildBlacklist.ts b/src/inhibitors/blacklist/channelGuildBlacklist.ts index cc72182..13f3644 100644 --- a/src/inhibitors/blacklist/channelGuildBlacklist.ts +++ b/src/inhibitors/blacklist/channelGuildBlacklist.ts @@ -11,14 +11,10 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { public async exec(message: BushMessage | BushSlashMessage): Promise<boolean> { if (!message.author || !message.guild) return false; - if ( - this.client.isOwner(message.author) || - this.client.isSuperUser(message.author) || - this.client.user.id === message.author.id - ) + if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedChannels'))?.includes(message.channel.id)) { - this.client.console.debug(`channelGuildBlacklist blocked message.`); + client.console.debug(`channelGuildBlacklist blocked message.`); return true; } } diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index 7d08157..0d99c38 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -13,13 +13,11 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { if (!message.guild) return false; if ( message.author && - (this.client.isOwner(message.author) || - this.client.isSuperUser(message.author) || - this.client.user.id === message.author.id) + (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user.id === message.author.id) ) return false; - if (this.client.cache.global.blacklistedGuilds.includes(message.guild.id)) { - this.client.console.debug(`GuildBlacklistInhibitor blocked message.`); + if (client.cache.global.blacklistedGuilds.includes(message.guild.id)) { + client.console.debug(`GuildBlacklistInhibitor blocked message.`); return true; } } diff --git a/src/inhibitors/blacklist/userGlobalBlacklist.ts b/src/inhibitors/blacklist/userGlobalBlacklist.ts index 061bae9..4ad1982 100644 --- a/src/inhibitors/blacklist/userGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/userGlobalBlacklist.ts @@ -11,14 +11,10 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { public exec(message: BushMessage | BushSlashMessage): boolean { if (!message.author) return false; - if ( - this.client.isOwner(message.author) || - this.client.isSuperUser(message.author) || - this.client.user.id === message.author.id - ) + if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user.id === message.author.id) return false; - if (this.client.cache.global.blacklistedUsers.includes(message.author.id)) { - this.client.console.debug(`userGlobalBlacklist blocked message.`); + if (client.cache.global.blacklistedUsers.includes(message.author.id)) { + client.console.debug(`userGlobalBlacklist blocked message.`); return true; } } diff --git a/src/inhibitors/blacklist/userGuildBlacklist.ts b/src/inhibitors/blacklist/userGuildBlacklist.ts index 02a3762..473c0fb 100644 --- a/src/inhibitors/blacklist/userGuildBlacklist.ts +++ b/src/inhibitors/blacklist/userGuildBlacklist.ts @@ -11,14 +11,10 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { public async exec(message: BushMessage | BushSlashMessage): Promise<boolean> { if (!message.author || !message.guild) return false; - if ( - this.client.isOwner(message.author) || - this.client.isSuperUser(message.author) || - this.client.user.id === message.author.id - ) + if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedUsers'))?.includes(message.author.id)) { - this.client.console.debug(`userGuildBlacklist blocked message.`); + client.console.debug(`userGuildBlacklist blocked message.`); return true; } } diff --git a/src/inhibitors/commands/globalDisabledCommand.ts b/src/inhibitors/commands/globalDisabledCommand.ts index 3ce39c2..2954393 100644 --- a/src/inhibitors/commands/globalDisabledCommand.ts +++ b/src/inhibitors/commands/globalDisabledCommand.ts @@ -11,8 +11,8 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { public async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { if (message.author.isOwner()) return false; - if (this.client.cache.global.disabledCommands?.includes(command?.id)) { - this.client.console.debug(`disabledGlobalCommand blocked message.`); + if (client.cache.global.disabledCommands?.includes(command?.id)) { + client.console.debug(`disabledGlobalCommand blocked message.`); return true; } } diff --git a/src/inhibitors/commands/guildDisabledCommand.ts b/src/inhibitors/commands/guildDisabledCommand.ts index a036ec5..d16bff7 100644 --- a/src/inhibitors/commands/guildDisabledCommand.ts +++ b/src/inhibitors/commands/guildDisabledCommand.ts @@ -14,7 +14,7 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { - this.client.console.debug(`disabledGuildCommand blocked message.`); + client.console.debug(`disabledGuildCommand blocked message.`); return true; } } diff --git a/src/inhibitors/noCache.ts b/src/inhibitors/noCache.ts index 9bddedd..d461076 100644 --- a/src/inhibitors/noCache.ts +++ b/src/inhibitors/noCache.ts @@ -10,10 +10,10 @@ export default class NoCacheInhibitor extends BushInhibitor { } public async exec(message: BushMessage | BushSlashMessage): Promise<boolean> { - if (this.client.isOwner(message.author)) return false; - for (const property in this.client.cache.global) { - if (!this.client.cache.global[property]) { - this.client.console.debug(`NoCacheInhibitor blocked message.`); + if (client.isOwner(message.author)) return false; + for (const property in client.cache.global) { + if (!client.cache.global[property]) { + client.console.debug(`NoCacheInhibitor blocked message.`); return true; } } diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index b35725d..20fb468 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -135,7 +135,7 @@ export class BushClientUtil extends ClientUtil { * @returns The list of users mapped */ public async mapIDs(ids: Snowflake[]): Promise<User[]> { - return await Promise.all(ids.map((id) => this.client.users.fetch(id))); + return await Promise.all(ids.map((id) => client.users.fetch(id))); } /** @@ -170,7 +170,7 @@ export class BushClientUtil extends ClientUtil { const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json(); return `${url}/${res.key}`; } catch { - this.client.console.error('Haste', `Unable to upload haste to ${url}`); + client.console.error('Haste', `Unable to upload haste to ${url}`); } } return 'Unable to post'; @@ -186,7 +186,7 @@ export class BushClientUtil extends ClientUtil { const idMatch = text.match(idReg); if (idMatch) { try { - return await this.client.users.fetch(text as Snowflake); + return await client.users.fetch(text as Snowflake); } catch { // pass } @@ -195,12 +195,12 @@ export class BushClientUtil extends ClientUtil { const mentionMatch = text.match(mentionReg); if (mentionMatch) { try { - return await this.client.users.fetch(mentionMatch.groups.id as Snowflake); + return await client.users.fetch(mentionMatch.groups.id as Snowflake); } catch { // pass } } - const user = this.client.users.cache.find((u) => u.username === text); + const user = client.users.cache.find((u) => u.username === text); if (user) return user; return null; } @@ -322,7 +322,7 @@ export class BushClientUtil extends ClientUtil { interaction.customId.startsWith('paginate_') && interaction.message == msg; const collector = msg.createMessageComponentCollector({ filter, time: 300000 }); collector.on('collect', async (interaction: MessageComponentInteraction) => { - if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { + if (interaction.user.id == message.author.id || client.config.owners.includes(interaction.user.id)) { switch (interaction.customId) { case 'paginate_beginning': { curPage = 0; @@ -411,7 +411,7 @@ export class BushClientUtil extends ClientUtil { const filter = (interaction: ButtonInteraction) => interaction.customId == 'paginate__stop' && interaction.message == msg; const collector = msg.createMessageComponentCollector({ filter, time: 300000 }); collector.on('collect', async (interaction: MessageComponentInteraction) => { - if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) { + if (interaction.user.id == message.author.id || client.config.owners.includes(interaction.user.id)) { await interaction.deferUpdate().catch(() => undefined); if (msg.deletable && !msg.deleted) { await msg.delete(); @@ -521,7 +521,7 @@ export class BushClientUtil extends ClientUtil { /** Gets the channel configs as a TextChannel */ public async getConfigChannel(channel: 'log' | 'error' | 'dm'): Promise<TextChannel> { - return (await this.client.channels.fetch(this.client.config.channels[channel])) as TextChannel; + return (await client.channels.fetch(client.config.channels[channel])) as TextChannel; } /** @@ -551,12 +551,12 @@ export class BushClientUtil extends ClientUtil { key: keyof typeof BushCache['global'], value: any ): Promise<Global | void> { - const row = await Global.findByPk(this.client.config.environment); + const row = await Global.findByPk(client.config.environment); const oldValue: any[] = row[key]; const newValue = this.addOrRemoveFromArray(action, oldValue, value); row[key] = newValue; - this.client.cache.global[key] = newValue; - return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e?.stack || e)); + client.cache.global[key] = newValue; + return await row.save().catch((e) => client.logger.error('insertOrRemoveFromGlobal', e?.stack || e)); } public addOrRemoveFromArray(action: 'add' | 'remove', array: any[], value: any): any[] { @@ -657,9 +657,9 @@ export class BushClientUtil extends ClientUtil { }, getCaseNumber = false ): Promise<{ log: ModLog; caseNum: number }> { - const user = this.client.users.resolveId(options.user); - const moderator = this.client.users.resolveId(options.moderator); - const guild = this.client.guilds.resolveId(options.guild); + const user = client.users.resolveId(options.user); + const moderator = client.users.resolveId(options.moderator); + const guild = client.guilds.resolveId(options.guild); const duration = options.duration || null; // If guild does not exist create it so the modlog can reference a guild. @@ -681,7 +681,7 @@ export class BushClientUtil extends ClientUtil { guild }); const saveResult: ModLog = await modLogEntry.save().catch((e) => { - this.client.console.error('createModLogEntry', e?.stack || e); + client.console.error('createModLogEntry', e?.stack || e); return null; }); @@ -700,15 +700,15 @@ export class BushClientUtil extends ClientUtil { extraInfo?: Snowflake; }): Promise<ActivePunishment> { const expires = options.duration ? new Date(new Date().getTime() + options.duration) : null; - const user = this.client.users.resolveId(options.user); - const guild = this.client.guilds.resolveId(options.guild); + const user = client.users.resolveId(options.user); + const guild = client.guilds.resolveId(options.guild); const type = this.findTypeEnum(options.type); const entry = options.extraInfo ? ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog, extraInfo: options.extraInfo }) : ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog }); return await entry.save().catch((e) => { - this.client.console.error('createPunishmentEntry', e?.stack || e); + client.console.error('createPunishmentEntry', e?.stack || e); return null; }); } @@ -718,8 +718,8 @@ export class BushClientUtil extends ClientUtil { user: BushGuildMemberResolvable; guild: BushGuildResolvable; }): Promise<boolean> { - const user = this.client.users.resolveId(options.user); - const guild = this.client.guilds.resolveId(options.guild); + const user = client.users.resolveId(options.user); + const guild = client.guilds.resolveId(options.guild); const type = this.findTypeEnum(options.type); let success = true; @@ -728,13 +728,13 @@ export class BushClientUtil extends ClientUtil { // finding all cases of a certain type incase there were duplicates or something where: { user, guild, type } }).catch((e) => { - this.client.console.error('removePunishmentEntry', e?.stack || e); + client.console.error('removePunishmentEntry', e?.stack || e); success = false; }); if (entries) { entries.forEach(async (entry) => { await entry.destroy().catch((e) => { - this.client.console.error('removePunishmentEntry', e?.stack || e); + client.console.error('removePunishmentEntry', e?.stack || e); }); success = false; }); diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index ae8f95b..f16554c 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -37,7 +37,7 @@ export class BushCommandHandler extends CommandHandler { public async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise<boolean> { if (command.ownerOnly) { - const isOwner = this.client.isOwner(message.author); + const isOwner = client.isOwner(message.author); if (!isOwner) { this.emit( slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, @@ -50,7 +50,7 @@ export class BushCommandHandler extends CommandHandler { } if (command.superUserOnly) { - const isSuperUser = this.client.isSuperUser(message.author); + const isSuperUser = client.isSuperUser(message.author); if (!isSuperUser) { this.emit( slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index 0e4891e..9d618ec 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -13,7 +13,7 @@ export class BushGuild extends Guild { public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> { return ( - this.client.cache.guilds.get(this.id)?.[setting] ?? + client.cache.guilds.get(this.id)?.[setting] ?? ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }))[setting] ); } @@ -21,7 +21,7 @@ export class BushGuild extends Guild { public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> { const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }); row[setting] = value; - this.client.cache.guilds.set(this.id, row.toJSON() as GuildDB); + client.cache.guilds.set(this.id, row.toJSON() as GuildDB); return await row.save(); } @@ -37,8 +37,8 @@ export class BushGuild extends Guild { | 'error creating modlog entry' | 'error removing ban entry' > { - const user = this.client.users.resolveId(options.user); - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator)); + const user = client.users.resolveId(options.user); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator)); const bans = await this.bans.fetch(); @@ -76,7 +76,7 @@ export class BushGuild extends Guild { .catch(() => null); if (!removePunishmentEntrySuccess) return 'error removing ban entry'; - const userObject = this.client.users.cache.get(user); + const userObject = client.users.cache.get(user); userObject?.send(`You have been unbanned from **${this}** for **${options.reason || 'No reason provided'}**.`); diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index c04c8f0..70feb90 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -80,7 +80,7 @@ export class BushGuildMember extends GuildMember { } public async warn(options: BushPunishmentOptions): Promise<{ result: WarnResponse; caseNum: number }> { - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); // add modlog entry const result = await util .createModLogEntry( @@ -94,7 +94,7 @@ export class BushGuildMember extends GuildMember { true ) .catch((e) => { - this.client.console.error('warn', e, true, 1); + client.console.error('warn', e, true, 1); return { log: null, caseNum: null }; }); if (!result || !result.log) return { result: 'error creating modlog entry', caseNum: null }; @@ -116,7 +116,7 @@ export class BushGuildMember extends GuildMember { const ifShouldAddRole = this.checkIfShouldAddRole(options.role); if (ifShouldAddRole !== true) return ifShouldAddRole; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); if (options.addToModlog) { const { log: modlog } = await util @@ -153,7 +153,7 @@ export class BushGuildMember extends GuildMember { const ifShouldAddRole = this.checkIfShouldAddRole(options.role); if (ifShouldAddRole !== true) return ifShouldAddRole; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); if (options.addToModlog) { const { log: modlog } = await util @@ -203,7 +203,7 @@ export class BushGuildMember extends GuildMember { if (!muteRole) return 'invalid mute role'; if (muteRole.position >= this.guild.me.roles.highest.position || muteRole.managed) return 'mute role not manageable'; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); // add role const muteSuccess = await this.roles @@ -258,7 +258,7 @@ export class BushGuildMember extends GuildMember { if (!muteRole) return 'invalid mute role'; if (muteRole.position >= this.guild.me.roles.highest.position || muteRole.managed) return 'mute role not manageable'; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); //remove role const muteSuccess = await this.roles @@ -302,7 +302,7 @@ export class BushGuildMember extends GuildMember { // checks if (!this.guild.me.permissions.has('KICK_MEMBERS') || !this.kickable) return 'missing permissions'; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); // dm user const ending = await this.guild.getSetting('punishmentEnding'); @@ -335,7 +335,7 @@ export class BushGuildMember extends GuildMember { // checks if (!this.guild.me.permissions.has('BAN_MEMBERS') || !this.bannable) return 'missing permissions'; - const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user)); + const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user)); // dm user const ending = await this.guild.getSetting('punishmentEnding'); @@ -382,10 +382,10 @@ export class BushGuildMember extends GuildMember { } public get isOwner(): boolean { - return this.client.isOwner(this); + return client.isOwner(this); } public get isSuperUser(): boolean { - return this.client.isSuperUser(this); + return client.isSuperUser(this); } } diff --git a/src/lib/extensions/discord.js/BushMessage.ts b/src/lib/extensions/discord.js/BushMessage.ts index d4b47c6..68f3de0 100644 --- a/src/lib/extensions/discord.js/BushMessage.ts +++ b/src/lib/extensions/discord.js/BushMessage.ts @@ -21,6 +21,6 @@ export class BushMessage extends Message { channel: BushTextChannel | BushDMChannel | BushNewsChannel | BushThreadChannel ) { super(client, data, channel); - // this.util = new BushCommandUtil(this.client.commandHandler, this); + // this.util = new BushCommandUtil(client.commandHandler, this); } } diff --git a/src/lib/extensions/discord.js/BushUser.ts b/src/lib/extensions/discord.js/BushUser.ts index 53a6be3..54a67b5 100644 --- a/src/lib/extensions/discord.js/BushUser.ts +++ b/src/lib/extensions/discord.js/BushUser.ts @@ -10,10 +10,10 @@ export class BushUser extends User { } public isOwner(): boolean { - return this.client.isOwner(this); + return client.isOwner(this); } public isSuperUser(): boolean { - return this.client.isSuperUser(this); + return client.isSuperUser(this); } } diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 3069dc8..d0c482f 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -8,7 +8,7 @@ import { BushClient, BushSendMessageType } from '../extensions/discord-akairo/Bu export class BushLogger { private client: BushClient; public constructor(client: BushClient) { - this.client = client; + client = client; } private parseFormatting( @@ -86,7 +86,7 @@ export class BushLogger { * @param depth - The depth the content will inspected. Defaults to 0. */ public debug(content: any, depth = 0): void { - if (!this.client.config.isDevelopment) return; + if (!client.config.isDevelopment) return; const newContent = this.inspectContent(content, depth, true); console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, newContent); } @@ -96,7 +96,7 @@ export class BushLogger { * @param content - The content to log. */ public debugRaw(...content: any): void { - if (!this.client.config.isDevelopment) return; + if (!client.config.isDevelopment) return; console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, ...content); } @@ -108,7 +108,7 @@ export class BushLogger { * @param depth - The depth the content will inspected. Defaults to 0. */ public async verbose(header: string, content: any, sendChannel = false, depth = 0): Promise<void> { - if (!this.client.config.logging.verbose) return; + if (!client.config.logging.verbose) return; const newContent = this.inspectContent(content, depth, true); console.info( `${chalk.bgGrey(this.getTimeStamp())} ${chalk.grey(`[${header}]`)} ` + this.parseFormatting(newContent, 'blackBright') @@ -129,7 +129,7 @@ export class BushLogger { * @param depth - The depth the content will inspected. Defaults to 0. */ public async info(header: string, content: any, sendChannel = true, depth = 0): Promise<void> { - if (!this.client.config.logging.info) return; + if (!client.config.logging.info) return; const newContent = this.inspectContent(content, depth, true); console.info( `${chalk.bgCyan(this.getTimeStamp())} ${chalk.cyan(`[${header}]`)} ` + this.parseFormatting(newContent, 'blueBright') diff --git a/src/listeners/client/interactionCreate.ts b/src/listeners/client/interactionCreate.ts index 77912d6..41905f7 100644 --- a/src/listeners/client/interactionCreate.ts +++ b/src/listeners/client/interactionCreate.ts @@ -13,7 +13,7 @@ export default class InteractionCreateListener extends BushListener { async exec(...[interaction]: ClientEvents['interactionCreate']): Promise<unknown> { if (!interaction) return; if (interaction.isCommand()) { - this.client.console.info( + client.console.info( 'SlashCommand', `The <<${interaction.commandName}>> command was used by <<${interaction.user.tag}>> in <<${ interaction.channel.type == 'DM' ? interaction.channel.recipient + 's DMs' : interaction.channel.name diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts index b5d0e25..9c04aea 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -10,15 +10,15 @@ export default class ReadyListener extends BushListener { } public async exec(): Promise<void> { - const tag = `<<${this.client.user.tag}>>`, - guildCount = `<<${this.client.guilds.cache.size.toLocaleString()}>>`, - userCount = `<<${this.client.users.cache.size.toLocaleString()}>>`; + const tag = `<<${client.user.tag}>>`, + guildCount = `<<${client.guilds.cache.size.toLocaleString()}>>`, + userCount = `<<${client.users.cache.size.toLocaleString()}>>`; - this.client.logger.success('Ready', `Logged in to ${tag} serving ${guildCount} guilds and ${userCount} users.`); + client.logger.success('Ready', `Logged in to ${tag} serving ${guildCount} guilds and ${userCount} users.`); console.log( chalk.blue( `------------------------------------------------------------------------------${ - this.client.config.isDevelopment ? '---' : this.client.config.isBeta ? '----' : '' + client.config.isDevelopment ? '---' : client.config.isBeta ? '----' : '' }` ) ); diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index e495f52..d33721e 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -9,12 +9,12 @@ export default class CommandBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']): Promise<unknown> { - this.client.console.info( + client.console.info( 'CommandBlocked', `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, true ); - const reasons = this.client.consts.BlockedReasons; + const reasons = client.consts.BlockedReasons; switch (reason) { case reasons.OWNER: { @@ -59,7 +59,7 @@ export default class CommandBlockedListener extends BushListener { const guilds = command.restrictedGuilds; const names = []; guilds.forEach((g) => { - names.push(`\`${this.client.guilds.cache.get(g).name}\``); + names.push(`\`${client.guilds.cache.get(g).name}\``); }); const pretty = util.oxford(names, 'and', undefined); return await message.util.reply({ diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index c34f52a..62906ab 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -24,9 +24,9 @@ export default class CommandErrorListener extends BushListener { .setColor(util.colors.error) .setTimestamp(); - await this.client.logger.channelError({ embeds: [errorEmbed] }); + await client.logger.channelError({ embeds: [errorEmbed] }); if (message) { - if (!this.client.config.owners.includes(message.author.id)) { + if (!client.config.owners.includes(message.author.id)) { const errorUserEmbed: MessageEmbed = new MessageEmbed() .setTitle('A Command Error Occurred') .setColor(util.colors.error) @@ -39,8 +39,8 @@ export default class CommandErrorListener extends BushListener { ); (await message.util?.send({ embeds: [errorUserEmbed] }).catch((e) => { const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; - this.client.console.warn('CommandError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); - })) ?? this.client.console.error('CommandError', `Failed to send user error embed.` + error?.stack || error, false); + client.console.warn('CommandError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); + })) ?? client.console.error('CommandError', `Failed to send user error embed.` + error?.stack || error, false); } else { const errorDevEmbed = new MessageEmbed() .setTitle('A Command Error Occurred') @@ -49,12 +49,12 @@ export default class CommandErrorListener extends BushListener { .setDescription(await util.codeblock(`${error?.stack || error}`, 2048, 'js')); (await message.util?.send({ embeds: [errorDevEmbed] }).catch((e) => { const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; - this.client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); - })) ?? this.client.console.error('CommandError', `Failed to send owner error stack.` + error?.stack || error, false); + client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); + })) ?? client.console.error('CommandError', `Failed to send owner error stack.` + error?.stack || error, false); } } const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; - this.client.console.error( + client.console.error( 'CommandError', `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + error?.stack || error, diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts index 1df54ab..ef1205b 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -12,8 +12,8 @@ export default class CommandMissingPermissionsListener extends BushListener { public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']): Promise<void> { const niceMissing = []; missing.forEach((missing) => { - if (this.client.consts.mappings.permissions[missing]) { - niceMissing.push(this.client.consts.mappings.permissions[missing].name); + if (client.consts.mappings.permissions[missing]) { + niceMissing.push(client.consts.mappings.permissions[missing].name); } else { niceMissing.push(missing); } @@ -21,7 +21,7 @@ export default class CommandMissingPermissionsListener extends BushListener { const discordFormat = util.oxford(util.surroundArray(niceMissing, '**'), 'and', ''); const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', ''); - this.client.console.info( + client.console.info( 'CommandMissingPermissions', `<<${message.author.tag}>> tried to run <<${ command?.id diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts index 421da02..b9aaf53 100644 --- a/src/listeners/commands/commandStarted.ts +++ b/src/listeners/commands/commandStarted.ts @@ -9,7 +9,7 @@ export default class CommandStartedListener extends BushListener { }); } exec(...[message, command]: BushCommandHandlerEvents['commandStarted']): void { - this.client.logger.info( + client.logger.info( 'Command', `The <<${command.id}>> command was used by <<${message.author.tag}>> in ${ message.channel.type === 'DM' ? `their <<DMs>>` : `<<#${message.channel.name}>> in <<${message.guild?.name}>>` diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index 7c26fb5..b65dac4 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -10,13 +10,13 @@ export default class SlashBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']): Promise<unknown> { - this.client.console.info( + client.console.info( 'SlashBlocked', `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, true ); - const reasons = this.client.consts.BlockedReasons; + const reasons = client.consts.BlockedReasons; switch (reason) { case reasons.OWNER: { @@ -61,7 +61,7 @@ export default class SlashBlockedListener extends BushListener { const guilds = command.restrictedGuilds; const names = []; guilds.forEach((g) => { - names.push(`\`${this.client.guilds.cache.get(g).name}\``); + names.push(`\`${client.guilds.cache.get(g).name}\``); }); const pretty = util.oxford(names, 'and', undefined); return await message.util.reply({ diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index c66076d..41f941c 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -24,10 +24,10 @@ export default class SlashCommandErrorListener extends BushListener { .setColor(util.colors.error) .setTimestamp(); - await this.client.logger.channelError({ embeds: [errorEmbed] }); + await client.logger.channelError({ embeds: [errorEmbed] }); if (message) { const channel = (message.channel as GuildChannel)?.name || message.interaction.user.tag; - if (!this.client.config.owners.includes(message.author.id)) { + if (!client.config.owners.includes(message.author.id)) { const errorUserEmbed: MessageEmbed = new MessageEmbed() .setTitle('A Slash Command Error Occurred') .setColor(util.colors.error) @@ -39,8 +39,8 @@ export default class SlashCommandErrorListener extends BushListener { `Oh no! While running the command \`${command.id}\`, an error occurred. Please give the developers code \`${errorNo}\`.` ); (await message.util?.send({ embeds: [errorUserEmbed] }).catch((e) => { - this.client.console.warn('SlashError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); - })) ?? this.client.console.error('SlashError', `Failed to send user error embed.` + error?.stack || error, false); + client.console.warn('SlashError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); + })) ?? client.console.error('SlashError', `Failed to send user error embed.` + error?.stack || error, false); } else { const errorDevEmbed = new MessageEmbed() .setTitle('A Slash Command Error Occurred') @@ -48,12 +48,12 @@ export default class SlashCommandErrorListener extends BushListener { .setTimestamp() .setDescription(await util.codeblock(`${error?.stack || error}`, 2048, 'js')); (await message.util?.send({ embeds: [errorDevEmbed] }).catch((e) => { - this.client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); - })) ?? this.client.console.error('SlashError', `Failed to send user error embed.` + error?.stack || error, false); + client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); + })) ?? client.console.error('SlashError', `Failed to send user error embed.` + error?.stack || error, false); } } const channel = (message.channel as GuildChannel)?.name || message.interaction.user.tag; - this.client.console.error( + client.console.error( 'SlashError', `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + error?.stack || error, diff --git a/src/listeners/commands/slashMissingPermissions.ts b/src/listeners/commands/slashMissingPermissions.ts index 34786e1..aa2bc50 100644 --- a/src/listeners/commands/slashMissingPermissions.ts +++ b/src/listeners/commands/slashMissingPermissions.ts @@ -12,8 +12,8 @@ export default class SlashMissingPermissionsListener extends BushListener { public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions']): Promise<void> { const niceMissing = []; missing.forEach((missing) => { - if (this.client.consts.mappings.permissions[missing]) { - niceMissing.push(this.client.consts.mappings.permissions[missing].name); + if (client.consts.mappings.permissions[missing]) { + niceMissing.push(client.consts.mappings.permissions[missing].name); } else { niceMissing.push(missing); } @@ -21,7 +21,7 @@ export default class SlashMissingPermissionsListener extends BushListener { const discordFormat = util.oxford(util.surroundArray(niceMissing, '`'), 'and', ''); const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', ''); - this.client.console.info( + client.console.info( 'CommandMissingPermissions', `<<${message.author.tag}>> tried to run <<${ command?.id diff --git a/src/listeners/commands/slashStarted.ts b/src/listeners/commands/slashStarted.ts index 2a89b03..1b0590f 100644 --- a/src/listeners/commands/slashStarted.ts +++ b/src/listeners/commands/slashStarted.ts @@ -9,7 +9,7 @@ export default class SlashStartedListener extends BushListener { }); } async exec(...[message, command]: BushCommandHandlerEvents['slashStarted']): Promise<unknown> { - return await this.client.logger.info( + return await client.logger.info( 'SlashCommand', `The <<${command.id}>> command was used by <<${message.author.tag}>> in ${ message.channel.type === 'DM' ? `their <<DMs>>` : `<<#${message.channel.name}>> in <<${message.guild?.name}>>` diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index 1ff098e..b3bd08c 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -37,11 +37,11 @@ export default class LevelListener extends BushListener { console.debug(`User: ${message.author.id}`); console.debug(`Guild: ${message.author.id}`); console.debug(`Model: ${user}`); - this.client.logger.error('LevelMessageListener', e?.stack || e); + client.logger.error('LevelMessageListener', e?.stack || e); return false; }); if (success) - this.client.logger.verbose( + client.logger.verbose( `LevelMessageListener`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.` ); diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts index 8bd834f..b6f53d8 100644 --- a/src/listeners/other/consoleListener.ts +++ b/src/listeners/other/consoleListener.ts @@ -15,9 +15,9 @@ export default class ConsoleListener extends BushListener { public async exec(line: string): Promise<void> { if (line.startsWith('eval ') || line.startsWith('ev ')) { const sh = promisify(exec), - bot = this.client, - config = this.client.config, - client = this.client, + bot = client, + config = client.config, + client = client, { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('@lib'), { ButtonInteraction, diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index da6480c..204e43a 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -9,8 +9,8 @@ export default class PromiseRejectionListener extends BushListener { } public async exec(error: Error): Promise<void> { - this.client.console.error('PromiseRejection', `An unhanded promise rejection occurred:\n${error?.stack || error}`, false); - this.client.console.channelError({ + client.console.error('PromiseRejection', `An unhanded promise rejection occurred:\n${error?.stack || error}`, false); + client.console.channelError({ embeds: [ { title: 'Unhandled promise rejection', diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index 1bb57c1..651fefe 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -9,8 +9,8 @@ export default class UncaughtExceptionListener extends BushListener { } public async exec(error: Error): Promise<void> { - this.client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack || error}`, false); - this.client.console.channelError({ + client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack || error}`, false); + client.console.channelError({ embeds: [ { title: 'An uncaught exception occurred', diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts index d0220ba..0a6e417 100644 --- a/src/tasks/removeExpiredPunishements.ts +++ b/src/tasks/removeExpiredPunishements.ts @@ -22,13 +22,13 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { } }); - this.client.logger.verbose( + client.logger.verbose( `removeExpiredPunishments`, `Queried punishments, found <<${expiredEntries.length}>> expired punishments.` ); for (const entry of expiredEntries) { - const guild = this.client.guilds.cache.get(entry.guild) as BushGuild; + const guild = client.guilds.cache.get(entry.guild) as BushGuild; const member = guild.members.cache.get(entry.user) as BushGuildMember; if (!guild) { @@ -41,7 +41,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { const result = await guild.unban({ user: entry.user, reason: 'Punishment expired.' }); if (['success', 'user not banned'].includes(result)) await entry.destroy(); else throw result; - this.client.logger.verbose(`removeExpiredPunishments`, `Unbanned ${entry.user}.`); + client.logger.verbose(`removeExpiredPunishments`, `Unbanned ${entry.user}.`); break; } case ActivePunishmentType.BLOCK: { @@ -52,7 +52,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { const result = await member.unmute({ reason: 'Punishment expired.' }); if (['success', 'failed to dm'].includes(result)) await entry.destroy(); else throw result; - this.client.logger.verbose(`removeExpiredPunishments`, `Unmuted ${entry.user}.`); + client.logger.verbose(`removeExpiredPunishments`, `Unmuted ${entry.user}.`); break; } case ActivePunishmentType.ROLE: { @@ -65,7 +65,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask { if (['success', 'failed to dm'].includes(result)) await entry.destroy(); else throw result; - this.client.logger.verbose(`removeExpiredPunishments`, `Removed a punishment role from ${entry.user}.`); + client.logger.verbose(`removeExpiredPunishments`, `Removed a punishment role from ${entry.user}.`); break; } } diff --git a/src/tasks/updateCache.ts b/src/tasks/updateCache.ts index 404173b..721b2db 100644 --- a/src/tasks/updateCache.ts +++ b/src/tasks/updateCache.ts @@ -12,9 +12,9 @@ export class UpdateCacheTask extends BushTask { }); } public async exec(): Promise<void> { - await UpdateCacheTask.updateGlobalCache(this.client); - await UpdateCacheTask.updateGuildCache(this.client); - await this.client.logger.verbose(`UpdateCache`, `Updated cache.`); + await UpdateCacheTask.updateGlobalCache(client); + await UpdateCacheTask.updateGuildCache(client); + await client.logger.verbose(`UpdateCache`, `Updated cache.`); } public static async init(client: BushClient): Promise<void> { |