make bot responsive in dms without mention

This commit is contained in:
Adora Laura Kalb 2024-01-01 18:40:00 +01:00
parent fd66696361
commit 10ae222474
Signed by: adoralaura
GPG key ID: 7A4552166FC8C056

8
app.py
View file

@ -37,13 +37,15 @@ async def on_message(message):
logger.info(f"Ping by {message.author.name}") logger.info(f"Ping by {message.author.name}")
await message.channel.send(f"{message.author.mention} 👋") await message.channel.send(f"{message.author.mention} 👋")
return return
messagearray = message.content.split()
if not (isinstance(message.channel, discord.channel.DMChannel)) and not (messagearray[0] == client.user.mention):
return
# Handle @Bot mention # Handle @Bot mention
messagearray = message.content.split()
if messagearray[0] == client.user.mention: if messagearray[0] == client.user.mention:
messagearray.pop(0) messagearray.pop(0)
else:
return
command = messagearray[0].lower() command = messagearray[0].lower()