From 1f269e129169afd1cf6f976267449f495c0c6c0f Mon Sep 17 00:00:00 2001 From: rooki Date: Fri, 5 Dec 2025 21:40:30 +0100 Subject: [PATCH] - Added `blacklistChannelIds` option to starboard configuration - Implemented channel blacklisting logic in starboard listener - Updated both prod and dev config files with default blacklist values - Modified starboard processing to skip messages from blacklisted channels --- src/Config.prod.ts | 1 + src/Config.ts | 1 + src/config.type.ts | 1 + src/modules/starboard/starboard.listener.ts | 13 +++++++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Config.prod.ts b/src/Config.prod.ts index adaf80fe..ff9b1522 100644 --- a/src/Config.prod.ts +++ b/src/Config.prod.ts @@ -18,6 +18,7 @@ export const config: Config = { emojiId: "⭐", channel: "975786395211816980", threshold: 2, + blacklistChannelIds: [], }, commands: { daily: "1059214166075912225", diff --git a/src/Config.ts b/src/Config.ts index af095e43..85b320ba 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -18,6 +18,7 @@ const devConfig: Config = { emojiId: "⭐", channel: "1407366658552631296", threshold: 1, + blacklistChannelIds: ["904478147351806015"], }, commands: { daily: "1029850807794937949", diff --git a/src/config.type.ts b/src/config.type.ts index a3c03dee..3413e480 100644 --- a/src/config.type.ts +++ b/src/config.type.ts @@ -26,6 +26,7 @@ export interface Config { emojiId: string; channel: string; threshold: number; + blacklistChannelIds?: Snowflake[]; }; suggest: { suggestionsChannel: string; diff --git a/src/modules/starboard/starboard.listener.ts b/src/modules/starboard/starboard.listener.ts index ff74fe63..4fb52edd 100644 --- a/src/modules/starboard/starboard.listener.ts +++ b/src/modules/starboard/starboard.listener.ts @@ -1,4 +1,5 @@ import type { + Channel, Embed, GuildMember, Message, @@ -91,6 +92,10 @@ const getStarsFromEmbed: (embed: Embed) => number = (embed) => { return Number.parseInt(stars, 10); }; +const isChannelBlacklisted = (channel: Channel): boolean => { + return config.starboard.blacklistChannelIds?.includes(channel.id) || false; +}; + export const StarboardListener: EventListener = { async clientReady(client) { for (const guild of client.guilds.cache.values()) { @@ -99,7 +104,8 @@ export const StarboardListener: EventListener = { for (const channel of channels.values()) { if ( channel?.isTextBased() && - channel.id !== config.starboard.channel + channel.id !== config.starboard.channel && + !isChannelBlacklisted(channel) ) { // Add to rate-limited queue await messageFetcher.addToQueue(async () => { @@ -141,7 +147,8 @@ export const StarboardListener: EventListener = { const channel = await guild.channels.fetch( dbStarboardMessage.originalMessageChannelId.toString(), ); - if (!channel?.isTextBased()) return; // Channel is not available? ( Either we can hope it comes back or we can delete the entry from the database ) + if (!channel?.isTextBased() || isChannelBlacklisted(channel)) + return; const starboardChannel = await guild.channels.fetch( config.starboard.channel, @@ -221,6 +228,7 @@ export const StarboardListener: EventListener = { ); }, async messageReactionAdd(_, reaction) { + if (isChannelBlacklisted(reaction.message.channel)) return; if (reaction.partial) { // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled try { @@ -327,6 +335,7 @@ export const StarboardListener: EventListener = { }, async messageReactionRemove(_, reaction) { + if (isChannelBlacklisted(reaction.message.channel)) return; if (reaction.partial) { // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled try {