Skip to content

Commit

Permalink
Merge pull request #37 from boaz-baekjoon/feat/36-guilddelete
Browse files Browse the repository at this point in the history
feat: Delete information when bot is removed (#36)
  • Loading branch information
synoti21 authored Feb 4, 2024
2 parents 415c12b + 8d52c00 commit 235e89e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/embedMessage/guideMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const embedWelcome = new EmbedBuilder()
{ name: '/report', value: '버그나 개선사항이 있으면 자유롭게 말씀해주세요!', inline: false },
{ name: '/help', value: '백준 봇 명령어를 알려드립니다.', inline: false },
{ name: '/categorylist', value: '/category 사용 전, 알고리즘 분류 목록표를 보여드립니다.', inline: false },
{ name: '/quit', value: '백준 ID를 제거합니다.', inline: false },
{ name: '/quit', value: '백준 ID를 제거합니다. 봇을 제거할 시 정보 또한 동일하게 제거됩니다.', inline: false },
{ name: '/deactivate', value: '일일 문제 알림 수신을 비활성화 합니다.', inline: false },
{ name: '\u200B', value: '\u200B' },
{ name: '업데이트 로그는 다음 링크에서 확인해주세요.', value: 'https://github.com/boaz-baekjoon/baekjoon-discord-bot/releases', inline: false },
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { logger } from './logger.js'
import {initializeBot} from "./bot/initialize-bot.js";
import {embedWelcome} from "./embedMessage/guideMessage.js";
import {sendAdminMessage} from "./bot/adminMessage.js";
import {ModelUtil} from "./util/modelUtil.js";
import {MongoUtil} from "./util/mongoUtil.js";

declare module "discord.js" {
export interface Client {
Expand Down Expand Up @@ -38,6 +40,15 @@ client.on("guildCreate", async(guild) => {
channel.send({embeds: [embedWelcome]});
})

client.on('guildDelete', async(guild) => {
try{
await MongoUtil.deleteUser(guild.ownerId);
logger.info(`${guild.ownerId} / Bot is removed from guild`)
}catch (error){
logger.error(error);
}
});

client.on('interactionCreate', async (interaction: Interaction) => {
try{
if (!interaction.isChatInputCommand()) return;
Expand Down

0 comments on commit 235e89e

Please sign in to comment.