baiumbg / baiumbg-Cogs

A bunch of useless (and some questionably useful) cogs for Red-DiscordBot (V3)
MIT License
3 stars 10 forks source link

Duels issue #14

Closed kennnyshiwa closed 4 years ago

kennnyshiwa commented 4 years ago

So ona server where my bot is, there is an issue with the duels command which i believe is happening cus the user left so it can't get the display name for that user it produces this error below


  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/bb8/customcogs/duel/duel.py", line 509, in _duels
    await ctx.invoke(self._duels_list)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/context.py", line 132, in invoke
    ret = await command.callback(*arguments, **kwargs)
  File "/home/bb8/customcogs/duel/duel.py", line 551, in _duels_list
    names = {uid: m.display_name for uid, m in members.items()}
  File "/home/bb8/customcogs/duel/duel.py", line 551, in <dictcomp>
    names = {uid: m.display_name for uid, m in members.items()}
AttributeError: 'NoneType' object has no attribute 'display_name'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/redbot/core/commands/commands.py", line 582, in invoke
    await super().invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 1163, in invoke
    await super().invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'display_name'``
baiumbg commented 4 years ago

Added a quick fix for this - might cause the top 10 list to be shorter than it should be, but this should stop any errors from occurring until I get a proper fix for it.

Do [p]cog update for the fix.

kennnyshiwa commented 4 years ago

so that fixed that section but then caused this error to happen as a result


Traceback (most recent call last):
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/bb8/customcogs/duel/duel.py", line 504, in _duels
    await ctx.invoke(self._duels_list)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/context.py", line 132, in invoke
    ret = await command.callback(*arguments, **kwargs)
  File "/home/bb8/customcogs/duel/duel.py", line 560, in _duels_list
    highscore += names[uid].ljust(max_name_len + 4)
KeyError: 620685765277384705

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/redbot/core/commands/commands.py", line 582, in invoke
    await super().invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 1163, in invoke
    await super().invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 620685765277384705```
baiumbg commented 4 years ago

I've fixed that error as well, try it now.

kennnyshiwa commented 4 years ago

Totally forgot all about this, so sorry about that, but can confirm this did fix my issue! Thanks a ton!