1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 17:23:00 +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 // non-null, it is a message object
ReferencedMessage *Message `json:"referenced_message,omitempty"` ReferencedMessage *Message `json:"referenced_message,omitempty"`
// Stickers contains the sticker sent with the message. // Stickers contains the sticker "items" sent with the message.
Stickers []Sticker `json:"stickers,omitempty"` Stickers []StickerItem `json:"sticker_items,omitempty"`
} }
// URL generates a Discord client URL to the message. If the message doesn't // URL generates a Discord client URL to the message. If the message doesn't
@ -190,6 +190,18 @@ const (
MessageLoading 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 // https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
type Sticker struct { type Sticker struct {
// ID is the ID of the sticker. // ID is the ID of the sticker.
@ -228,9 +240,14 @@ func (s Sticker) PackCreatedAt() time.Time {
return s.PackID.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 { 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 type StickerType int