1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 09:12:53 +00:00

discord: Add StickerItem, fix Sticker.TagList

This commit is contained in:
diamondburned 2022-01-29 03:38:10 -08:00
parent 40ff267a74
commit 3fe7fbc24b
No known key found for this signature in database
GPG key ID: D78C4471CE776659

View file

@ -98,8 +98,8 @@ type Message struct {
// non-null, it is a message object
ReferencedMessage *Message `json:"referenced_message,omitempty"`
// Stickers contains the sticker sent with the message.
Stickers []Sticker `json:"stickers,omitempty"`
// Stickers contains the sticker "items" sent with the message.
Stickers []StickerItem `json:"sticker_items,omitempty"`
}
// URL generates a Discord client URL to the message. If the message doesn't
@ -190,6 +190,18 @@ const (
MessageLoading
)
// StickerItem contains partial data of a Sticker.
//
// https://discord.com/developers/docs/resources/sticker#sticker-item-object
type StickerItem struct {
// ID is the ID of the sticker.
ID StickerID `json:"id"`
// Name is the name of the sticker.
Name string `json:"name"`
// FormatType is the type of sticker format.
FormatType StickerFormatType `json:"format_type"`
}
// https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
type Sticker struct {
// ID is the ID of the sticker.
@ -228,9 +240,14 @@ func (s Sticker) PackCreatedAt() time.Time {
return s.PackID.Time()
}
// TagList splits the sticker tags into a slice of strings.
// TagList splits the sticker tags into a slice of strings. Each tag will have
// its trailing space trimmed.
func (s Sticker) TagList() []string {
return strings.Split(s.Tags, ",")
tags := strings.Split(s.Tags, ",")
for i := range tags {
tags[i] = strings.TrimSpace(tags[i])
}
return tags
}
type StickerType int