Bot does not react to every message i send

Hello, i need some help with my bot. I’ve coded a bot which reacts to the message “$shoot”, every time I send $shoot it should tell me if I hit the target or if I missed. Everything works fine but the problem is that sometimes I send the command “$shoot” and it just simply does nothing, I have to send the command multiple times for the bot to reply. Can anyone tell me where the problem is please?
The purpose of the bot is for a server event, where many people can shoot a snow ball to a snowman every 10 minutes. So if people send the command, discord channel will not allow them to type in 10 minutes, so i want the bot to reply every time it sees the command “$shoot”. Here is the code:

import os
import discord
import random

client = discord.Client()

async def on_ready():
  print('We have logged in as {0.user}'.format(client))

async def on_message(message):
  if == client.user:

  if message.content.startswith('$shoot'):
    accuracy1 = random.randint(1,10)
    accuracy2 = random.randint(1,10)
    accuracy3 = random.randint(1,10)
    accuracy4 = random.randint(1,10)

    #reply1 = random.randint(1,4)

    if accuracy1 >= 1 and accuracy1 <= 5:
      if accuracy2 >= 1 and accuracy2 <= 5:
        if accuracy3 >= 1 and accuracy3 <= 5:
          if accuracy4 >= 1 and accuracy4 <= 5:
            await'**{}** hit the snowman, congratulations!' .format(message))
      await'**{}** missed the shot, try again!' .format(message))'TOKEN')

The else block will be executed only if accuracy1 >= 1 and accuracy1 <= 5, is not True. If it is True, and any of the nested if statements is False, then the else block won’t be executed, as it’s not a part of that if/else.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.