Feature/4 add data delete on guild remove #7

Merged
AstroGD merged 7 commits from feature/4-add-data-delete-on-guild-remove into dev 2022-11-25 18:31:44 +01:00
2 changed files with 19 additions and 1 deletions
Showing only changes of commit d9c81ef3f2 - Show all commits

17
src/events/guildDelete.ts Normal file
View File

@ -0,0 +1,17 @@
import client from "../client";
import { Events } from "discord.js";
import { getGuildSetting } from "../tools/data";
import { Badword, database, GuildSetting } from "../data";
client.on(Events.GuildDelete, async (guild) => {
const settings = await getGuildSetting(guild.id);
if (settings.preserveDataOnGuildLeave) return;
await database.getRepository(GuildSetting).delete({
id: guild.id
});
await database.getRepository(Badword).delete({
guildID: guild.id
});
});

View File

@ -1 +1,2 @@
import "./channelUpdate"; import "./channelUpdate";
import "./guildDelete";