Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stickers #1057

Merged
merged 5 commits into from Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions endpoints.go
Expand Up @@ -31,6 +31,7 @@ var (
EndpointGateway = EndpointAPI + "gateway"
EndpointGatewayBot = EndpointGateway + "/bot"
EndpointWebhooks = EndpointAPI + "webhooks/"
EndpointStickers = EndpointAPI + "stickers/"

EndpointCDN = "https://cdn.discordapp.com/"
EndpointCDNAttachments = EndpointCDN + "attachments/"
Expand Down Expand Up @@ -102,6 +103,8 @@ var (
EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
EndpointGuildStickers = func(gID string) string { return EndpointGuilds + gID + "/stickers" }
EndpointGuildSticker = func(gID, sID string) string { return EndpointGuilds + gID + "/stickers/" + sID }

EndpointChannel = func(cID string) string { return EndpointChannels + cID }
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
Expand All @@ -119,6 +122,9 @@ var (

EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }

EndpointSticker = func(sID string) string { return EndpointStickers + sID }
EndpointNitroStickersPacks = EndpointAPI + "/sticker-packs"

EndpointChannelWebhooks = func(cID string) string { return EndpointChannel(cID) + "/webhooks" }
EndpointWebhook = func(wID string) string { return EndpointWebhooks + wID }
EndpointWebhookToken = func(wID, token string) string { return EndpointWebhooks + wID + "/" + token }
Expand Down
47 changes: 47 additions & 0 deletions message.go
Expand Up @@ -129,6 +129,9 @@ type Message struct {
// This is a combination of bit masks; the presence of a certain permission can
// be checked by performing a bitwise AND between this int and the flag.
Flags MessageFlags `json:"flags"`

// An array of Sticker objects, if any were sent.
StickerItems []*Sticker `json:"sticker_items"`
}

// UnmarshalJSON is a helper function to unmarshal the Message.
Expand Down Expand Up @@ -188,6 +191,50 @@ 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 {
Jordan-Cartwright marked this conversation as resolved.
Show resolved Hide resolved
ID string `json:"id"`
PackID string `json:"pack_id"`
Name string `json:"name"`
Description string `json:"description"`
Tags string `json:"tags"`
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"`
Expand Down