aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/message
diff options
context:
space:
mode:
Diffstat (limited to 'src/listeners/message')
-rw-r--r--src/listeners/message/autoPublisher.ts2
-rw-r--r--src/listeners/message/autoThread.ts (renamed from src/listeners/message/supportThreads.ts)4
-rw-r--r--src/listeners/message/automodCreate.ts4
-rw-r--r--src/listeners/message/blacklistedFile.ts8
-rw-r--r--src/listeners/message/boosterMessage.ts (renamed from src/listeners/message/booster.ts)3
-rw-r--r--src/listeners/message/level.ts9
-rw-r--r--src/listeners/message/verbose.ts2
7 files changed, 12 insertions, 20 deletions
diff --git a/src/listeners/message/autoPublisher.ts b/src/listeners/message/autoPublisher.ts
index a1d61f7..1be58a3 100644
--- a/src/listeners/message/autoPublisher.ts
+++ b/src/listeners/message/autoPublisher.ts
@@ -11,7 +11,7 @@ export default class autoPublisherListener extends BushListener {
}
public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void> {
- if (!message.guild) return;
+ if (!message.guild || !(await message.guild.hasFeature('autoPublish'))) return;
const autoPublishChannels = await message.guild.getSetting('autoPublishChannels');
if (autoPublishChannels) {
if (message.channel.type === 'GUILD_NEWS' && autoPublishChannels.some((x) => message.channel.id.includes(x))) {
diff --git a/src/listeners/message/supportThreads.ts b/src/listeners/message/autoThread.ts
index 9b3ea3e..eb54554 100644
--- a/src/listeners/message/supportThreads.ts
+++ b/src/listeners/message/autoThread.ts
@@ -3,9 +3,9 @@ import { MessageEmbed } from 'discord.js';
import { BushListener, BushTextChannel } from '../../lib';
import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents';
-export default class SupportThreadListener extends BushListener {
+export default class autoThreadListener extends BushListener {
public constructor() {
- super('supportThreads', {
+ super('autoThread', {
emitter: 'client',
event: 'messageCreate',
category: 'message'
diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts
index ca61dd0..f78efec 100644
--- a/src/listeners/message/automodCreate.ts
+++ b/src/listeners/message/automodCreate.ts
@@ -22,8 +22,8 @@ export default class AutomodMessageCreateListener extends BushListener {
}
public static async automod(message: BushMessage): Promise<unknown> {
- if (message.channel.type === 'DM') return;
- if (message.guild?.id !== client.consts.mappings.guilds.bush) return; // just temporary
+ if (message.channel.type === 'DM' || !message.guild) return;
+ if (!(await message.guild.hasFeature('automod'))) return;
/* await message.guild.getSetting('autoModPhases'); */
const badLinks: { [key: string]: number } = {};
let temp = _badLinks;
diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts
index a9c5c46..5aa5477 100644
--- a/src/listeners/message/blacklistedFile.ts
+++ b/src/listeners/message/blacklistedFile.ts
@@ -66,13 +66,7 @@ export default class BlacklistedFileListener extends BushListener {
}
public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void> {
- if (!message.guild) return;
- const guildWhitelist = [
- client.consts.mappings.guilds.bush,
- client.consts.mappings.guilds.tree,
- client.consts.mappings.guilds.space_ship
- ];
- if (!guildWhitelist.includes(message.guild!.id)) return;
+ if (!message.guild || !(await message.guild.hasFeature('blacklistedFile'))) return;
const embedAttachments = message.embeds.filter((e) => ['image', 'video', 'gifv'].includes(e.type));
const foundEmojis = [...message.content.matchAll(/<(?<animated>a?):\w+:(?<id>\d+)>/g)];
if (message.attachments.size + embedAttachments.length + foundEmojis.length < 1) return;
diff --git a/src/listeners/message/booster.ts b/src/listeners/message/boosterMessage.ts
index 603e535..5d49661 100644
--- a/src/listeners/message/booster.ts
+++ b/src/listeners/message/boosterMessage.ts
@@ -11,7 +11,8 @@ export default class BoosterMessageListener extends BushListener {
}
public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<unknown> {
- if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION' && message.guild!.id === this.client.consts.mappings.guilds.bush) {
+ if (!message.guild || !(await message.guild?.hasFeature('boosterMessageReact'))) return;
+ if (message.type === 'USER_PREMIUM_GUILD_SUBSCRIPTION') {
return await message.react('<:nitroboost:785160348885975062>').catch(() => {
void this.client.console.warn('BoosterMessage', `Failed to react to <<${message.id}>>.`);
});
diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts
index 0077276..33e7b08 100644
--- a/src/listeners/message/level.ts
+++ b/src/listeners/message/level.ts
@@ -12,10 +12,7 @@ export default class LevelListener extends BushListener {
});
}
public override async exec(...[message]: BushCommandHandlerEvents['messageInvalid']): Promise<void> {
- if (message.author.bot) return;
- if (!message.author) return;
- if (!message.guild) return;
- if (message.util?.parsed?.command) return;
+ if (message.author.bot || !message.author || !message.guild) return;
if (this.#levelCooldowns.has(`${message.guild.id}-${message.author.id}`)) return;
if (this.#blacklistedChannels.includes(message.channel.id)) return;
const allowedMessageTypes: MessageType[] = ['DEFAULT', 'REPLY']; // this is so ts will yell at me when discord.js makes some unnecessary breaking change
@@ -33,12 +30,12 @@ export default class LevelListener extends BushListener {
});
const xpToGive = Level.genRandomizedXp();
const success = await user.increment('xp', { by: xpToGive }).catch((e) => {
- void client.logger.error('LevelMessageListener', e?.stack || e);
+ void client.logger.error('levelMessageListener', e?.stack || e);
return false;
});
if (success)
void client.logger.verbose(
- `LevelMessageListener`,
+ `levelMessageListener`,
`Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.`
);
this.#levelCooldowns.add(`${message.guild.id}-${message.author.id}`);
diff --git a/src/listeners/message/verbose.ts b/src/listeners/message/verbose.ts
index f1530ce..9404412 100644
--- a/src/listeners/message/verbose.ts
+++ b/src/listeners/message/verbose.ts
@@ -13,7 +13,7 @@ export default class MessageVerboseListener extends BushListener {
public override exec(...[message]: BushClientEvents['messageCreate']): Promise<void> | undefined {
if (message.channel?.type === 'DM') return;
void this.client.console.verbose(
- 'Message',
+ 'messageVerbose',
`A message was sent by <<${message.author.tag}>> in <<${message.channel.name}>> in <<${message.guild!.name}>>.`
);
}