-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
add support for clan/server tags #10190
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clan
is deprecated
And also, this is undocumented in discord's side. |
def __init__(self, data: ClanTagPayload): | ||
self.identity_guild_id: Optional[int] = (int(data["identity_guild_id"]) if data.get("identity_guild_id") is not None else None) | ||
self.identity_enabled: bool = data.get("identity_enabled", False) | ||
self.tag: Optional[str] = data.get("tag", "null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not make this optional, just use data.get
self.identity_guild_id: Optional[int] = (int(data["identity_guild_id"]) if data.get("identity_guild_id") is not None else None) | ||
self.identity_enabled: bool = data.get("identity_enabled", False) | ||
self.tag: Optional[str] = data.get("tag", "null") | ||
self.badge: Optional[str] = data.get("badge", "null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as mentioned on self.tag
from typing import TypedDict, Optional | ||
from .types.snowflake import Snowflake | ||
|
||
|
||
class ClanTagPayload(TypedDict): | ||
identity_guild_id: Snowflake | ||
identity_enabled: bool | ||
tag: str | ||
badge: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this should be on its discord/types
file, not here.
__slots__ = ("identity_guild_id", "identity_enabled", "tag", "badge") | ||
|
||
def __init__(self, data: ClanTagPayload): | ||
self.identity_guild_id: Optional[int] = (int(data["identity_guild_id"]) if data.get("identity_guild_id") is not None else None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use utils._get_as_snowflake
@@ -25,6 +25,7 @@ | |||
from .snowflake import Snowflake | |||
from typing import Literal, Optional, TypedDict | |||
from typing_extensions import NotRequired | |||
from ..clantag import ClanTagPayload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as mentioned on the TypedDict
@@ -39,6 +40,8 @@ class PartialUser(TypedDict): | |||
avatar: Optional[str] | |||
global_name: Optional[str] | |||
avatar_decoration_data: NotRequired[AvatarDecorationData] | |||
clan: NotRequired[ClanTagPayload] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clan is deprecated, as dolphies said
if clan_data: | ||
self.clan_tag: Optional[ClanTag] = ClanTag(clan_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will raise an attribute error if the clan data is None
Co-authored-by: DA344 <[email protected]>
Summary
adds support for clan/server tags
Checklist
i only bothered to add this bcuz i needed to use it in one of my bots and i was surprised that it hasnt been added yet
this is a super hacky fix and im honestly surprised i got it to work, but it would probably be a good idea to clean it up a bit
why did i spend 3 hours on this what am i doing with my life