diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 10:25:46 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 10:25:46 -0400 |
commit | d1724227abfb8f0fcd9e573f7e9772cf0be8257a (patch) | |
tree | 52c9dbae1fbbbd3c777d9c16ab643c477141ae21 /src/listeners | |
parent | 53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3 (diff) | |
download | tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.gz tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.bz2 tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.zip |
honestly no idea what I did at this point
Diffstat (limited to 'src/listeners')
-rw-r--r-- | src/listeners/client/interactionCreate.ts (renamed from src/listeners/client/interaction.ts) | 6 | ||||
-rw-r--r-- | src/listeners/commands/commandBlocked.ts | 10 | ||||
-rw-r--r-- | src/listeners/commands/commandError.ts | 8 | ||||
-rw-r--r-- | src/listeners/commands/slashBlocked.ts | 10 | ||||
-rw-r--r-- | src/listeners/commands/slashCommandError.ts | 8 | ||||
-rw-r--r-- | src/listeners/message/level.ts | 24 |
6 files changed, 36 insertions, 30 deletions
diff --git a/src/listeners/client/interaction.ts b/src/listeners/client/interactionCreate.ts index c848d15..1183004 100644 --- a/src/listeners/client/interaction.ts +++ b/src/listeners/client/interactionCreate.ts @@ -1,11 +1,11 @@ import { BushListener } from '@lib'; import { ButtonInteraction, CommandInteraction, Interaction, SelectMenuInteraction } from 'discord.js'; -export default class InteractionListener extends BushListener { +export default class InteractionCreateListener extends BushListener { public constructor() { - super('interaction', { + super('interactionCreate', { emitter: 'client', - event: 'interaction', + event: 'interactionCreate', category: 'client' }); } diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index 03050c2..24d46af 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -37,12 +37,10 @@ export default class CommandBlockedListener extends BushListener { content: `${this.client.util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.` }); } - case reasons.CHANNEL_BLACKLIST: { - return; - } - case reasons.USER_BLACKLIST: { - return; - } + 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; } diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 9d51ea8..696b59b 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -38,20 +38,20 @@ export default class CommandErrorListener extends BushListener { 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) => { + (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); } else { const errorDevEmbed = new MessageEmbed() .setTitle('A Command Error Occurred') .setColor(this.client.util.colors.error) .setTimestamp() .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js')); - await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => { + (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); } } const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name; diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index bf98734..2443efb 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -38,12 +38,10 @@ export default class SlashBlockedListener extends BushListener { content: `${this.client.util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.` }); } - case reasons.CHANNEL_BLACKLIST: { - return; - } - case reasons.USER_BLACKLIST: { - return; - } + 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; } diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index 9bf5f6a..8abe788 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -37,18 +37,18 @@ export default class SlashCommandErrorListener extends BushListener { 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) => { + (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); } else { const errorDevEmbed = new MessageEmbed() .setTitle('A Slash Command Error Occurred') .setColor(this.client.util.colors.error) .setTimestamp() .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js')); - await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => { + (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); } } const channel = (message.channel as GuildChannel)?.name || message.interaction.user.tag; diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index a35766b..a50f580 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -12,27 +12,37 @@ export default class LevelListener extends BushListener { } async exec(message: Message): Promise<void> { if (message.author.bot) return; + if (!message.author) return; + if (!message.guild) return; if (message.util?.parsed?.command) return; - if (this.levelCooldowns.has(message.author.id)) return; - if (!this.client.config.dev && message.guild.id != '516977525906341928') return; + if (this.levelCooldowns.has(message.guild.id + message.author.id)) return; if (this.blacklistedChannels.includes(message.channel.id)) return; if (!['DEFAULT', 'REPLY'].includes(message.type)) return; //checks for join messages, slash commands, booster messages etc const [user] = await Level.findOrBuild({ where: { - id: message.author.id + user: message.author.id, + guild: message.guild.id }, defaults: { - id: message.author.id + user: message.author.id, + guild: message.guild.id } }); const xpToGive = Level.genRandomizedXp(); - user.xp = user.xp + xpToGive; + 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}`); this.client.logger.error('LevelMessageListener', e?.stack || e); return false; }); - if (success) this.client.logger.verbose(`LevelMessageListener`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>>.`); - this.levelCooldowns.add(message.author.id); + if (success) + this.client.logger.verbose( + `LevelMessageListener`, + `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.` + ); + this.levelCooldowns.add(message.guild.id + message.author.id); setTimeout(() => this.levelCooldowns.delete(message.author.id), 60_000); } } |