Skip to content

Add support for new RPC fields#10227

Merged
Rapptz merged 6 commits intoRapptz:masterfrom
Soheab:new-rpc-fields
Jul 30, 2025
Merged

Add support for new RPC fields#10227
Rapptz merged 6 commits intoRapptz:masterfrom
Soheab:new-rpc-fields

Conversation

@Soheab
Copy link
Contributor

@Soheab Soheab commented Jul 11, 2025

Summary

discord/discord-api-docs#7674

Enum names are upped cased because name is an existing attribute.
Bots don't support any of this, just like before.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Rapptz
Copy link
Owner

Rapptz commented Jul 11, 2025

Make them lowercase.

The code does not care.

>>> from discord.enums import Enum
>>> class X(Enum):
...     name = 1
...
>>> X.name
<X.name: 1>

@Soheab
Copy link
Contributor Author

Soheab commented Jul 11, 2025

Make them lowercase.

The code does not care.

>>> from discord.enums import Enum
>>> class X(Enum):
...     name = 1
...
>>> X.name
<X.name: 1>

Works. But the type checker doesn't understand it:

class Enum(discord.Enum):
    name = 0
    # Type "Literal[0]" is not assignable to declared type "DynamicClassAttribute"
    # "Literal[0]" is not assignable to "DynamicClassAttribute" Pylance reportAssignmentType

e = Enum.name
reveal_type(e) # DynamicClassAttribute
reveal_type(e.name)
# Cannot access attribute "name" for class "DynamicClassAttribute"
#  Attribute "name" is unknown Pylance reportAttributeAccessIssue
reveal_type(e.value)
# Cannot access attribute "value" for class "DynamicClassAttribute"
#  Attribute "value" is unknown Pylance reportAttributeAccessIssue

@Rapptz
Copy link
Owner

Rapptz commented Jul 11, 2025

File a bug with pylance.

>>> import enum
>>> class Y(enum.Enum):
...   name = 1
...
>>> Y.name
<Y.name: 1>

@Soheab
Copy link
Contributor Author

Soheab commented Jul 11, 2025

File a bug with pylance.

>>> import enum
>>> class Y(enum.Enum):
...   name = 1
...
>>> Y.name
<Y.name: 1>

It's apparently as designed. But i've lower-cased them.

Copy link
Owner

@Rapptz Rapptz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly okay, just fix the pre-existing nits as well.



class StatusDisplayType(Enum):
name = 0 # pyright: ignore[reportAssignmentType]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we figure out how this looks from a user's POV when they try using this attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still the same as before when accessing .name or .value from the member, and no response to the comment left on the Pyright repository about it.

But to be fair, it works fine when setting or comparing it:

act = discord.Activity(
    ...
    status_display_type=discord.StatusDisplayType.name,
)
print(act.status_display_type) # StatusDisplayType.name
if act.status_display_type is discord.StatusDisplayType.name:
    print("Status display type is name")

@Rapptz Rapptz merged commit 6e7fc13 into Rapptz:master Jul 30, 2025
8 checks passed
@owocado owocado mentioned this pull request Jul 30, 2025
6 tasks
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.

4 participants