feat: add bot exclusive guild

This commit is contained in:
skinmaker1345 2026-05-17 20:08:45 +09:00
parent 1639f9b8a3
commit 683f7f8b7b
4 changed files with 15 additions and 6 deletions

View File

@ -17,6 +17,7 @@ DISCORD_TOKEN=BOT_TOKEN
DISCORD_CLIENT_INTENTS=32767 DISCORD_CLIENT_INTENTS=32767
GUILD_ID=653083797763522580 GUILD_ID=653083797763522580
BOT_GUILD_ID=653083797763522580
REVIEW_GUILD_ID=906537041326637086 REVIEW_GUILD_ID=906537041326637086
GITHUB_CLIENT_ID=GH_CLIENT_ID GITHUB_CLIENT_ID=GH_CLIENT_ID

View File

@ -24,7 +24,7 @@ import {
objectDiff, objectDiff,
serialize, serialize,
} from '@utils/Tools' } from '@utils/Tools'
import { discordLog, getMainGuild, webhookClients } from '@utils/DiscordBot' import { discordLog, getBotGuild, getMainGuild, webhookClients } from '@utils/DiscordBot'
import { KoreanbotsEndPoints } from '@utils/Constants' import { KoreanbotsEndPoints } from '@utils/Constants'
const patchLimiter = rateLimit({ const patchLimiter = rateLimit({
@ -181,6 +181,7 @@ const Bots = RequestHandler()
return ResponseWrapper(res, { code: 400, message: '봇 이름을 입력해주세요.' }) return ResponseWrapper(res, { code: 400, message: '봇 이름을 입력해주세요.' })
await remove.bot(bot.id) await remove.bot(bot.id)
await getMainGuild().members.cache.get(bot.id)?.kick('봇 삭제됨.') await getMainGuild().members.cache.get(bot.id)?.kick('봇 삭제됨.')
await getBotGuild().members.cache.get(bot.id)?.kick('봇 삭제됨.')
get.user.clear(user) get.user.clear(user)
await discordLog( await discordLog(
'BOT/DELETE', 'BOT/DELETE',

View File

@ -14,7 +14,8 @@ if (!global.kodl) {
global.kodl.on('ready', async () => { global.kodl.on('ready', async () => {
console.log('Discord Client is ready') console.log('Discord Client is ready')
await getMainGuild().members.fetch() await getMainGuild().members.fetch()
console.log(`Fetched ${getMainGuild().members.cache.size} Members`) await getBotGuild().members.fetch()
console.log(`Fetched ${getMainGuild().members.cache.size} + ${getBotGuild().members.cache.size} Members`)
}) })
global.kodl.login(process.env.DISCORD_TOKEN ?? '') global.kodl.login(process.env.DISCORD_TOKEN ?? '')
@ -66,6 +67,8 @@ export const webhookClients = {
export const getMainGuild = () => DiscordBot.guilds.cache.get(process.env.GUILD_ID ?? '') export const getMainGuild = () => DiscordBot.guilds.cache.get(process.env.GUILD_ID ?? '')
export const getBotGuild = () => DiscordBot.guilds.cache.get(process.env.BOT_GUILD_ID ?? '')
export const discordLog = async ( export const discordLog = async (
type: string, type: string,
issuerID: string, issuerID: string,

View File

@ -34,7 +34,7 @@ import {
import knex from './Knex' import knex from './Knex'
import { Bots, Servers } from './Mongo' import { Bots, Servers } from './Mongo'
import { DiscordBot, getMainGuild } from './DiscordBot' import { DiscordBot, getBotGuild, getMainGuild } from './DiscordBot'
import { sign, verify } from './Jwt' import { sign, verify } from './Jwt'
import { areArraysEqual, camoUrl, formData, getYYMMDD, serialize } from './Tools' import { areArraysEqual, camoUrl, formData, getYYMMDD, serialize } from './Tools'
import { AddBotSubmit, AddServerSubmit, ManageBot, ManageServer } from './Yup' import { AddBotSubmit, AddServerSubmit, ManageBot, ManageServer } from './Yup'
@ -87,9 +87,13 @@ async function getBot(id: string, topLevel = true): Promise<Bot> {
.where({ id }) .where({ id })
.then((r) => r) .then((r) => r)
} }
const botMember = (await getMainGuild() const botMember =
?.members?.fetch(res.id) ((await getMainGuild()
.catch((e) => e)) as GuildMember ?.members?.fetch(res.id)
.catch((e) => null)) ??
((await getBotGuild()
?.members?.fetch(res.id)
.catch((e) => null))) as GuildMember)
const name = discordBot.displayName const name = discordBot.displayName
res.flags = res.flags =
res.flags | res.flags |