discord: Add StickerURLWithType

This commit adds the StickerURLWithType methods into Sticker and
StickerItem types. No Lottie support is added yet, because I'm not sure
what the filename format for that is.
This commit is contained in:
diamondburned 2022-05-08 16:03:57 -07:00
parent 4b6bc657dc
commit e09abfdbcb
No known key found for this signature in database
GPG Key ID: D78C4471CE776659
1 changed files with 14 additions and 0 deletions

View File

@ -202,6 +202,13 @@ type StickerItem struct {
FormatType StickerFormatType `json:"format_type"`
}
// StickerURLWithType returns the URL to the emoji's image.
//
// Supported ImageTypes: PNG
func (s StickerItem) StickerURLWithType(t ImageType) string {
return "https://cdn.discordapp.com/stickers/" + t.format(s.ID.String())
}
// https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
type Sticker struct {
// ID is the ID of the sticker.
@ -250,6 +257,13 @@ func (s Sticker) TagList() []string {
return tags
}
// StickerURLWithType returns the URL to the emoji's image.
//
// Supported ImageTypes: PNG
func (s Sticker) StickerURLWithType(t ImageType) string {
return "https://cdn.discordapp.com/stickers/" + t.format(s.ID.String())
}
type StickerType int
// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types