TheDescend / elevatorbot

Interacting with the Destiny 2 API via Discord
https://elevatorbot.ch/
Other
11 stars 3 forks source link

Repeat Application Interactions causes crash #202

Closed MelodicAlbuild closed 1 year ago

MelodicAlbuild commented 1 year ago

Hello,

I am trying to run the bot on my own servers and after configuring the entire bot and running it, I had to restart it because of a networking change. As soon as I restarted it I started to get this error:

raceback (most recent call last):
  File "/app/ElevatorBot/elevator.py", line 209, in <module>
    CustomDebugModule(bot=client)
  File "/app/ElevatorBot/elevator.py", line 202, in __new__
    return super().__new__(cls=cls, bot=bot, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/naff/models/naff/extension.py", line 97, in __new__
    if not bot.add_interaction(val):
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/naff/client/client.py", line 1202, in add_interaction
    raise ValueError(f"Duplicate Command! {scope}::{old_cmd.resolved_name}")
ValueError: Duplicate Command! 1017440747491958794::debug app_cmds internal_info

I'm not sure why it's doing this but I'm looking into it to try and find a solution.

MelodicAlbuild commented 1 year ago

After looking at this for a couple hours, it looks like the bot creation calls the add interaction, but doesn't have a check to not add an interaction if the command already exists, as such it throws the error and the bot crashes. Seems like a simple check to add in but I don't work in python so I can't do much here. @Kigstn If you need more error log or such from me, let me know.

Kigstn commented 1 year ago

@MelodicAlbuild

Huh, interesting issue. It seems like discord does not properly report your commands back to your client, or I made a mistake somewhere. The 2nd is probably more likely :D

There are two solutions I can propose on the spot:

1) comment out line 209 in ElevatorBot/elevator.py to see if the same issue happens with other commands. That line only loads debugging features, which you don't need anyways.

2) change the COMMAND_GUILD_SCOPE in your settings.toml back to an empty list, that should do the trick as well and only disable some debugging commands and some admin stuff, nothing major or destiny related. I recommend this over solution 1

If that does not work, I'd love to get the full traceback.

Anyways, please report back if that worked and ping me when you do. Otherwise it may take me a couple days until I notice the update :)