diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-30 13:04:24 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-30 13:04:24 -0400 |
commit | f5c2b7b946487c2828365cc63bc6f471dd6cfc2f (patch) | |
tree | b225533c2858105b85ba118588954d9cb1ee9781 /src/listeners | |
parent | 1c6d451ffd63f9805b978e8565807e8a6b528681 (diff) | |
download | tanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.tar.gz tanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.tar.bz2 tanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.zip |
clean up and fix stuff
Diffstat (limited to 'src/listeners')
-rw-r--r-- | src/listeners/commands/commandBlocked.ts | 48 | ||||
-rw-r--r-- | src/listeners/commands/commandError.ts | 53 | ||||
-rw-r--r-- | src/listeners/commands/commandMissingPermissions.ts | 14 | ||||
-rw-r--r-- | src/listeners/commands/slashBlocked.ts | 66 | ||||
-rw-r--r-- | src/listeners/commands/slashCommandError.ts | 52 | ||||
-rw-r--r-- | src/listeners/commands/slashMissingPermissions.ts | 41 | ||||
-rw-r--r-- | src/listeners/message/automodCreate.ts | 95 | ||||
-rw-r--r-- | src/listeners/message/automodUpdate.ts | 10 | ||||
-rw-r--r-- | src/listeners/other/consoleListener.ts | 3 |
9 files changed, 190 insertions, 192 deletions
diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index 526977b..095ce58 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -1,4 +1,4 @@ -import { BushCommandHandlerEvents, BushListener } from '@lib'; +import { BushCommandHandlerEvents, BushListener, BushMessage } from '@lib'; export default class CommandBlockedListener extends BushListener { public constructor() { @@ -9,9 +9,17 @@ export default class CommandBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']): Promise<unknown> { + return await CommandBlockedListener.handleBlocked(message, command, reason); + } + + public static async handleBlocked( + ...[message, command, reason]: BushCommandHandlerEvents['commandBlocked'] | BushCommandHandlerEvents['slashBlocked'] + ): Promise<unknown> { + const isSlash = message.util.isSlash; + void client.console.info( - 'CommandBlocked', - `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, + `${isSlash ? 'Slash' : 'Command'}Blocked`, + `<<${message.author.tag}>> tried to run <<${command}>> but was blocked because <<${reason}>>.`, true ); const reasons = client.consts.BlockedReasons; @@ -19,30 +27,45 @@ export default class CommandBlockedListener extends BushListener { switch (reason) { case reasons.OWNER: { return await message.util.reply({ - content: `${util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.` + content: `${util.emojis.error} Only my developers can run the \`${command}\` command.`, + ephemeral: true }); } case reasons.SUPER_USER: { return await message.util.reply({ - content: `${util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.` + content: `${util.emojis.error} You must be a superuser to run the \`${command}\` command.`, + ephemeral: true }); } case reasons.DISABLED_GLOBAL: { return await message.util.reply({ - content: `${util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.` + content: `${util.emojis.error} My developers disabled the \`${command}\` command.`, + ephemeral: true }); } case reasons.DISABLED_GUILD: { return await message.util.reply({ - content: `${util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.` + content: `${util.emojis.error} The \`${command}\` command is currently disabled in \`${message.guild.name}\`.`, + ephemeral: true }); } case reasons.CHANNEL_GLOBAL_BLACKLIST: case reasons.CHANNEL_GUILD_BLACKLIST: + return isSlash + ? message.util.reply({ content: `${util.emojis.error} You cannot use this bot in this channel.`, ephemeral: true }) + : (message as BushMessage).react(util.emojis.error); case reasons.USER_GLOBAL_BLACKLIST: case reasons.USER_GUILD_BLACKLIST: + return isSlash + ? message.util.reply({ content: `${util.emojis.error} You are blacklisted from using this bot.`, ephemeral: true }) + : (message as BushMessage).react(util.emojis.error); case reasons.ROLE_BLACKLIST: { - return; + return isSlash + ? message.util.reply({ + content: `${util.emojis.error} One of your roles blacklists you from using this bot.`, + ephemeral: true + }) + : (message as BushMessage).react(util.emojis.error); } case reasons.RESTRICTED_CHANNEL: { const channels = command.restrictedChannels; @@ -52,7 +75,8 @@ export default class CommandBlockedListener extends BushListener { }); const pretty = util.oxford(names, 'and', undefined); return await message.util.reply({ - content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.` + content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`, + ephemeral: true }); } case reasons.RESTRICTED_GUILD: { @@ -63,12 +87,14 @@ export default class CommandBlockedListener extends BushListener { }); const pretty = util.oxford(names, 'and', undefined); return await message.util.reply({ - content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.` + content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`, + ephemeral: true }); } default: { return await message.util.reply({ - content: `${util.emojis.error} Command blocked with reason \`${reason}\`` + content: `${util.emojis.error} Command blocked with reason \`${reason}\``, + ephemeral: true }); } } diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index c287656..0525fe6 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -1,5 +1,4 @@ import { BushCommandHandlerEvents, BushListener } from '@lib'; -import { stripIndents } from 'common-tags'; import { MessageEmbed } from 'discord.js'; export default class CommandErrorListener extends BushListener { @@ -10,21 +9,33 @@ export default class CommandErrorListener extends BushListener { }); } - public async exec(...[error, message, command]: BushCommandHandlerEvents['error']): Promise<void> { + public async exec(...[error, message, command]: BushCommandHandlerEvents['error']): Promise<unknown> { + return await CommandErrorListener.handleError(error, message, command); + } + + public static async handleError( + ...[error, message, command]: BushCommandHandlerEvents['error'] | BushCommandHandlerEvents['slashError'] + ): Promise<void> { + const isSlash = message.util.isSlash; + const errorNo = Math.floor(Math.random() * 6969696969) + 69; // hehe funny number const errorEmbed: MessageEmbed = new MessageEmbed() - .setTitle(`Error # \`${errorNo}\`: An error occurred`) - .setDescription( - stripIndents`**User:** ${message.author} (${message.author.tag}) - **Command:** ${command} - **Channel:** ${message.channel} (${message.channel?.id}) - **Message:** [link](${message.url})` - ) + .setTitle(`${isSlash ? 'Slash ' : ''}Error # \`${errorNo}\`: An error occurred`) .addField('Error', await util.codeblock(`${error?.stack || error}`, 1024, 'js')) .setColor(util.colors.error) .setTimestamp(); - + const description = [ + `**User:** ${message.author} (${message.author.tag})`, + `**Command:** ${command}`, + `**Channel:** ${message.channel} (${message.channel?.id})`, + `**Message:** [link](${message.url})` + ]; + // @ts-ignore: shut + if (error?.code) description.push(`**Error Code:** \`${error.code}\``); + if (message?.util?.parsed?.content) description.push(`**Command Content:** ${message.util.parsed.content}`); + errorEmbed.setDescription(description.join('\n')); await client.logger.channelError({ embeds: [errorEmbed] }); + const heading = `${isSlash ? 'Slash' : 'Command'}Error`; if (message) { if (!client.config.owners.includes(message.author.id)) { const errorUserEmbed: MessageEmbed = new MessageEmbed() @@ -35,29 +46,33 @@ export default class CommandErrorListener extends BushListener { errorUserEmbed.setDescription(`Oh no! An error occurred. Please give the developers code \`${errorNo}\`.`); else errorUserEmbed.setDescription( - `Oh no! While running the command \`${command.id}\`, an error occurred. Please give the developers code \`${errorNo}\`.` + `Oh no! While running the ${isSlash ? 'slash ' : ''}command \`${ + command.id + }\`, an error occurred. Please give the developers code \`${errorNo}\`.` ); (await message.util?.send({ embeds: [errorUserEmbed] }).catch((e) => { const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; - 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); + void client.console.warn(heading, `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e); + })) ?? client.console.error(heading, `Failed to send user error embed.` + error?.stack || error, false); } else { const errorDevEmbed = new MessageEmbed() - .setTitle('A Command Error Occurred') + // @ts-ignore: shut + .setTitle(`A Command Error Occurred ${error?.code ? `\`${error.code}\`` : ''}`) .setColor(util.colors.error) .setTimestamp() .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; - 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); + void client.console.warn(heading, `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e); + })) ?? client.console.error(heading, `Failed to send owner error stack.` + error?.stack || error, false); } } const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; void client.console.error( - 'CommandError', - `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + - error?.stack || error, + heading, + `an error occurred with the <<${command}>> ${isSlash ? 'slash ' : ''}command in <<${channel}>> triggered by <<${ + message?.author?.tag + }>>:\n` + error?.stack || error, false ); } diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts index 3ada70f..70adcd1 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -9,7 +9,15 @@ export default class CommandMissingPermissionsListener extends BushListener { }); } - public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']): Promise<void> { + public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']): Promise<unknown> { + return await CommandMissingPermissionsListener.handleMissing(message, command, type, missing); + } + + public static async handleMissing( + ...[message, command, type, missing]: + | BushCommandHandlerEvents['missingPermissions'] + | BushCommandHandlerEvents['slashMissingPermissions'] + ): Promise<unknown> { const niceMissing = []; missing.forEach((missing) => { if (client.consts.mappings.permissions[missing]) { @@ -28,7 +36,7 @@ export default class CommandMissingPermissionsListener extends BushListener { }>> but could not because <<${type}>> is missing the ${consoleFormat} permissions${missing.length ? 's' : ''}.` ); if (type == 'client') { - await message.util + return await message.util .reply( `${util.emojis.error} I am missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the \`${ command?.id @@ -36,7 +44,7 @@ export default class CommandMissingPermissionsListener extends BushListener { ) .catch(() => {}); } else if (type == 'user') { - await message.util + return await message.util .reply( `${util.emojis.error} You are missing the ${discordFormat} permission${ missing.length ? 's' : '' diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index f79cec3..bdad2ea 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -1,4 +1,5 @@ import { BushCommandHandlerEvents, BushListener } from '@lib'; +import CommandBlockedListener from './commandBlocked'; export default class SlashBlockedListener extends BushListener { public constructor() { @@ -10,69 +11,6 @@ export default class SlashBlockedListener extends BushListener { } public async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']): Promise<unknown> { - void client.console.info( - 'SlashBlocked', - `<<${message.author.tag}>> tried to run <<${message.util.parsed.command}>> but was blocked because <<${reason}>>.`, - true - ); - - const reasons = client.consts.BlockedReasons; - - switch (reason) { - case reasons.OWNER: { - return await message.util.reply({ - content: `${util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.` - }); - } - case reasons.SUPER_USER: { - return await message.util.reply({ - content: `${util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.` - }); - } - case reasons.DISABLED_GLOBAL: { - return await message.util.reply({ - content: `${util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.` - }); - } - case reasons.DISABLED_GUILD: { - return await message.util.reply({ - content: `${util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.` - }); - } - case reasons.CHANNEL_GLOBAL_BLACKLIST: - case reasons.CHANNEL_GUILD_BLACKLIST: - case reasons.USER_GLOBAL_BLACKLIST: - case reasons.USER_GUILD_BLACKLIST: - case reasons.ROLE_BLACKLIST: { - return; - } - case reasons.RESTRICTED_CHANNEL: { - const channels = command.restrictedChannels; - const names = []; - channels.forEach((c) => { - names.push(`<#${c}>`); - }); - const pretty = util.oxford(names, 'and', undefined); - return await message.util.reply({ - content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.` - }); - } - case reasons.RESTRICTED_GUILD: { - const guilds = command.restrictedGuilds; - const names = []; - guilds.forEach((g) => { - names.push(`\`${client.guilds.cache.get(g).name}\``); - }); - const pretty = util.oxford(names, 'and', undefined); - return await message.util.reply({ - content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.` - }); - } - default: { - return await message.util.reply({ - content: `${util.emojis.error} Command blocked with reason \`${reason}\`` - }); - } - } + return await CommandBlockedListener.handleBlocked(message, command, reason); } } diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index a108151..67febfd 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -1,6 +1,5 @@ import { BushCommandHandlerEvents, BushListener } from '@lib'; -import { stripIndents } from 'common-tags'; -import { GuildChannel, MessageEmbed } from 'discord.js'; +import CommandErrorListener from './commandError'; export default class SlashCommandErrorListener extends BushListener { public constructor() { @@ -11,53 +10,6 @@ export default class SlashCommandErrorListener extends BushListener { }); } async exec(...[error, message, command]: BushCommandHandlerEvents['slashError']): Promise<void> { - const errorNo = Math.floor(Math.random() * 6969696969) + 69; // hehe funny number - const errorEmbed: MessageEmbed = new MessageEmbed() - .setTitle(`Slash Error # \`${errorNo}\`: An error occurred`) - .setDescription( - stripIndents`**User:** ${message.author} (${message.author.tag}) - **Slash Command:** ${command} - **Channel:** ${message.channel || message.interaction.user?.tag} ${message.channel ? `(${message.channel?.id})` : ''} - **Message:** [link](https://discord.com/${message.guild?.id}/${message.channel?.id}/${message.id})` - ) - .addField('Error', await util.codeblock(`${error?.stack || error}`, 1024, 'js')) - .setColor(util.colors.error) - .setTimestamp(); - - await client.logger.channelError({ embeds: [errorEmbed] }); - if (message) { - const channel = (message.channel as GuildChannel)?.name || message.interaction.user.tag; - if (!client.config.owners.includes(message.author.id)) { - const errorUserEmbed: MessageEmbed = new MessageEmbed() - .setTitle('A Slash Command Error Occurred') - .setColor(util.colors.error) - .setTimestamp(); - if (!command) - errorUserEmbed.setDescription(`Oh no! An error occurred. Please give the developers code \`${errorNo}\`.`); - else - errorUserEmbed.setDescription( - `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) => { - 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() - .setTitle('A Slash Command Error Occurred') - .setColor(util.colors.error) - .setTimestamp() - .setDescription(await util.codeblock(`${error?.stack || error}`, 2048, 'js')); - (await message.util?.send({ embeds: [errorDevEmbed] }).catch((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; - void client.console.error( - 'SlashError', - `an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` + - error?.stack || error, - false - ); + return await CommandErrorListener.handleError(error, message, command); } } diff --git a/src/listeners/commands/slashMissingPermissions.ts b/src/listeners/commands/slashMissingPermissions.ts index 70ed7c2..07c63e9 100644 --- a/src/listeners/commands/slashMissingPermissions.ts +++ b/src/listeners/commands/slashMissingPermissions.ts @@ -1,4 +1,5 @@ import { BushCommandHandlerEvents, BushListener } from '@lib'; +import CommandMissingPermissionsListener from './commandMissingPermissions'; export default class SlashMissingPermissionsListener extends BushListener { public constructor() { @@ -9,41 +10,9 @@ export default class SlashMissingPermissionsListener extends BushListener { }); } - public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions']): Promise<void> { - const niceMissing = []; - missing.forEach((missing) => { - if (client.consts.mappings.permissions[missing]) { - niceMissing.push(client.consts.mappings.permissions[missing].name); - } else { - niceMissing.push(missing); - } - }); - - const discordFormat = util.oxford(util.surroundArray(niceMissing, '`'), 'and', ''); - const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', ''); - void client.console.info( - 'CommandMissingPermissions', - `<<${message.author.tag}>> tried to run <<${ - command?.id - }>> but could not because <<${type}>> is missing the ${consoleFormat} permissions${missing.length ? 's' : ''}.`, - true - ); - if (type == 'client') { - await message.util - .reply( - `${util.emojis.error} I am missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the \`${ - command?.id - }\` command.` - ) - .catch(() => {}); - } else if (type == 'user') { - await message.util - .reply( - `${util.emojis.error} You are missing the ${discordFormat} permission${ - missing.length ? 's' : '' - } required for the \`${command?.id}\` command.` - ) - .catch(() => {}); - } + public async exec( + ...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions'] + ): Promise<unknown> { + return await CommandMissingPermissionsListener.handleMissing(message, command, type, missing); } } diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts index b6718fc..0321aca 100644 --- a/src/listeners/message/automodCreate.ts +++ b/src/listeners/message/automodCreate.ts @@ -1,5 +1,8 @@ import { BushListener, BushMessage } from '@lib'; -import { ClientEvents } from 'discord.js'; +import { MessageEmbed, TextChannel } from 'discord.js'; +import _badLinks from '../../lib/badlinks.json'; // Stolen from https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json +import badWords from '../../lib/badwords.json'; +import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; export default class AutomodMessageCreateListener extends BushListener { public constructor() { @@ -10,7 +13,93 @@ export default class AutomodMessageCreateListener extends BushListener { }); } - async exec(...[message]: ClientEvents['messageCreate']): Promise<unknown> { - return await util.automod(message as BushMessage); + async exec(...[message]: BushClientEvents['messageCreate']): Promise<unknown> { + return await AutomodMessageCreateListener.automod(message); + } + + public static async automod(message: BushMessage): Promise<unknown> { + if (message.guild.id !== client.consts.mappings.guilds.bush) return; // just temporary + /* await message.guild.getSetting('autoModPhases'); */ + const badLinks = {}; + _badLinks.forEach((link) => { + badLinks[link] = 3; + }); + + // client.console.debug(badLinks, 1); + // client.console.debug(badWords, 1); + + const wordArray = [...Object.keys(badWords), ...Object.keys(badLinks)]; + const offences: { [key: string]: number } = {}; + + // client.console.debug(wordArray); + wordArray.forEach((word) => { + const cleanMessageContent = message.content?.toLowerCase().replace(/ /g, ''); + const cleanWord = word.toLowerCase().replace(/ /g, ''); + + // client.console.debug(cleanMessageContent); + // client.console.debug(cleanWord); + if (cleanMessageContent.includes(cleanWord)) { + if (offences[word]) offences[word] = wordArray[word]; + } + }); + if (!Object.keys(offences)?.length) return; + + const highestOffence = Object.values(offences).sort((a, b) => b - a)[0]; + + switch (highestOffence) { + case 0: { + if (message.deletable) void message.delete(); + break; + } + case 1: { + if (message.deletable) void message.delete(); + void message.member.warn({ + moderator: message.guild.me, + reason: 'Saying a blacklisted word.' + }); + break; + } + case 2: { + if (message.deletable) void message.delete(); + void message.member.mute({ + moderator: message.guild.me, + reason: 'Saying a blacklisted word.', + duration: 900_000 // 15 minutes + }); + break; + } + case 3: { + if (message.deletable) void message.delete(); + void message.member.mute({ + moderator: message.guild.me, + reason: 'Saying a blacklisted word.', + duration: 0 // perm + }); + break; + } + } + + const color = + highestOffence === 0 + ? util.colors.lightGray + : highestOffence === 1 + ? util.colors.yellow + : highestOffence === 2 + ? util.colors.orange + : util.colors.red; + void (message.guild.channels.cache.get('783088333055066212') as TextChannel).send({ + embeds: [ + new MessageEmbed() + .setTitle(`[Severity ${highestOffence}] Automod Action Performed`) + .setDescription( + `**User:** ${message.author} (${message.author.tag})\n**Blacklisted Words:** ${util + .surroundArray(Object.keys(offences), '`') + .join()}` + ) + .addField('Message Content', `${util.codeblock(message.content, 1024)}`) + .setColor(color) + .setTimestamp() + ] + }); } } diff --git a/src/listeners/message/automodUpdate.ts b/src/listeners/message/automodUpdate.ts index e455a3d..7b9e01a 100644 --- a/src/listeners/message/automodUpdate.ts +++ b/src/listeners/message/automodUpdate.ts @@ -1,5 +1,6 @@ import { BushListener, BushMessage } from '@lib'; -import { ClientEvents, Message } from 'discord.js'; +import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; +import AutomodMessageCreateListener from './automodCreate'; export default class AutomodMessageUpdateListener extends BushListener { public constructor() { @@ -10,8 +11,9 @@ export default class AutomodMessageUpdateListener extends BushListener { }); } - async exec(...[message]: ClientEvents['messageUpdate']): Promise<unknown> { - const fullMessage = message.partial ? await message.fetch() : (message as Message); - return await util.automod(fullMessage as BushMessage); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async exec(...[_, newMessage]: BushClientEvents['messageUpdate']): Promise<unknown> { + const fullMessage = newMessage.partial ? await newMessage.fetch() : (newMessage as BushMessage); + return await AutomodMessageCreateListener.automod(fullMessage); } } diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts index 4e72ec9..6d548ba 100644 --- a/src/listeners/other/consoleListener.ts +++ b/src/listeners/other/consoleListener.ts @@ -34,8 +34,7 @@ export default class ConsoleListener extends BushListener { ReactionCollector, Util, Collection - } = await import('discord.js'), - { Canvas } = await import('node-canvas'); + } = await import('discord.js'); try { const input = line.replace('eval ', '').replace('ev ', ''); let output = eval(input); |