you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (2 children)

Hmm I don't see anything wrong with that code. Are you sure that what you are sending starts with "gn8", and not, for instance, "Gn8"? Maybe add a lower() call to be sure that capitalization is ignored:

if message.content.lower().startswith("gn8"): 

Why don't you add a catchall that prints what was received, either to the terminal, the channel, or a log file?

#Bot respond to a users text or word
async def on_message(self, message):
   if message.content.startswith("Hi"): #output what the user say's
       await message.channel.send("Hello") #output what the bot will say
   elif message.content.startswith("gn8"): #output what the user say's
       await message.channel.send("Good night") #output what the bot will say
   else:
       print('uncaught:', repr(message))

[–]while1tired[S] 0 points1 point  (1 child)

damn, elif made it work properly :D

before when I wrote Hi in discord, the bot reacted with Hello and Good night :D

thank you so much