Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

message.content.startswith Discord.Py

@client.event
async def on_message(message):
    await client.process_commands(message)
    if message.content.startswith('sa'):
        await message.channel.send('as')

This is my code. It should say as when I say sa. It works fine but when I write salah or anything that starts with sa, it detects it and responds. It shouldn't work like that. I read the documentation but couldn't find anything, I know that it is becuse of .startswith but I can't find any replacement for it.

like image 750
Emir Sürmen Avatar asked Jun 11 '20 07:06

Emir Sürmen


1 Answers

As explained in the comments, if you want to compare equality between strings, then:

if message.content == 'sa':
like image 66
TerryA Avatar answered Sep 20 '22 11:09

TerryA