If a confession is removed by deletion, delete it internally too
This commit is contained in:
parent
aeb3c70f91
commit
afa0a70f8a
11
src/main.ts
11
src/main.ts
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue