[go: up one dir, main page]

Bug: `inspect guild` is broken

It sends the spinner message, but then runs into:

Ignoring exception in command inspect guild:                                                                                                                Traceback (most recent call last):                                                                                                                            File "/home/erin/.cache/pypoetry/virtualenvs/cabling-bot-417_n4la-py3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 184, in wrapped     ret = await coro(*args, **kwargs)                                                                                                                       
  File "/media/hdd-array/tech/dev/repos/gitlab/aelithe/cables/cabling_bot/cmds/inspect.py", line 219, in guild                                                  features = cabling_bot.util.discord.guild_attributes([guild])                                                                                             File "/media/hdd-array/tech/dev/repos/gitlab/aelithe/cables/cabling_bot/util/discord.py", line 89, in guild_attributes                                        return struct[str(guilds[0].id)]                                                                                                                        KeyError: '895846927231496224'                                                                                                                                                                                                                                                                                          The above exception was the direct cause of the following exception:
                                                                                                                                                            
Traceback (most recent call last):                                            
  File "/home/erin/.cache/pypoetry/virtualenvs/cabling-bot-417_n4la-py3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 344, in invoke       await ctx.command.invoke(ctx)
  File "/home/erin/.cache/pypoetry/virtualenvs/cabling-bot-417_n4la-py3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1550, in invoke
    await ctx.invoked_subcommand.invoke(ctx)                                 
  File "/home/erin/.cache/pypoetry/virtualenvs/cabling-bot-417_n4la-py3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 951, in invoke      await injected(*ctx.args, **ctx.kwargs)                                                                                                                   File "/home/erin/.cache/pypoetry/virtualenvs/cabling-bot-417_n4la-py3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 193, in wrapped     raise CommandInvokeError(exc) from exc                                                                                                                  discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: '895846927231496224'

Which appears to be due to utils.discord.guild_attributes() passing when no user parameter is passed to it.

What should happen instead, is that the user-related attributes are conditionally added to the guilds array dependent on the user parameter, and if the guilds array is empty, to return None.