-
Notifications
You must be signed in to change notification settings - Fork 35
/
sticker.go
94 lines (79 loc) · 2.41 KB
/
sticker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package discord
import (
"time"
"github.com/disgoorg/snowflake/v2"
)
// Sticker is a sticker sent with a Message
type Sticker struct {
ID snowflake.ID `json:"id"`
PackID *snowflake.ID `json:"pack_id"`
Name string `json:"name"`
Description string `json:"description"`
Tags string `json:"tags"`
Type StickerType `json:"type"`
FormatType StickerFormatType `json:"format_type"`
Available *bool `json:"available"`
GuildID *snowflake.ID `json:"guild_id,omitempty"`
User *User `json:"user,omitempty"`
SortValue *int `json:"sort_value"`
}
func (s Sticker) URL(opts ...CDNOpt) string {
format := ImageFormatPNG
if s.FormatType == StickerFormatTypeLottie {
format = ImageFormatLottie
}
return formatAssetURL(CustomSticker, append(opts, WithFormat(format)), s.ID)
}
func (s Sticker) CreatedAt() time.Time {
return s.ID.Time()
}
type StickerType int
const (
StickerTypeStandard StickerType = iota + 1
StickerTypeGuild
)
// StickerFormatType is the Format type of Sticker
type StickerFormatType int
// Constants for StickerFormatType
const (
StickerFormatTypePNG StickerFormatType = iota + 1
StickerFormatTypeAPNG
StickerFormatTypeLottie
)
type StickerCreate struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Tags string `json:"tags"`
File *File `json:"-"`
}
// ToBody returns the MessageCreate ready for body
func (c StickerCreate) ToBody() (any, error) {
if c.File != nil {
return PayloadWithFiles(c, c.File)
}
return c, nil
}
type StickerUpdate struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Tags *string `json:"tags,omitempty"`
}
type StickerPack struct {
ID snowflake.ID `json:"id"`
Stickers []Sticker `json:"stickers"`
Name string `json:"name"`
SkuID snowflake.ID `json:"sku_id"`
CoverStickerID snowflake.ID `json:"cover_sticker_id"`
Description string `json:"description"`
BannerAssetID *snowflake.ID `json:"banner_asset_id"`
}
func (p StickerPack) BannerURL(opts ...CDNOpt) *string {
if p.BannerAssetID == nil {
return nil
}
url := formatAssetURL(StickerPackBanner, opts, p.BannerAssetID)
return &url
}
type StickerPacks struct {
StickerPacks []StickerPack `json:"sticker_packs"`
}