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
GUILD_ID=653083797763522580
BOT_GUILD_ID=653083797763522580
REVIEW_GUILD_ID=906537041326637086
GITHUB_CLIENT_ID=GH_CLIENT_ID

View File

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

View File

@ -14,7 +14,8 @@ if (!global.kodl) {
global.kodl.on('ready', async () => {
console.log('Discord Client is ready')
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 ?? '')
@ -66,6 +67,8 @@ export const webhookClients = {
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 (
type: string,
issuerID: string,

View File

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