If a confession is removed by deletion, delete it internally too

This commit is contained in:
powermaker450 2024-10-13 13:44:20 -04:00
parent aeb3c70f91
commit afa0a70f8a
2 changed files with 21 additions and 0 deletions

View file

@ -64,6 +64,17 @@ BotClient.on(Events.InteractionCreate, async interaction => {
}
});
BotClient.on(Events.MessageDelete, async message => {
const id = message.guild?.id!;
const confessions = dt.getGuildInfo(id)?.confessions!;
for (const confession of confessions) {
if (confession.messageId === id) {
dt.adminDelConfession(id, confession.id);
}
}
});
BotClient.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) {
return;

View file

@ -199,6 +199,16 @@ export class StoreMan {
return false;
}
public adminDelConfession(guildId: string, confessionId: string): void {
for (const guild of this.data) {
if (guild.id === guildId) {
guild.confessions = guild.confessions.filter(confession => {
return confession.id !== confessionId;
});
}
}
}
// Check if a certain user is banned within a guild.
public isBanned(guildId: string, userId: string): boolean {
for (const guild of this.data) {