From 29f3fa2a782deeb974dd1357f837eb4e565e1507 Mon Sep 17 00:00:00 2001 From: SmoothieNoIce Date: Tue, 15 Feb 2022 21:06:10 +0800 Subject: [PATCH 1/2] Add get guild stickers support --- message.go | 45 --------------------------------------------- structs.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/message.go b/message.go index 7bde46f72..b7b2cf5c4 100644 --- a/message.go +++ b/message.go @@ -192,51 +192,6 @@ type File struct { Reader io.Reader } -// StickerFormat is the file format of the Sticker. -type StickerFormat int - -// Defines all known Sticker types. -const ( - StickerFormatTypePNG StickerFormat = 1 - StickerFormatTypeAPNG StickerFormat = 2 - StickerFormatTypeLottie StickerFormat = 3 -) - -// StickerType is the type of sticker. -type StickerType int - -// Defines Sticker types. -const ( - StickerTypeStandard StickerType = 1 - StickerTypeGuild StickerType = 2 -) - -// Sticker represents a sticker object that can be sent in a Message. -type Sticker struct { - ID string `json:"id"` - PackID string `json:"pack_id"` - Name string `json:"name"` - Description string `json:"description"` - Tags string `json:"tags"` - Type StickerType `json:"type"` - FormatType StickerFormat `json:"format_type"` - Available bool `json:"available"` - GuildID string `json:"guild_id"` - User *User `json:"user"` - SortValue int `json:"sort_value"` -} - -// StickerPack represents a pack of standard stickers. -type StickerPack struct { - ID string `json:"id"` - Stickers []Sticker `json:"stickers"` - Name string `json:"name"` - SKUID string `json:"sku_id"` - CoverStickerID string `json:"cover_sticker_id"` - Description string `json:"description"` - BannerAssetID string `json:"banner_asset_id"` -} - // MessageSend stores all parameters you can send with ChannelMessageSendComplex. type MessageSend struct { Content string `json:"content,omitempty"` diff --git a/structs.go b/structs.go index 9d7c1fccb..146bc8bd5 100644 --- a/structs.go +++ b/structs.go @@ -383,6 +383,51 @@ func (e *Emoji) APIName() string { return e.ID } +// StickerFormat is the file format of the Sticker. +type StickerFormat int + +// Defines all known Sticker types. +const ( + StickerFormatTypePNG StickerFormat = 1 + StickerFormatTypeAPNG StickerFormat = 2 + StickerFormatTypeLottie StickerFormat = 3 +) + +// StickerType is the type of sticker. +type StickerType int + +// Defines Sticker types. +const ( + StickerTypeStandard StickerType = 1 + StickerTypeGuild StickerType = 2 +) + +// Sticker represents a sticker object that can be sent in a Message. +type Sticker struct { + ID string `json:"id"` + PackID string `json:"pack_id"` + Name string `json:"name"` + Description string `json:"description"` + Tags string `json:"tags"` + Type StickerType `json:"type"` + FormatType StickerFormat `json:"format_type"` + Available bool `json:"available"` + GuildID string `json:"guild_id"` + User *User `json:"user"` + SortValue int `json:"sort_value"` +} + +// StickerPack represents a pack of standard stickers. +type StickerPack struct { + ID string `json:"id"` + Stickers []Sticker `json:"stickers"` + Name string `json:"name"` + SKUID string `json:"sku_id"` + CoverStickerID string `json:"cover_sticker_id"` + Description string `json:"description"` + BannerAssetID string `json:"banner_asset_id"` +} + // VerificationLevel type definition type VerificationLevel int @@ -486,6 +531,9 @@ type Guild struct { // A list of the custom emojis present in the guild. Emojis []*Emoji `json:"emojis"` + // A list of the custom stickers present in the guild. + Stickers []*Sticker `json:"stickers"` + // A list of the members in the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. From c46d67a758c0abd4f86f3a940d5a29fee246a68f Mon Sep 17 00:00:00 2001 From: flexolk Date: Thu, 17 Feb 2022 12:24:33 +0000 Subject: [PATCH 2/2] fix: change the type of Stickers of StickerPack to array pointer --- structs.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/structs.go b/structs.go index 146bc8bd5..dd174639d 100644 --- a/structs.go +++ b/structs.go @@ -419,13 +419,13 @@ type Sticker struct { // StickerPack represents a pack of standard stickers. type StickerPack struct { - ID string `json:"id"` - Stickers []Sticker `json:"stickers"` - Name string `json:"name"` - SKUID string `json:"sku_id"` - CoverStickerID string `json:"cover_sticker_id"` - Description string `json:"description"` - BannerAssetID string `json:"banner_asset_id"` + ID string `json:"id"` + Stickers []*Sticker `json:"stickers"` + Name string `json:"name"` + SKUID string `json:"sku_id"` + CoverStickerID string `json:"cover_sticker_id"` + Description string `json:"description"` + BannerAssetID string `json:"banner_asset_id"` } // VerificationLevel type definition