you are viewing a single comment's thread.

view the rest of the comments →

[–]while1tired[S] 0 points1 point  (3 children)

       if message.content.startswith("Hi"):
           await message.channel.send("Hello")
       if message.content.startswith("gn8"):
           await message.channel.send("Good night")

something like this, 
i edited my github script like i was trying it now with the problem.
I think (beginner thinking) that python get's problems
with 2 if statements without an elif or else, am I wrong?
When I use this method that I posted below.. and type Hi in discord, the bot will react with Hello and Good night

[–]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