add (some) sticker support

This commit is contained in:
git-bruh 2021-07-04 15:08:32 +05:30
parent 4db1b48c71
commit 3b47e5af3f
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6
2 changed files with 17 additions and 0 deletions

View file

@ -34,6 +34,13 @@ class MessageReference:
guild_id: str guild_id: str
@dataclass
class Sticker:
name: str
id: str
format_type: int
@dataclass @dataclass
class Typing: class Typing:
user_id: str user_id: str
@ -114,6 +121,11 @@ class Message:
self.author = User(author) if author else None self.author = User(author) if author else None
self.stickers = [
dict_cls(sticker, Sticker)
for sticker in message.get("sticker_items", [])
]
class ChannelType: class ChannelType:
GUILD_TEXT = 0 GUILD_TEXT = 0

View file

@ -656,6 +656,11 @@ class DiscordClient(Gateway):
for attachment in message.attachments: for attachment in message.attachments:
content += f"\n{attachment['url']}" content += f"\n{attachment['url']}"
# Append stickers to message.
for sticker in message.stickers:
if sticker.format_type != 3: # 3 == Lottie format.
content += f"\n{discord.CDN_URL}/stickers/{sticker.id}.png"
return content, emotes return content, emotes