| @@ 209-228 (lines=20) @@ | ||
| 206 | EVERYONE = "everyone" |
|
| 207 | ||
| 208 | ||
| 209 | @dataclass |
|
| 210 | class AllowedMentions(APIObject): |
|
| 211 | parse: List[AllowedMentionTypes] |
|
| 212 | roles: List[Union[Role, Snowflake]] |
|
| 213 | users: List[Union[User, Snowflake]] |
|
| 214 | reply: bool = True |
|
| 215 | ||
| 216 | @staticmethod |
|
| 217 | def get_str_id(obj: Union[Snowflake, User, Role]) -> str: |
|
| 218 | if hasattr(obj, "id"): |
|
| 219 | obj = obj.id |
|
| 220 | ||
| 221 | return str(obj) |
|
| 222 | ||
| 223 | def to_dict(self): |
|
| 224 | return { |
|
| 225 | "parse": self.parse, |
|
| 226 | "roles": list(map(self.get_str_id, self.roles)), |
|
| 227 | "users": list(map(self.get_str_id, self.users)), |
|
| 228 | "replied_user": self.reply |
|
| 229 | } |
|
| 230 | ||
| 231 | ||
| @@ 42-75 (lines=34) @@ | ||
| 39 | from .component import MessageComponent |
|
| 40 | ||
| 41 | ||
| 42 | @dataclass |
|
| 43 | class AllowedMentions(APIObject): |
|
| 44 | """Represents the entities the client can mention |
|
| 45 | ||
| 46 | Attributes |
|
| 47 | ---------- |
|
| 48 | parse: List[:class:`~pincer.objects.message.user_message.AllowedMentionTypes`] |
|
| 49 | An array of allowed mention types to parse from the content. |
|
| 50 | roles: List[Union[:class:`~pincer.objects.guild.role.Role`, :class:`~pincer.utils.snowflake.Snowflake`]] |
|
| 51 | List of ``Role`` objects or snowflakes of allowed mentions. |
|
| 52 | users: List[Union[:class:`~pincer.objects.user.user.User` :class:`~pincer.utils.snowflake.Snowflake`]] |
|
| 53 | List of ``user`` objects or snowflakes of allowed mentions. |
|
| 54 | reply: :class:`bool` |
|
| 55 | If replies should mention the author. |
|
| 56 | |default| :data:`True` |
|
| 57 | """ # noqa: E501 |
|
| 58 | ||
| 59 | parse: List[AllowedMentionTypes] |
|
| 60 | roles: List[Union[Role, Snowflake]] |
|
| 61 | users: List[Union[User, Snowflake]] |
|
| 62 | reply: bool = True |
|
| 63 | ||
| 64 | def to_dict(self): |
|
| 65 | def get_str_id(obj: Union[Snowflake, User, Role]) -> str: |
|
| 66 | if hasattr(obj, "id"): |
|
| 67 | obj = obj.id |
|
| 68 | ||
| 69 | return str(obj) |
|
| 70 | ||
| 71 | return { |
|
| 72 | "parse": self.parse, |
|
| 73 | "roles": list(map(get_str_id, self.roles)), |
|
| 74 | "users": list(map(get_str_id, self.users)), |
|
| 75 | "replied_user": self.reply |
|
| 76 | } |
|
| 77 | ||
| 78 | ||