Initial commit: Discord-Claude Gateway with event-driven agent runtime
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user