봇 중계: 지켜보는 앱이 없는 서버의 슬래시 명령은 서버가 받지 않는다

봇 토큰을 직접 쓰는 v1.1.0 PC 가 아직 켜져 있으면 같은 명령을 서버와 PC 가 함께 받는다.
서버가 먼저 응답(defer)하면 PC 의 응답이 실패해 /녹음시작 이 동작하지 않으므로, 그 서버를 지켜보는 v1.2.1 앱이 있을 때만 받는다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-15 10:42:06 +09:00
parent 6a03c67b54
commit 68e0b43b77
3 changed files with 10 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ export interface BotCommand {
* 이벤트: 'ready', 'guilds', 'voiceState' (BotVoiceEvent), 'command' (BotCommand, respond(content))
*/
export interface BotSource extends EventEmitter {
/** 이 서버의 슬래시 명령을 받을지 (지켜보는 앱이 없으면 응답하지 않는다: 아직 봇 토큰을 직접 쓰는 v1.1.0 PC 의 응답을 가로채지 않게) */
wants?: (guildId: string) => boolean;
me(): BotGwMember | null;
guilds(): BotGwGuild[];
/** 음성채널 목록과 음성채널에 있는 사람 */
@@ -76,6 +78,7 @@ export class BotBroker {
source.on('voiceState', (e: BotVoiceEvent) => {
for (const c of this.conns) if (c.guildId === e.guildId) this.send(c, { t: 'voiceState', ...e });
});
source.wants = (guildId) => [...this.conns].some((c) => c.guildId === guildId);
source.on('command', (cmd: BotCommand, respond: (content: string) => void) => void this.onCommand(cmd).then(respond));
// 등록 해제 · 로그아웃된 연결은 30초 안에 끊는다 (해제 · 로그아웃 API 는 kick 으로 바로 끊는다)
this.timer = setInterval(() => {

View File

@@ -18,6 +18,7 @@ const isVoice = (c: { type: ChannelType } | null | undefined): c is VoiceBasedCh
export class DiscordSource extends EventEmitter implements BotSource {
readonly client: Client;
wants?: (guildId: string) => boolean;
constructor(private log: { info: (o: any, m?: string) => void; error: (o: any, m?: string) => void }) {
super();
@@ -39,6 +40,7 @@ export class DiscordSource extends EventEmitter implements BotSource {
});
c.on(Events.InteractionCreate, async (i) => {
if (!i.isChatInputCommand() || !i.guildId || !COMMANDS.some((x) => x.name === i.commandName)) return;
if (this.wants && !this.wants(i.guildId)) return;
try {
await i.deferReply({ flags: MessageFlags.Ephemeral });
} catch (e) {