-5

UPDATE

For some reason, my discord bot is unable to respond to multiple messages though my code is seemingly correct. In addition, i'm experiencing an issue in VS Code: the terminal isn't being updated unless i close, reopen the editor and rerun the code! Keep in mind that the discord bot doesn't run unless the program displays 'ready' on the terminal. And because of that terminal issue, my bot isn't running perfectly! So what can result in such a problem?

NOTE :

When i click the run button is VSC, nothing changes.(it's not working unless i reopen the editor)

...
@bot.event
async def on_message(message):
    events = ['happy birthday', 'joyeux anniversaire']
    games = ['rocket league', 'Minecraft']
    while True:
        if message.author == bot.user:
            return
    for event in events:
        if event in message.content.lower():
            await message.channel.send('Happy Birthday! 🎈🎉')
    for game in games:
        if game in message.content.lower():
            await message.channel.send('It\'s play time ! ')
...
4
  • what is the problem to use if 'rocket league' in message.content.lower(): ...? It is basic knowledge of python
    – furas
    Feb 14, 2021 at 16:02
  • or even for text in games: if text in message.content.lower(): ... ? It is basic knowledge of Python
    – furas
    Feb 14, 2021 at 16:03
  • @furas i know that it's really simple. I tried it multiple times but it didn't work for some reason. However, it's working properly now after i closed and reopened the editor !
    – Salem
    Feb 14, 2021 at 16:21
  • maybe you had two files - maybe you made changes in one file but it was running all time other file. OR maybe you didn't restart bot after changes and you all time was running old code.
    – furas
    Feb 14, 2021 at 16:40

2 Answers 2

1

Frankly, I don't understand your problem because it is basic knowledge.

You have to use another for-loop.

events = ['happy birthday', 'joyeux anniversaire']
games  = ['rocket league']

@bot.event
async def on_message(message):

    if message.author == bot.user:
        return
       
    for event in events:
        if event in message.content.lower():
            await message.channel.send('Happy Birthday! 🎈🎉')

    for game in games:
        if game in message.content.lower():
            await message.channel.send(f'"{game}" is a good game')
2
  • you should say it in question. And if doesn't work then you should describe it- ie . you should add error message if you get error message. Sentence "doesn't work" is the most useless information. And maybe if you would say it in question then you wouldn't get so may downvotes.
    – furas
    Feb 14, 2021 at 16:18
  • the problem is in the editor itself. When i run the code, nothing appears in the terminal and no changes apply to the bot unless i close the editor, reopen it.and rerun the code.
    – Salem
    Feb 14, 2021 at 17:02
0

FIX :

So i realized that the problem's origin was from the editor as i expected. However, the nature of the problem is still unknown but copying the file content (the code) and moving it to another python file could help. Such issues occur sometimes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.