From bc648e927bb0b90e287cf3cb29cc7c260f0a2f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=98en=20Fylling?= Date: Sat, 7 Aug 2021 13:51:35 +0200 Subject: [PATCH] mark Stickers deprecated --- iface_copier_gen.go | 4 +++ iface_reseter_gen.go | 1 + message.go | 60 +++++++++++++++++++++++--------------------- sort_gen.go | 14 +++++++++++ 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/iface_copier_gen.go b/iface_copier_gen.go index 13821a7e..791d347f 100644 --- a/iface_copier_gen.go +++ b/iface_copier_gen.go @@ -597,6 +597,10 @@ func (m *Message) copyOverTo(other interface{}) error { dest.ReferencedMessage = m.ReferencedMessage dest.SpoilerTagAllAttachments = m.SpoilerTagAllAttachments dest.SpoilerTagContent = m.SpoilerTagContent + dest.StickerItems = make([]*StickerItem, len(m.StickerItems)) + for i := 0; i < len(m.StickerItems); i++ { + dest.StickerItems[i] = DeepCopy(m.StickerItems[i]).(*StickerItem) + } dest.Stickers = make([]*MessageSticker, len(m.Stickers)) for i := 0; i < len(m.Stickers); i++ { dest.Stickers[i] = DeepCopy(m.Stickers[i]).(*MessageSticker) diff --git a/iface_reseter_gen.go b/iface_reseter_gen.go index 4fccaa7e..0a7d4153 100644 --- a/iface_reseter_gen.go +++ b/iface_reseter_gen.go @@ -139,6 +139,7 @@ func (m *Message) reset() { } m.SpoilerTagAllAttachments = false m.SpoilerTagContent = false + m.StickerItems = nil m.Stickers = nil m.Timestamp = Time{} m.Tts = false diff --git a/message.go b/message.go index a7b0af9e..515dc69a 100644 --- a/message.go +++ b/message.go @@ -155,35 +155,37 @@ var _ DeepCopier = (*MessageSticker)(nil) // Message https://discord.com/developers/docs/resources/channel#message-object-message-structure type Message struct { - ID Snowflake `json:"id"` - ChannelID Snowflake `json:"channel_id"` - GuildID Snowflake `json:"guild_id"` - Author *User `json:"author"` - Member *Member `json:"member"` - Content string `json:"content"` - Timestamp Time `json:"timestamp"` - EditedTimestamp Time `json:"edited_timestamp"` // ? - Tts bool `json:"tts"` - MentionEveryone bool `json:"mention_everyone"` - Mentions []*User `json:"mentions"` - MentionRoles []Snowflake `json:"mention_roles"` - MentionChannels []*MentionChannel `json:"mention_channels"` - Attachments []*Attachment `json:"attachments"` - Embeds []*Embed `json:"embeds"` - Reactions []*Reaction `json:"reactions"` // ? - Nonce interface{} `json:"nonce"` // NOT A SNOWFLAKE! DONT TOUCH! - Pinned bool `json:"pinned"` - WebhookID Snowflake `json:"webhook_id"` // ? - Type MessageType `json:"type"` - Activity MessageActivity `json:"activity"` - Application MessageApplication `json:"application"` - MessageReference *MessageReference `json:"message_reference"` - ReferencedMessage *Message `json:"referenced_message"` - Flags MessageFlag `json:"flags"` - StickerItems []*StickerItem `json:"sticker_items"` - Stickers []*MessageSticker `json:"stickers"` - Components []*MessageComponent `json:"components"` - Interaction *MessageInteraction `json:"interaction"` + ID Snowflake `json:"id"` + ChannelID Snowflake `json:"channel_id"` + GuildID Snowflake `json:"guild_id"` + Author *User `json:"author"` + Member *Member `json:"member"` + Content string `json:"content"` + Timestamp Time `json:"timestamp"` + EditedTimestamp Time `json:"edited_timestamp"` // ? + Tts bool `json:"tts"` + MentionEveryone bool `json:"mention_everyone"` + Mentions []*User `json:"mentions"` + MentionRoles []Snowflake `json:"mention_roles"` + MentionChannels []*MentionChannel `json:"mention_channels"` + Attachments []*Attachment `json:"attachments"` + Embeds []*Embed `json:"embeds"` + Reactions []*Reaction `json:"reactions"` // ? + Nonce interface{} `json:"nonce"` // NOT A SNOWFLAKE! DONT TOUCH! + Pinned bool `json:"pinned"` + WebhookID Snowflake `json:"webhook_id"` // ? + Type MessageType `json:"type"` + Activity MessageActivity `json:"activity"` + Application MessageApplication `json:"application"` + MessageReference *MessageReference `json:"message_reference"` + ReferencedMessage *Message `json:"referenced_message"` + Flags MessageFlag `json:"flags"` + StickerItems []*StickerItem `json:"sticker_items"` + + // Deprecated + Stickers []*MessageSticker `json:"stickers"` + Components []*MessageComponent `json:"components"` + Interaction *MessageInteraction `json:"interaction"` // SpoilerTagContent is only true if the entire message text is tagged as a spoiler (aka completely wrapped in ||) SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` diff --git a/sort_gen.go b/sort_gen.go index 5b4d2193..2f8be879 100644 --- a/sort_gen.go +++ b/sort_gen.go @@ -255,6 +255,8 @@ func derefSliceP(v interface{}) (s interface{}) { s = *t case *[]*MessageSticker: s = *t + case *[]*StickerItem: + s = *t case *[]*GetReactionURLParams: s = *t case *[]*Reaction: @@ -443,6 +445,12 @@ func sortByID(v interface{}, flags Flag) { } else { less = func(i, j int) bool { return s[i].ID < s[j].ID } } + case []*StickerItem: + if descending { + less = func(i, j int) bool { return s[i].ID > s[j].ID } + } else { + less = func(i, j int) bool { return s[i].ID < s[j].ID } + } case []*Role: if descending { less = func(i, j int) bool { return s[i].ID > s[j].ID } @@ -923,6 +931,12 @@ func sortByName(v interface{}, flags Flag) { } else { less = func(i, j int) bool { return strings.ToLower(s[i].Name) < strings.ToLower(s[j].Name) } } + case []*StickerItem: + if descending { + less = func(i, j int) bool { return strings.ToLower(s[i].Name) > strings.ToLower(s[j].Name) } + } else { + less = func(i, j int) bool { return strings.ToLower(s[i].Name) < strings.ToLower(s[j].Name) } + } case []*Role: if descending { less = func(i, j int) bool { return strings.ToLower(s[i].Name) > strings.ToLower(s[j].Name) }