lexicalunit/spellbot

'NoneType' object has no attribute 'name' - MOD_PREFIX code

lexicalunit opened this issue · 0 comments

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/asgiref/sync.py", line 472, in thread_handler
    raise exc_info[1]
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 99, in create
    await action.upsert_request_objects()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 68, in upsert_request_objects
    await self.handle_verification()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 77, in handle_verification
    if not user_can_moderate(self.interaction.user, self.guild, self.channel):
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 161, in user_can_moderate
    return any(
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 162, in <genexpr>
    role.name == settings.ADMIN_ROLE or role.name.startswith(settings.MOD_PREFIX)
AttributeError: 'NoneType' object has no attribute 'name'
[2022-11-20 12:48:54][spellbot.utils][ERROR] - error: unhandled exception in interaction `1043870552793821275`: AttributeError: 'NoneType' object has no attribute 'name'
  File "/usr/local/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "/usr/local/lib/python3.10/site-packages/spellbot/views/lfg_view.py", line 54, in leave
    async with LeaveAction.create(self.bot, interaction) as action:
  File "/usr/local/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 102, in create
    await handle_exception(ex)
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 99, in create
    await action.upsert_request_objects()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 68, in upsert_request_objects
    await self.handle_verification()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 77, in handle_verification
    if not user_can_moderate(self.interaction.user, self.guild, self.channel):
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 161, in user_can_moderate
    return any(
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 162, in <genexpr>
    role.name == settings.ADMIN_ROLE or role.name.startswith(settings.MOD_PREFIX)
[2022-11-20 12:48:55][spellbot.actions.base_action][ERROR] - error: rolling back database session due to unhandled exception: AttributeError: 'NoneType' object has no attribute 'name'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/asgiref/sync.py", line 472, in thread_handler
    raise exc_info[1]
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 99, in create
    await action.upsert_request_objects()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 68, in upsert_request_objects
    await self.handle_verification()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 77, in handle_verification
    if not user_can_moderate(self.interaction.user, self.guild, self.channel):
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 161, in user_can_moderate
    return any(
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 162, in <genexpr>
    role.name == settings.ADMIN_ROLE or role.name.startswith(settings.MOD_PREFIX)
AttributeError: 'NoneType' object has no attribute 'name'
[2022-11-20 12:48:55][spellbot.utils][ERROR] - error: unhandled exception in interaction `1043870557776646214`: AttributeError: 'NoneType' object has no attribute 'name'
  File "/usr/local/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "/usr/local/lib/python3.10/site-packages/spellbot/views/lfg_view.py", line 54, in leave
    async with LeaveAction.create(self.bot, interaction) as action:
  File "/usr/local/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 102, in create
    await handle_exception(ex)
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 99, in create
    await action.upsert_request_objects()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 68, in upsert_request_objects
    await self.handle_verification()
  File "/usr/local/lib/python3.10/site-packages/spellbot/actions/base_action.py", line 77, in handle_verification
    if not user_can_moderate(self.interaction.user, self.guild, self.channel):
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 161, in user_can_moderate
    return any(
  File "/usr/local/lib/python3.10/site-packages/spellbot/utils.py", line 162, in <genexpr>
    role.name == settings.ADMIN_ROLE or role.name.startswith(settings.MOD_PREFIX)