I have just started to learn bots in discord. but the issue is that whenever i try
message.content.startswith('Hello')
then even after writing ‘Hello’ , even copying and pasting or making the bot return the string and pasting it within discord, it doesnt count it as correct input. But, if I make the bot write ‘Hello’, it recognises it just fine. pls help, here is the code
import discord
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print('Roger victim. I m in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('Hello'):
await message.channel.send('Hola !')
else:
await message.channel.send('no, Hello')
client.run('token value')
the code is showing this output
(https://i.sstatic.net/JpvYx3p2.png)
I have tried copying the ‘Hello’ from the editor, discord, the bot; and replacing it with simpler ‘.’ or ‘/’ to see if it works, but none did.
the bot is running, so i doubt any spelling error.
i m using discord on my phone if that helps.
the bot identifies the text as correct when I make it write the text itself and identify it.
import discord
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print('Roger victim. I m in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
await message.channel.send('Hello')
if message.content.startswith('Hello'):
await message.channel.send('Hola no mark')
return
if message.content == 'Hello':
await message.channel.send('Hola !')
else:
await message.channel.send('no')
client.run('token value')
the output of this code is
(https://i.sstatic.net/jH306kFd.png)
Anirudh Agrawal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.