Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cannot get user of message interaction #1459

Merged

Conversation

Damego
Copy link
Member

@Damego Damego commented Jun 22, 2023

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

When tries to get user of message interaction via await ctx.message.interaction.user() it raises an exception

Ignoring exception in Component Callback for message_delete:
Traceback (most recent call last):
  File "bot/venv/Lib/site-packages/interactions/client/client.py", line 1890, in __dispatch_interaction
    response = await callback
               ^^^^^^^^^^^^^^
  File "bot/venv/Lib/site-packages/interactions/models/internal/command.py", line 132, in __call__
    await self.call_callback(self.callback, context)
  File "bot/venv/Lib/site-packages/interactions/models/internal/command.py", line 198, in call_callback
    await self.call_with_binding(callback, context, **context.kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bot/venv/Lib/site-packages/interactions/models/internal/callback.py", line 43, in call_with_binding
    return await callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bot/extensions/events.py", line 46, in message_delete
    reference = await ctx.message.interaction.user()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bot/venv/Lib/site-packages/interactions/models/discord/message.py", line 192, in user  
    return await self.get_user(self._user_id)
                 ^^^^^^^^^^^^^
AttributeError: 'MessageInteraction' object has no attribute 'get_user'

Changes

  • Make MessageInteraction.user as property, not as async function.
  • Use self.client.get_user instead of nonexistent self.get_user

Related Issues

Test Scenarios

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@LordOfPolls LordOfPolls merged commit 60edb6f into interactions-py:unstable Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants