Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bot executing the same command twice

I am making a discord bot with the rewrite, but when my command runs, it sends the message twice There is 100% no other calls to send that message, and it is only the 1st message(Hold on, I'm gathering the data), that is sent twice. Here is the command's code:

    @bot.command()
    async def testcmd(ctx):
      print("called")
      msgtemp = await ctx.message.channel.send("Hold on, I'm gathering the data")
      print("sent")
      time.sleep(3)
      await msgtemp.delete()
      with open("fileofthings.txt") as fl:
        await ctx.send(fl.read())
like image 328
AirKetchup Avatar asked Dec 28 '25 14:12

AirKetchup


1 Answers

I had the same issue with my bot sending responses twice, does this happen with this particular command or it happens with other commands as well.

My theory is that you are running 2 versions of the bot meaning you get 2 messages. I developed a shutdown command in case this happens to me again

This is my code for a shutdown command if you need it.

@commands.command()
  async def shutdown(self,ctx):
    if ctx.message.author.id == OWNERID: #replace OWNERID with your user id
      print("shutdown")
      try:
        await self.bot.logout()
      except:
        print("EnvironmentError")
        self.bot.clear()
    else:
      await ctx.send("You do not own this bot!")
like image 51
FluxedScript Avatar answered Dec 31 '25 17:12

FluxedScript



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!