From 1d383d9a03c43469a298d3651f92e210c2966f96 Mon Sep 17 00:00:00 2001 From: Claude Owner Date: Wed, 27 May 2026 10:20:41 +0900 Subject: [PATCH] feat(prod-commands): wipe dev guild commands before global registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `Config.dev` is true, the operator typically registers slash commands per-guild (Config.guildId) during iteration so they appear instantly. Once those leak past dev, the same commands show up in Discord twice — once from the dev guild registration and once from the global registration. Before doing the global PUT, also PUT an empty array against the dev guild so any stale per-guild commands are cleared. Behavior in production (Config.dev=false) is unchanged. --- src/utils/Prod-commands.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/Prod-commands.ts b/src/utils/Prod-commands.ts index 79e1263..802cbc7 100644 --- a/src/utils/Prod-commands.ts +++ b/src/utils/Prod-commands.ts @@ -6,6 +6,18 @@ import { Logger } from "./Logger"; async function main() { const rest = new REST({ version: "10" }).setToken(Config.token); const body = Array.from(handler.commands.values().filter(cmd => cmd.visible).map(cmd => cmd.metaData)); + + // 개발 모드에서는 Config.guildId 길드에 따로 등록된 슬래시가 남아 + // 전역 명령어와 디스코드에 두 번 보이는 경우가 생긴다. + // 전역 등록 전에 해당 길드의 명령어를 전부 비워둔다. + if (Config.dev) { + await rest.put( + Routes.applicationGuildCommands(Config.appId, Config.guildId), + { body: [] }, + ); + Logger.ready(`개발 길드(${Config.guildId}) 슬래시 전체 삭제 완료`); + } + // 전역 등록 (권장: 배포 파이프라인에서만 실행) await rest.put(Routes.applicationCommands(Config.appId), { body }); Logger.ready(`전역 슬래시 등록 요청 완료: ${body.length}개`);