From 35839395f48dc0c9692fed977438f0139050da3e Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 30 Dec 2024 21:52:32 -0800 Subject: [PATCH] adding back the dm chat --- scripts/discordbot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/discordbot.py b/scripts/discordbot.py index 0628162..3f6475e 100644 --- a/scripts/discordbot.py +++ b/scripts/discordbot.py @@ -64,8 +64,13 @@ async def on_message(message): if message.author == bot.user: return - if bot.user in message.mentions: - prompt = message.content.replace(f'<@{bot.user.id}>', '').strip() + # Respond to DMs or when mentioned in a server + if isinstance(message.channel, discord.DMChannel) or bot.user in message.mentions: + # For mentions, remove the bot mention from the message + if bot.user in message.mentions: + prompt = message.content.replace(f'<@{bot.user.id}>', '').strip() + else: + prompt = message.content.strip() if not prompt: await message.channel.send("Hello! How can I help you?")