Skip to content

Commit

Permalink
fix: values access before interaction (#2104)
Browse files Browse the repository at this point in the history

Signed-off-by: plun1331 <49261529+plun1331@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
plun1331 and pre-commit-ci[bot] committed Jun 9, 2023
1 parent 36fea34 commit 7c71c9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2079](https://github.com/Pycord-Development/pycord/pull/2079))
- Fixed `HTTPException` when trying to create a forum thread with files.
([#2075](https://github.com/Pycord-Development/pycord/pull/2075))
- Fixed `AttributeError` when accessing a `Select`'s values when it hasn't been
interacted with. ([#2104](https://github.com/Pycord-Development/pycord/pull/2104))

## [2.4.1] - 2023-03-20

Expand Down
9 changes: 6 additions & 3 deletions discord/ui/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,13 @@ def values(
| list[Member | User | Role]
| list[GuildChannel | Thread]
):
"""Union[List[:class:`str`], List[Union[:class:`discord.Member`, :class:`discord.User`]], List[:class:`discord.Role`]],
List[Union[:class:`discord.Member`, :class:`discord.User`, :class:`discord.Role`]], List[:class:`discord.abc.GuildChannel`]]:
A list of values that have been selected by the user.
"""List[:class:`str`] | List[:class:`discord.Member` | :class:`discord.User`]] | List[:class:`discord.Role`]] |
List[:class:`discord.Member` | :class:`discord.User` | :class:`discord.Role`]] | List[:class:`discord.abc.GuildChannel`] | None:
A list of values that have been selected by the user. This will be ``None`` if the select has not been interacted with yet.
"""
if self._interaction is None:
# The select has not been interacted with yet
return None
select_type = self._underlying.type
if select_type is ComponentType.string_select:
return self._selected_values
Expand Down

0 comments on commit 7c71c9f

Please sign in to comment.