Feature/4 add data delete on guild remove #7
17
src/events/guildDelete.ts
Normal file
17
src/events/guildDelete.ts
Normal 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
|
||||||
|
});
|
||||||
|
});
|
@ -1 +1,2 @@
|
|||||||
import "./channelUpdate";
|
import "./channelUpdate";
|
||||||
|
import "./guildDelete";
|
Loading…
Reference in New Issue
Block a user