Skip to content

Commit 843eec8

Browse files
Merge pull request #204 from Pdzly/feature/starboard-blacklist-channels
2 parents dec8f35 + 1f269e1 commit 843eec8

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Config.prod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const config: Config = {
1818
emojiId: "⭐",
1919
channel: "975786395211816980",
2020
threshold: 2,
21+
blacklistChannelIds: [],
2122
},
2223
commands: {
2324
daily: "1059214166075912225",

src/Config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const devConfig: Config = {
1818
emojiId: "⭐",
1919
channel: "1407366658552631296",
2020
threshold: 1,
21+
blacklistChannelIds: ["904478147351806015"],
2122
},
2223
commands: {
2324
daily: "1029850807794937949",

src/config.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface Config {
2626
emojiId: string;
2727
channel: string;
2828
threshold: number;
29+
blacklistChannelIds?: Snowflake[];
2930
};
3031
suggest: {
3132
suggestionsChannel: string;

src/modules/starboard/starboard.listener.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 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+
9499
export 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

Comments
 (0)