1

I'm developing discord bot on discord.py with slash commands (I am using discord-py-slash-command version 3.0.3 library for this). Recently, error messages have been sent to my hosting console (heroku), but the command is executed successfully. There are no errors on the local hosting. Who knows what the problem is?

Error message:

2022-06-03T19:15:09.003586+00:00 app[worker.1]: An exception has occurred while executing command `botstat`:
2022-06-03T19:15:09.003594+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-03T19:15:09.003595+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord_slash/client.py", line 1353, in invoke_command
2022-06-03T19:15:09.003595+00:00 app[worker.1]:     await func.invoke(ctx, **args)
2022-06-03T19:15:09.003595+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord_slash/model.py", line 210, in invoke
2022-06-03T19:15:09.003596+00:00 app[worker.1]:     return await self.func(*args, **kwargs)
2022-06-03T19:15:09.003596+00:00 app[worker.1]:   File "/app/main.py", line 87, in botstat
2022-06-03T19:15:09.003596+00:00 app[worker.1]:     await ctx.send(embed = embed)
2022-06-03T19:15:09.003597+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord_slash/context.py", line 256, in send
2022-06-03T19:15:09.003598+00:00 app[worker.1]:     await self._http.post_initial_response(json_data, self.interaction_id, self._token)
2022-06-03T19:15:09.003599+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/http.py", line 250, in request
2022-06-03T19:15:09.003600+00:00 app[worker.1]:     raise NotFound(r, data)
2022-06-03T19:15:09.003601+00:00 app[worker.1]: discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```

Command code:

@slash.slash(description="Bot statistic")
async def botstat(ctx):
    global members
    members = 0
    for guild in bot.guilds:
        members += guild.member_count - 1 
    embed = discord.Embed(color = 0xff9900, title = 'Bot statistic', description=f'Statistic: guilds: {len(bot.guilds)}Users: {members}Tech info: Ping: {round(bot.latency * 1000)}  ms Uptime: {datetime.timedelta(seconds=int(round(time.time()-startTime)))} Using CPU: {psutil.cpu_percent()}% Using virual memory: {psutil.virtual_memory().percent}%')
    await ctx.send(embed = embed)
    print("botstat command used")
Zedikon
  • 11
  • 2
  • 1
    Have you enabled the `application.command` in [your bot?](https://discord.com/developers/applications) –  Jun 03 '22 at 22:17
  • @MorpKnight yes – Zedikon Jun 03 '22 at 22:55
  • Does the slash command appear on your discord? i think there should be `name`, `description`, and `guild_ids` for slash.slash –  Jun 04 '22 at 01:48
  • 1
    @MorpKnight A command appears, and, most surprisingly, it is perfectly executed. But after execution, it sends an error message to the console. – Zedikon Jun 04 '22 at 08:21
  • @Zedikon, [welcome to StackOverflow.](https://stackoverflow.com/tour) What is perfectly executed? It probably should be `ctx.channel.send()` and not `ctx.send()`. – The Amateur Coder Jun 04 '22 at 13:02
  • Also, do these help?: https://stackoverflow.com/questions/54722404/discord-py-rewrite-bot-doesnt-work-in-heroku-but-works-locally, https://stackoverflow.com/questions/62217345/discord-py-bot-properly-built-on-heroku-but-shows-offline, https://stackoverflow.com/questions/68919572/hosting-discord-bot-through-heroku-deploy-error?rq=1, https://stackoverflow.com/questions/63146978/i-am-trying-to-host-discord-py-bot-on-heroku-and-this-error-occurs and https://www.google.com/search?q=error+in+heroku+but+no+error+in+local+hosting+discord.py+404+not+found+unknown+interaction – The Amateur Coder Jun 04 '22 at 13:02
  • 1
    @TheAmateurCoder all these cases do not apply to mine. My bot works fine and processes commands, but it sends error messages to the heroku console, although in fact there are no errors. – Zedikon Jun 04 '22 at 22:02

0 Answers0