|
21 | 21 | from .team import Application |
22 | 22 | from .user import User |
23 | 23 |
|
| 24 | +__all__ = ( |
| 25 | + "MessageType", |
| 26 | + "Message", |
| 27 | + "MessageReference", |
| 28 | + "MessageActivity", |
| 29 | + "MessageInteraction", |
| 30 | + "ChannelMention", |
| 31 | + "Embed", |
| 32 | + "EmbedAuthor", |
| 33 | + "EmbedProvider", |
| 34 | + "EmbedImageStruct", |
| 35 | + "EmbedField", |
| 36 | + "Attachment", |
| 37 | + "Emoji", |
| 38 | + "EmbedFooter", |
| 39 | + "ReactionObject", |
| 40 | + "PartialSticker", |
| 41 | + "Sticker", |
| 42 | +) |
| 43 | + |
24 | 44 |
|
25 | 45 | class MessageType(IntEnum): |
26 | 46 | """An enumerable object representing the types of messages.""" |
@@ -906,6 +926,8 @@ async def edit( |
906 | 926 | :type files: Optional[Union[File, List[File]]] |
907 | 927 | :param embeds?: An embed, or list of embeds for the message. |
908 | 928 | :type embeds: Optional[Union[Embed, List[Embed]]] |
| 929 | + :param suppress_embeds?: Whether to suppress embeds in the message. |
| 930 | + :type suppress_embeds: Optional[bool] |
909 | 931 | :param allowed_mentions?: The message interactions/mention limits that the message can refer to. |
910 | 932 | :type allowed_mentions: Optional[MessageInteraction] |
911 | 933 | :param components?: A component, or list of components for the message. If `[]` the components will be removed |
@@ -1222,12 +1244,56 @@ async def remove_reaction_from( |
1222 | 1244 | if isinstance(emoji, Emoji) |
1223 | 1245 | else emoji |
1224 | 1246 | ) |
| 1247 | + if not self._client: |
| 1248 | + raise AttributeError("HTTPClient not found!") |
1225 | 1249 |
|
1226 | 1250 | _user_id = user if isinstance(user, int) else user.id |
1227 | 1251 | return await self._client.remove_user_reaction( |
1228 | 1252 | channel_id=int(self.channel_id), message_id=int(self.id), user_id=_user_id, emoji=_emoji |
1229 | 1253 | ) |
1230 | 1254 |
|
| 1255 | + async def get_users_from_reaction( |
| 1256 | + self, |
| 1257 | + emoji: Union[str, "Emoji"], |
| 1258 | + ) -> List[User]: |
| 1259 | + """ |
| 1260 | + Retrieves all users that reacted to the message with the given emoji |
| 1261 | +
|
| 1262 | + :param emoji: The Emoji as object or formatted as `name:id` |
| 1263 | + :type emoji: Union[str, Emoji] |
| 1264 | + :return: A list of user objects |
| 1265 | + :rtype: List[User] |
| 1266 | + """ |
| 1267 | + if not self._client: |
| 1268 | + raise AttributeError("HTTPClient not found!") |
| 1269 | + |
| 1270 | + _all_users: List[User] = [] |
| 1271 | + |
| 1272 | + _emoji = ( |
| 1273 | + f":{emoji.name.replace(':', '')}:{emoji.id or ''}" |
| 1274 | + if isinstance(emoji, Emoji) |
| 1275 | + else emoji |
| 1276 | + ) |
| 1277 | + |
| 1278 | + res: List[dict] = await self._client.get_reactions_of_emoji( |
| 1279 | + channel_id=int(self.channel_id), message_id=int(self.id), emoji=_emoji, limit=100 |
| 1280 | + ) |
| 1281 | + |
| 1282 | + while len(res) == 100: |
| 1283 | + _after = int(res[-1]["id"]) |
| 1284 | + _all_users.extend(User(**_) for _ in res) |
| 1285 | + res: List[dict] = await self._client.get_reactions_of_emoji( |
| 1286 | + channel_id=int(self.channel_id), |
| 1287 | + message_id=int(self.id), |
| 1288 | + emoji=_emoji, |
| 1289 | + limit=100, |
| 1290 | + after=_after, |
| 1291 | + ) |
| 1292 | + |
| 1293 | + _all_users.extend(User(**_) for _ in res) |
| 1294 | + |
| 1295 | + return _all_users |
| 1296 | + |
1231 | 1297 | @classmethod |
1232 | 1298 | async def get_from_url(cls, url: str, client: "HTTPClient") -> "Message": # noqa, |
1233 | 1299 | """ |
|
0 commit comments