23
23
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24
24
DEALINGS IN THE SOFTWARE.
25
25
"""
26
+ from __future__ import annotations
27
+
28
+ from typing import (
29
+ Optional ,
30
+ TYPE_CHECKING ,
31
+ Union ,
32
+ )
33
+
34
+ if TYPE_CHECKING :
35
+ from .types .message import Reaction as ReactionPayload
36
+ from .message import Message
37
+ from .emoji import Emoji
38
+ from .partial_emoji import PartialEmoji
39
+ from .abc import Snowflake
26
40
27
41
from .iterators import ReactionIterator
28
42
43
+
29
44
class Reaction :
30
45
"""Represents a reaction to a message.
31
46
32
- Depending on the way this object was created, some of the attributes can
47
+ Depending on the way this object was created, some attributes can
33
48
have a value of ``None``.
34
49
35
50
.. container:: operations
@@ -55,7 +70,7 @@ class Reaction:
55
70
Attributes
56
71
-----------
57
72
emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]
58
- The reaction emoji. May be a custom emoji, or a unicode emoji.
73
+ The reaction emoji. Might be a custom emoji, or a unicode emoji.
59
74
count: :class:`int`
60
75
Number of times this reaction was made
61
76
me: :class:`bool`
@@ -65,35 +80,35 @@ class Reaction:
65
80
"""
66
81
__slots__ = ('message' , 'count' , 'emoji' , 'me' )
67
82
68
- def __init__ (self , * , message , data , emoji = None ):
69
- self .message = message
70
- self .emoji = emoji or message ._state .get_reaction_emoji (data ['emoji' ])
71
- self .count = data .get ('count' , 1 )
72
- self .me = data .get ('me' )
83
+ def __init__ (self , * , message : Message , data : ReactionPayload , emoji : Optional [ Union [ Emoji , PartialEmoji , str ]] = None ):
84
+ self .message : Message = message
85
+ self .emoji : Union [ Emoji , PartialEmoji , str ] = emoji or message ._state .get_reaction_emoji (data ['emoji' ])
86
+ self .count : int = data .get ('count' , 1 )
87
+ self .me : bool = data .get ('me' )
73
88
74
89
@property
75
- def custom_emoji (self ):
90
+ def custom_emoji (self ) -> bool :
76
91
""":class:`bool`: If this is a custom emoji."""
77
92
return not isinstance (self .emoji , str )
78
93
79
- def __eq__ (self , other ):
94
+ def __eq__ (self , other ) -> bool :
80
95
return isinstance (other , self .__class__ ) and other .emoji == self .emoji
81
96
82
- def __ne__ (self , other ):
97
+ def __ne__ (self , other ) -> bool :
83
98
if isinstance (other , self .__class__ ):
84
99
return other .emoji != self .emoji
85
100
return True
86
101
87
- def __hash__ (self ):
102
+ def __hash__ (self ) -> int :
88
103
return hash (self .emoji )
89
104
90
- def __str__ (self ):
105
+ def __str__ (self ) -> str :
91
106
return str (self .emoji )
92
107
93
- def __repr__ (self ):
108
+ def __repr__ (self ) -> str :
94
109
return '<Reaction emoji={0.emoji!r} me={0.me} count={0.count}>' .format (self )
95
110
96
- async def remove (self , user ) :
111
+ async def remove (self , user : Snowflake ) -> None :
97
112
"""|coro|
98
113
99
114
Remove the reaction by the provided :class:`User` from the message.
@@ -121,7 +136,7 @@ async def remove(self, user):
121
136
122
137
await self .message .remove_reaction (self .emoji , user )
123
138
124
- async def clear (self ):
139
+ async def clear (self ) -> None :
125
140
"""|coro|
126
141
127
142
Clears this reaction from the message.
@@ -143,7 +158,7 @@ async def clear(self):
143
158
"""
144
159
await self .message .clear_reaction (self .emoji )
145
160
146
- def users (self , limit = None , after = None ):
161
+ def users (self , limit : Optional [ int ] = None , after : Optional [ Snowflake ] = None ) -> ReactionIterator :
147
162
"""Returns an :class:`AsyncIterator` representing the users that have reacted to the message.
148
163
149
164
The ``after`` parameter must represent a member
0 commit comments