11import type {
2+ Channel ,
23 Embed ,
34 GuildMember ,
45 Message ,
@@ -91,6 +92,10 @@ const getStarsFromEmbed: (embed: Embed) => number = (embed) => {
9192 return Number . parseInt ( stars , 10 ) ;
9293} ;
9394
95+ const isChannelBlacklisted = ( channel : Channel ) : boolean => {
96+ return config . starboard . blacklistChannelIds ?. includes ( channel . id ) || false ;
97+ } ;
98+
9499export const StarboardListener : EventListener = {
95100 async clientReady ( client ) {
96101 for ( const guild of client . guilds . cache . values ( ) ) {
@@ -99,7 +104,8 @@ export const StarboardListener: EventListener = {
99104 for ( const channel of channels . values ( ) ) {
100105 if (
101106 channel ?. isTextBased ( ) &&
102- channel . id !== config . starboard . channel
107+ channel . id !== config . starboard . channel &&
108+ ! isChannelBlacklisted ( channel )
103109 ) {
104110 // Add to rate-limited queue
105111 await messageFetcher . addToQueue ( async ( ) => {
@@ -141,7 +147,8 @@ export const StarboardListener: EventListener = {
141147 const channel = await guild . channels . fetch (
142148 dbStarboardMessage . originalMessageChannelId . toString ( ) ,
143149 ) ;
144- if ( ! channel ?. isTextBased ( ) ) return ; // Channel is not available? ( Either we can hope it comes back or we can delete the entry from the database )
150+ if ( ! channel ?. isTextBased ( ) || isChannelBlacklisted ( channel ) )
151+ return ;
145152
146153 const starboardChannel = await guild . channels . fetch (
147154 config . starboard . channel ,
@@ -221,6 +228,7 @@ export const StarboardListener: EventListener = {
221228 ) ;
222229 } ,
223230 async messageReactionAdd ( _ , reaction ) {
231+ if ( isChannelBlacklisted ( reaction . message . channel ) ) return ;
224232 if ( reaction . partial ) {
225233 // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled
226234 try {
@@ -327,6 +335,7 @@ export const StarboardListener: EventListener = {
327335 } ,
328336
329337 async messageReactionRemove ( _ , reaction ) {
338+ if ( isChannelBlacklisted ( reaction . message . channel ) ) return ;
330339 if ( reaction . partial ) {
331340 // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled
332341 try {
0 commit comments