Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Config.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const config: Config = {
emojiId: "⭐",
channel: "975786395211816980",
threshold: 2,
blacklistChannelIds: [],
},
commands: {
daily: "1059214166075912225",
Expand Down
1 change: 1 addition & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const devConfig: Config = {
emojiId: "⭐",
channel: "1407366658552631296",
threshold: 1,
blacklistChannelIds: ["904478147351806015"],
},
commands: {
daily: "1029850807794937949",
Expand Down
1 change: 1 addition & 0 deletions src/config.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Config {
emojiId: string;
channel: string;
threshold: number;
blacklistChannelIds?: Snowflake[];
};
suggest: {
suggestionsChannel: string;
Expand Down
13 changes: 11 additions & 2 deletions src/modules/starboard/starboard.listener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
Channel,
Embed,
GuildMember,
Message,
Expand Down Expand Up @@ -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()) {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading