Skip to content

Conversation

@AlbertUnruh
Copy link
Contributor

@AlbertUnruh AlbertUnruh commented Mar 30, 2023

About

This PR fixes a bug where self.channel can be None.

(The actual bug isn't fixed since the channel-property would have to be asynchronous, but one case where channel.id is used is fixed...)

Checklist

  • The pre-commit code linter has been run over all edited files to ensure the code is linted.
  • I've ensured the change(s) work on 3.8.6 and higher.
  • I have added the versionadded, versionchanged and deprecated to any new or changed user-facing function I committed.

Pull-Request specification

I've made this pull request: (check all that apply)

  • For the documentation
  • To add a new feature
  • As a general enhancement
  • As a refactor of the library/the library's code
  • To fix an existing bug
  • To resolve #ISSUENUMBER

This is:

  • A breaking change

*Inside Prefixed Commands

Traceback before applying the fix:

  File "/home/albert/PycharmProjects/Alberto-X3-V4/extensions/administration/sudo/ext.py", line 80, in sudo
    await ctx.reply("test...")
  File "/home/albert/.local/share/virtualenvs/Alberto-X3-V4-WQLHrZIA/lib/python3.11/site-packages/interactions/ext/prefixed_commands/context.py", line 98, in reply
    return await self.send(content=content, reply_to=self.message, embeds=embeds or embed, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/albert/.local/share/virtualenvs/Alberto-X3-V4-WQLHrZIA/lib/python3.11/site-packages/interactions/client/mixins/send.py", line 97, in send
    message_data = await self._send_http_request(message_payload, files=files or file)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/albert/.local/share/virtualenvs/Alberto-X3-V4-WQLHrZIA/lib/python3.11/site-packages/interactions/ext/prefixed_commands/context.py", line 76, in _send_http_request
    return await self.client.http.create_message(message_payload, self.channel.id, files=files)
                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'

`self.channel_id` is given at any point but `self.channel` can be `None` if (DM-) channel isn't cached
@LordOfPolls LordOfPolls merged commit 485ee87 into interactions-py:5.x Apr 1, 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.

2 participants