-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsticker.go
74 lines (60 loc) · 1.67 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
package objects
import (
"encoding/json"
"strings"
)
//go:generate stringer -type StickerType,StickerFormatType -output sticker_string.go
var _ SnowflakeObject = (*StickerItem)(nil)
var _ SnowflakeObject = (*Sticker)(nil)
var _ SnowflakeObject = (*StickerPack)(nil)
type StickerType int
const (
StickerTypeStandard StickerType = iota + 1
StickerTypeGuild
)
type StickerFormatType int
const (
StickerFormatTypePNG StickerFormatType = iota + 1
StickerFormatTypeAPNG
StickerFormatTypeLOTTIE
)
type StickerTags []string
func (t StickerTags) MarshalJSON() ([]byte, error) {
return json.Marshal(
strings.Join(t, ","),
)
}
func (t StickerTags) UnmarshalJSON(bytes []byte) error {
var tags string
err := json.Unmarshal(bytes, &tags)
if err != nil {
return err
}
t = strings.Split(tags, ",")
return nil
}
type StickerItem struct {
DiscordBaseObject
Name string `json:"name"`
FormatType StickerFormatType `json:"format_type"`
}
type Sticker struct {
StickerItem
PackID Snowflake `json:"pack_id"`
Description string `json:"description"`
Tags string `json:"tags"`
Type StickerType `json:"type"`
Available bool `json:"available,omitempty"`
GuildID Snowflake `json:"guild_id,omitempty"`
User *User `json:"user,omitempty"`
SortValue *int `json:"sort_value,omitempty"`
}
type StickerPack struct {
DiscordBaseObject
Stickers []*Sticker `json:"stickers"`
Name string `json:"name"`
SKU Snowflake `json:"sku_id"`
CoverStickerID Snowflake `json:"cover_sticker_id"`
Description string `json:"description"`
BannerAssetID Snowflake `json:"banner_asset_id"`
}