This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
✨ ⚡ Added Mentionable type and improved Interaction performance #253
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5352629
:sparkles: made GuildMember inherit from User
Lunarmagpie 2a1e3fc
:zap: Fixed incorrect user of Interaction data and added mentionable
Lunarmagpie b3507fa
:memo: updated docs
Lunarmagpie 9a50b7f
Merge remote-tracking branch 'upstream/main' into mentionable
Lunarmagpie d63c55f
:bug: put back changes that were accidently reverted
Lunarmagpie c4e6304
:memo: updated docs
Lunarmagpie b939361
:art: codacity changes
Lunarmagpie 4822c84
Update pincer/objects/guild/member.py
Lunarmagpie e91ace4
:recycle: simplified return_type() method
Lunarmagpie 0ec9de3
:art: made id APINullable
Lunarmagpie 7240046
Merge branch 'mentionable' of https://github.com/Lunarmagpie/Pincer i…
Lunarmagpie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright Pincer 2021-Present | ||
# Full MIT License can be found in `LICENSE` at the project root. | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
from ...objects.guild.role import Role | ||
from ...objects.user.user import User | ||
|
||
|
||
@dataclass | ||
class Mentionable: | ||
""" | ||
Represents the Mentionable type | ||
|
||
user : Optional[:class:`~pincer.objects.user.user.User`] | ||
User object returned from a discord interaction | ||
role: Optional[:class:`~pincer.objects.guild.role.Role`] | ||
Role object returned from a discord interaction | ||
""" | ||
user: Optional[User] = None | ||
role: Optional[Role] = None | ||
|
||
@property | ||
def is_user(self): | ||
"""Returns true if the Mentionable object has a User""" | ||
return self.user is not None | ||
|
||
@property | ||
def is_role(self): | ||
"""Returns true if the Mentionable object has a Role""" | ||
return self.role is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
does this big
elif
chain is actually any faster?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.
No idea. It's there now since Mentionable runs two different functions so a dictionary doesn't work.
The optimazatiom comes from me removing unnecessary request to the discord API.