Initial commit: Discord-Claude Gateway with event-driven agent runtime

This commit is contained in:
2026-02-22 00:48:18 -05:00
parent bc6494395e
commit ee5c17291b
2 changed files with 24 additions and 6 deletions

View File

@@ -121,16 +121,32 @@ export class DiscordBot {
private setupMessageHandler(): void {
this.client.on("messageCreate", (message: Message) => {
if (shouldIgnoreMessage(message)) return;
console.log(`[DEBUG] Message received: "${message.content}" from ${message.author.tag} (bot: ${message.author.bot})`);
if (shouldIgnoreMessage(message)) {
console.log("[DEBUG] Ignoring bot message");
return;
}
const botUser = this.client.user;
if (!botUser) return;
if (!botUser) {
console.log("[DEBUG] No bot user available");
return;
}
if (!message.mentions.has(botUser)) return;
if (!message.mentions.has(botUser)) {
console.log("[DEBUG] Message does not mention the bot");
return;
}
const text = extractPromptFromMention(message.content, botUser.id);
if (!text) return;
console.log(`[DEBUG] Extracted prompt: "${text}"`);
if (!text) {
console.log("[DEBUG] Empty prompt after extraction, ignoring");
return;
}
console.log(`[DEBUG] Forwarding prompt to handler: "${text}" from channel ${message.channelId}`);
this.promptHandler?.({
text,
channelId: message.channelId,