mirror of
https://github.com/Burn-E99/GroupUp.git
synced 2026-06-04 08:53:49 -04:00
Update guild delete and clean map
This commit is contained in:
@@ -1,20 +1,28 @@
|
||||
import config from '../../config.ts';
|
||||
import { Bot, log, LT } from '../../deps.ts';
|
||||
import { warnColor } from '../commandUtils.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, lfgChannelSettings } from '../db.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const guildDelete = async (bot: Bot, guildId: bigint) => {
|
||||
log(LT.LOG, `Handling leaving guild ${utils.jsonStringifyBig(guildId)}`);
|
||||
|
||||
// Clean the DB
|
||||
try {
|
||||
await dbClient.execute('DELETE FROM guild_prefix WHERE guildId = ?', [guildId]);
|
||||
await dbClient.execute('DELETE FROM guild_mod_role WHERE guildId = ?', [guildId]);
|
||||
await dbClient.execute('DELETE FROM guild_clean_channel WHERE guildId = ?', [guildId]);
|
||||
await dbClient.execute('DELETE FROM guild_settings WHERE guildId = ?', [guildId]);
|
||||
await dbClient.execute('DELETE FROM active_events WHERE guildId = ?', [guildId]);
|
||||
} catch (e) {
|
||||
log(LT.WARN, `Failed to remove guild from DB: ${utils.jsonStringifyBig(e)}`);
|
||||
}
|
||||
|
||||
// Clean lfgChannelSettings
|
||||
lfgChannelSettings.forEach((_val, key) => {
|
||||
if (key.startsWith(`${guildId}-`)) {
|
||||
lfgChannelSettings.delete(key);
|
||||
}
|
||||
});
|
||||
|
||||
// Send Log Message
|
||||
bot.helpers.sendMessage(config.logChannel, {
|
||||
embeds: [{
|
||||
title: 'Removed from Guild',
|
||||
|
||||
Reference in New Issue
Block a user