|
8 | 8 | AsyncGenerator,
|
9 | 9 | Dict,
|
10 | 10 | List,
|
| 11 | + Mapping, |
11 | 12 | Optional,
|
12 | 13 | Sequence,
|
13 | 14 | Union,
|
14 |
| - Mapping, |
15 | 15 | )
|
16 | 16 |
|
17 | 17 | import attrs
|
18 | 18 |
|
19 | 19 | import interactions.models as models
|
20 | 20 | from interactions.client.const import GUILD_WELCOME_MESSAGES, MISSING, Absent
|
21 |
| -from interactions.client.errors import ThreadOutsideOfGuild, NotFound |
| 21 | +from interactions.client.errors import NotFound, ThreadOutsideOfGuild |
22 | 22 | from interactions.client.mixins.serialization import DictSerializationMixin
|
23 | 23 | from interactions.client.utils.attr_converters import optional as optional_c
|
24 | 24 | from interactions.client.utils.attr_converters import timestamp_converter
|
25 | 25 | from interactions.client.utils.serializer import dict_filter_none
|
26 | 26 | from interactions.client.utils.text_utils import mentions
|
27 | 27 | from interactions.models.discord.channel import BaseChannel, GuildChannel
|
| 28 | +from interactions.models.discord.embed import process_embeds |
28 | 29 | from interactions.models.discord.emoji import process_emoji_req_format
|
29 | 30 | from interactions.models.discord.file import UPLOADABLE_TYPE
|
30 |
| -from interactions.models.discord.embed import process_embeds |
| 31 | + |
31 | 32 | from .base import DiscordObject
|
32 | 33 | from .enums import (
|
| 34 | + AutoArchiveDuration, |
33 | 35 | ChannelType,
|
34 | 36 | InteractionType,
|
35 | 37 | MentionType,
|
36 | 38 | MessageActivityType,
|
37 | 39 | MessageFlags,
|
38 | 40 | MessageType,
|
39 |
| - AutoArchiveDuration, |
40 | 41 | )
|
41 |
| -from .snowflake import to_snowflake, Snowflake_Type, to_snowflake_list, to_optional_snowflake |
| 42 | +from .snowflake import ( |
| 43 | + Snowflake_Type, |
| 44 | + to_optional_snowflake, |
| 45 | + to_snowflake, |
| 46 | + to_snowflake_list, |
| 47 | +) |
42 | 48 |
|
43 | 49 | if TYPE_CHECKING:
|
44 |
| - from interactions.client import Client |
45 | 50 | from interactions import InteractionContext
|
| 51 | + from interactions.client import Client |
46 | 52 |
|
47 | 53 | __all__ = (
|
48 | 54 | "Attachment",
|
@@ -365,10 +371,13 @@ class Message(BaseMessage):
|
365 | 371 | _referenced_message_id: Optional["Snowflake_Type"] = attrs.field(repr=False, default=None)
|
366 | 372 |
|
367 | 373 | @property
|
368 |
| - async def mention_users(self) -> AsyncGenerator["models.Member", None]: |
| 374 | + async def mention_users(self) -> AsyncGenerator[Union["models.Member", "models.User"], None]: |
369 | 375 | """A generator of users mentioned in this message"""
|
370 | 376 | for u_id in self._mention_ids:
|
371 |
| - yield await self._client.cache.fetch_member(self._guild_id, u_id) |
| 377 | + if self._guild_id: |
| 378 | + yield await self._client.cache.fetch_member(self._guild_id, u_id) |
| 379 | + else: |
| 380 | + yield await self._client.cache.fetch_user(u_id) |
372 | 381 |
|
373 | 382 | @property
|
374 | 383 | async def mention_roles(self) -> AsyncGenerator["models.Role", None]:
|
|
0 commit comments