Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ export async function connect(): Promise<Client> {
// Ignore messages from the bot itself
if (message.author.id === client.user!.id) return;

// console.log(message.content);
// Only process messages that end with a question mark
if (!message.content.trim().endsWith("?")) return;

console.log(
`Received message: "${message.content}" from ${message.author.tag} in channel ${message.channel.id} (${message.channel.type})`,
`Received question: "${message.content}" from ${message.author.tag} in channel ${message.channel.id} (${message.channel.type})`,
);
const content = message.content;
const answer = await ask(content);
Expand All @@ -73,7 +75,7 @@ export async function connect(): Promise<Client> {
storeMessage(content, answer);
message.reply(answer);
}
});
});

await client.login(process.env.DISCORD_BOT_TOKEN);
console.log("Autodelve is now running...");
Expand Down