From 7990abdb511eeec2a114b124a3628b10bfefc342 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 26 Jul 2021 22:53:27 -0400 Subject: chore: add new eslint rule --- src/listeners/client/interactionCreate.ts | 2 +- src/listeners/client/ready.ts | 2 +- src/listeners/commands/commandBlocked.ts | 2 +- src/listeners/commands/commandError.ts | 6 +++--- src/listeners/commands/commandMissingPermissions.ts | 2 +- src/listeners/commands/commandStarted.ts | 2 +- src/listeners/commands/slashBlocked.ts | 2 +- src/listeners/commands/slashCommandError.ts | 6 +++--- src/listeners/commands/slashMissingPermissions.ts | 2 +- src/listeners/commands/slashStarted.ts | 2 +- src/listeners/message/level.ts | 10 +++------- src/listeners/other/promiseRejection.ts | 4 ++-- src/listeners/other/uncaughtException.ts | 4 ++-- 13 files changed, 21 insertions(+), 25 deletions(-) (limited to 'src/listeners') diff --git a/src/listeners/client/interactionCreate.ts b/src/listeners/client/interactionCreate.ts index 41905f7..b0d1786 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 { if (!interaction) return; if (interaction.isCommand()) { - client.console.info( + void 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 9c04aea..449ec42 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -14,7 +14,7 @@ export default class ReadyListener extends BushListener { guildCount = `<<${client.guilds.cache.size.toLocaleString()}>>`, userCount = `<<${client.users.cache.size.toLocaleString()}>>`; - client.logger.success('Ready', `Logged in to ${tag} serving ${guildCount} guilds and ${userCount} users.`); + void client.logger.success('Ready', `Logged in to ${tag} serving ${guildCount} guilds and ${userCount} users.`); console.log( chalk.blue( `------------------------------------------------------------------------------${ diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index d33721e..526977b 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -9,7 +9,7 @@ export default class CommandBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']): Promise { - client.console.info( + void client.console.info( 'CommandBlocked', `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, true diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 62906ab..c287656 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -39,7 +39,7 @@ 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; - client.console.warn('CommandError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); + void 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() @@ -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; - client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); + void 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; - client.console.error( + void 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 ef1205b..3ada70f 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -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', ''); - client.console.info( + void 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 b9aaf53..bccb500 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 { - client.logger.info( + void client.logger.info( 'Command', `The <<${command.id}>> command was used by <<${message.author.tag}>> in ${ message.channel.type === 'DM' ? `their <>` : `<<#${message.channel.name}>> in <<${message.guild?.name}>>` diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index b65dac4..f79cec3 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -10,7 +10,7 @@ export default class SlashBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']): Promise { - client.console.info( + void client.console.info( 'SlashBlocked', `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, true diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index 41f941c..a108151 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -39,7 +39,7 @@ 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) => { - client.console.warn('SlashError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); + void 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() @@ -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) => { - client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); + void 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; - client.console.error( + void 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 aa2bc50..70ed7c2 100644 --- a/src/listeners/commands/slashMissingPermissions.ts +++ b/src/listeners/commands/slashMissingPermissions.ts @@ -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', ''); - client.console.info( + void 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 1b0590f..dbb0c0d 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 { - return await client.logger.info( + return void client.logger.info( 'SlashCommand', `The <<${command.id}>> command was used by <<${message.author.tag}>> in ${ message.channel.type === 'DM' ? `their <>` : `<<#${message.channel.name}>> in <<${message.guild?.name}>>` diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index b3bd08c..e8edfcf 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -32,16 +32,12 @@ export default class LevelListener extends BushListener { } }); const xpToGive = Level.genRandomizedXp(); - user.increment('xp', { by: xpToGive }); - const success = await user.save().catch((e) => { - console.debug(`User: ${message.author.id}`); - console.debug(`Guild: ${message.author.id}`); - console.debug(`Model: ${user}`); - client.logger.error('LevelMessageListener', e?.stack || e); + const success = await user.increment('xp', { by: xpToGive }).catch((e) => { + void client.logger.error('LevelMessageListener', e?.stack || e); return false; }); if (success) - client.logger.verbose( + void client.logger.verbose( `LevelMessageListener`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.` ); diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 204e43a..e0a62c0 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 { - client.console.error('PromiseRejection', `An unhanded promise rejection occurred:\n${error?.stack || error}`, false); - client.console.channelError({ + void client.console.error('PromiseRejection', `An unhanded promise rejection occurred:\n${error?.stack || error}`, false); + void client.console.channelError({ embeds: [ { title: 'Unhandled promise rejection', diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index 651fefe..f1714f7 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 { - client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack || error}`, false); - client.console.channelError({ + void client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack || error}`, false); + void client.console.channelError({ embeds: [ { title: 'An uncaught exception occurred', -- cgit