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
23 changes: 23 additions & 0 deletions src/modules/suggest/suggest.listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type ModalSubmitInteraction,
} from "discord.js";
import { config } from "../../Config.js";
import { logger } from "../../logging.js";
import { SuggestionStatus } from "../../store/models/Suggestion.js";

import type { EventListener } from "../module.js";
Expand All @@ -15,6 +16,7 @@ import {
createVotesEmbed,
generateVoteMessage,
getSuggestionByMessageIdOrRecoverFromMessage,
removeSuggestionVotesForMember,
respondToSuggestionInteraction,
SUGGESTION_MANAGE_APPROVE_ID,
SUGGESTION_MANAGE_APPROVE_MODAL_ID,
Expand Down Expand Up @@ -256,4 +258,25 @@ export const SuggestionButtonListener: EventListener = {
}
}
},
async guildBanAdd(client, ban) {
try {
const { removedVotes, updatedSuggestions } =
await removeSuggestionVotesForMember(client, BigInt(ban.user.id));

if (removedVotes > 0) {
logger.info(
"Removed %d suggestion votes from banned user %s and refreshed %d suggestion messages",
removedVotes,
ban.user.id,
updatedSuggestions,
);
}
} catch (error) {
logger.error(
"Failed to remove suggestion votes for banned user %s",
ban.user.id,
error,
);
}
},
};
7 changes: 6 additions & 1 deletion src/modules/suggest/suggest.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import type Module from "../module.js";
import { ManageSuggestionCommand } from "./manageSuggestion.command.js";
import { SuggestCommand } from "./suggest.command.js";
import { SuggestionButtonListener } from "./suggest.listener.js";
import { SyncSuggestionVotesCommand } from "./syncSuggestionVotes.command.js";

export const SuggestModule: Module = {
name: "suggest",
commands: [SuggestCommand, ManageSuggestionCommand],
commands: [
SuggestCommand,
ManageSuggestionCommand,
SyncSuggestionVotesCommand,
],
listeners: [SuggestionButtonListener],
};

Expand Down
Loading