diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:47:13 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-26 18:47:13 -0400 |
commit | 80d5b5b11ae261945dc725a0a80115922003afcf (patch) | |
tree | 16c9f251b4d53456b4b5340c0203d35fd5870859 /src/listeners/commands | |
parent | cca0b7a03bcd61af12b7f9bff51276f6c70beeb3 (diff) | |
download | tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.gz tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.bz2 tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.zip |
refactor: this.client -> client
Diffstat (limited to 'src/listeners/commands')
-rw-r--r-- | src/listeners/commands/commandBlocked.ts | 6 | ||||
-rw-r--r-- | src/listeners/commands/commandError.ts | 14 | ||||
-rw-r--r-- | src/listeners/commands/commandMissingPermissions.ts | 6 | ||||
-rw-r--r-- | src/listeners/commands/commandStarted.ts | 2 | ||||
-rw-r--r-- | src/listeners/commands/slashBlocked.ts | 6 | ||||
-rw-r--r-- | src/listeners/commands/slashCommandError.ts | 14 | ||||
-rw-r--r-- | src/listeners/commands/slashMissingPermissions.ts | 6 | ||||
-rw-r--r-- | src/listeners/commands/slashStarted.ts | 2 |
8 files changed, 28 insertions, 28 deletions
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}>>` |