Skip to content

Commit 893117b

Browse files
committed
document emoji.go
1 parent ee38187 commit 893117b

File tree

2 files changed

+109
-72
lines changed

2 files changed

+109
-72
lines changed

api/emoji.go

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,91 @@
1717
package api
1818

1919
import (
20+
"encoding/base64"
2021
"fmt"
2122
"net/http"
2223

2324
"github.com/veteran-software/discord-api-wrapper/routes"
2425
)
2526

26-
/*
27-
Emoji
28-
29-
ID: emoji id
30-
31-
Name: emoji name
32-
33-
Roles: roles allowed to use this emoji
34-
35-
User: user that created this emoji
36-
37-
RequireColons: whether this emoji must be wrapped in colons
38-
39-
Managed: whether this emoji is managed
40-
41-
Animated: whether this emoji is animated
42-
43-
Available: whether this emoji can be used, may be false due to loss of Server Boosts
44-
*/
27+
// Emoji - Routes for controlling emojis do not follow the normal rate limit conventions.
28+
//
29+
// These routes are specifically limited on a per-guild basis to prevent abuse.
30+
//
31+
// This means that the quota returned by our APIs may be inaccurate, and you may encounter 429s.
4532
type Emoji struct {
46-
ID *Snowflake `json:"id"`
47-
Name string `json:"name"`
48-
Roles []Role `json:"roles,omitempty"`
49-
User *User `json:"user,omitempty"`
50-
RequireColons bool `json:"require_colons,omitempty"`
51-
Managed bool `json:"managed,omitempty"`
52-
Animated bool `json:"animated,omitempty"`
53-
Available bool `json:"available,omitempty"`
33+
ID *Snowflake `json:"id"` // ID - emoji id
34+
Name string `json:"name"` // Name - emoji name
35+
Roles []Role `json:"roles,omitempty"` // Roles - roles allowed to use this emoji
36+
User *User `json:"user,omitempty"` // User - user that created this emoji
37+
RequireColons bool `json:"require_colons,omitempty"` // RequireColons - whether this emoji must be wrapped in colons
38+
Managed bool `json:"managed,omitempty"` // Managed - whether this emoji is managed
39+
Animated bool `json:"animated,omitempty"` // Animated - whether this emoji is animated
40+
Available bool `json:"available,omitempty"` // Available - whether this emoji can be used, may be false due to loss of Server Boosts
5441
}
5542

56-
// ListGuildEmojis
57-
// Returns a list of emoji objects for the given guild.
43+
// ListGuildEmojis - Returns a list of emoji objects for the given guild.
5844
func (g *Guild) ListGuildEmojis() (method string, route string) {
5945
return http.MethodGet, fmt.Sprintf(routes.Guilds_Emojis, api, g.ID.String())
6046
}
6147

62-
// GetGuildEmoji
63-
// Returns an emoji object for the given guild and emoji IDs.
48+
// GetGuildEmoji - Returns an emoji object for the given guild and emoji IDs.
6449
func (g *Guild) GetGuildEmoji(emoji Emoji) (method string, route string) {
6550
return http.MethodGet, fmt.Sprintf(routes.Guilds_Emojis_, api, g.ID.String(), emoji.ID.String())
6651
}
6752

53+
// CreateGuildEmoji - Create a new emoji for the guild.
54+
//
55+
// Requires the ManageEmojisAndStickers permission.
56+
//
57+
// Returns the new Emoji object on success.
58+
//
59+
// Fires a Guild Emojis Update Gateway event.
60+
//
61+
// Emojis and animated emojis have a maximum file size of 256kb.
62+
//
63+
// Attempting to upload an emoji larger than this limit will fail and return "400 Bad Request" and an error message, but not a JSON status code.
64+
//
65+
// This endpoint supports the "X-Audit-Log-Reason" header.
6866
func (g *Guild) CreateGuildEmoji() (method string, route string) {
6967
return http.MethodPost, fmt.Sprintf(routes.Guilds_Emojis, api, g.ID.String())
7068
}
69+
70+
type CreateEmojiJSON struct {
71+
Name string `json:"name"` // Name - name of the emoji
72+
Image base64.Encoding `json:"image"` // Image - the 128x128 emoji image
73+
Roles []Snowflake `json:"roles"` // Roles - roles allowed to use this emoji
74+
}
75+
76+
// ModifyGuildEmoji - Modify the given emoji.
77+
//
78+
// Requires the ManageEmojisAndStickers permission.
79+
//
80+
// Returns the updated emoji object on success.
81+
//
82+
// Fires a Guild Emojis Update Gateway event.
83+
//
84+
// All JSON parameters to this endpoint are optional.
85+
//
86+
// This endpoint supports the X-Audit-Log-Reason header.
87+
func (g *Guild) ModifyGuildEmoji(emoji Emoji) (method string, route string) {
88+
return http.MethodPatch, fmt.Sprintf(routes.Guilds_Emojis_, api, g.ID.String(), emoji.ID.String())
89+
}
90+
91+
type ModifyGuildEmojiJSON struct {
92+
Name string `json:"name,omitempty"` //Name - name of the emoji
93+
Roles *[]Snowflake `json:"roles,omitempty"` // Roles - roles allowed to use this emoji
94+
}
95+
96+
// DeleteGuildEmoji - Delete the given emoji.
97+
//
98+
// Requires the ManageEmojisAndStickers permission.
99+
//
100+
// Returns "204 No Content" on success.
101+
//
102+
// Fires a Guild Emojis Update Gateway event.
103+
//
104+
// This endpoint supports the "X-Audit-Log-Reason" header.
105+
func (g *Guild) DeleteGuildEmoji(emoji Emoji) (method string, route string) {
106+
return http.MethodDelete, fmt.Sprintf(routes.Guilds_Emojis_, api, g.ID.String(), emoji.ID.String())
107+
}

api/permissions.go

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,47 @@ import (
2121
)
2222

2323
const (
24-
CreateInstantInvite int64 = 1 << 0
25-
KickMembers int64 = 1 << 1
26-
BanMembers int64 = 1 << 2
27-
Administrator int64 = 1 << 3
28-
ManageChannels int64 = 1 << 4
29-
ManageGuild int64 = 1 << 5
30-
AddReactions int64 = 1 << 6
31-
ViewAuditLogs int64 = 1 << 7
32-
PrioritySpeaker int64 = 1 << 8
33-
Stream int64 = 1 << 9
34-
ViewChannel int64 = 1 << 10
35-
SendMessages int64 = 1 << 11 // Does not allow for sending messages in Threads
36-
SendTtsMessages int64 = 1 << 12
37-
ManageMessages int64 = 1 << 13
38-
EmbedLinks int64 = 1 << 14
39-
AttachFiles int64 = 1 << 15
40-
ReadMessageHistory int64 = 1 << 16
41-
MentionEveryone int64 = 1 << 17
42-
UseExternalEmojis int64 = 1 << 18
43-
ViewGuildInsights int64 = 1 << 19
44-
Connect int64 = 1 << 20
45-
Speak int64 = 1 << 21
46-
MuteMembers int64 = 1 << 22
47-
DeafenMembers int64 = 1 << 23
48-
MoveMembers int64 = 1 << 24
49-
UseVoiceActivity int64 = 1 << 25
50-
ChangeNickname int64 = 1 << 26
51-
ManageNicknames int64 = 1 << 27
52-
ManageRoles int64 = 1 << 28
53-
ManageWebhooks int64 = 1 << 29
54-
ManageEmojis int64 = 1 << 30
55-
UseSlashCommands int64 = 1 << 31
56-
RequestToSpeak int64 = 1 << 32
57-
_ int64 = 1 << 33
58-
ManageThreads int64 = 1 << 34
59-
CreatePublicThreads int64 = 1 << 35
60-
CreatePrivateThreads int64 = 1 << 36
61-
UseExternalStickers int64 = 1 << 37
62-
SendMessagesInThreads int64 = 1 << 38
63-
StartEmbeddedActivities int64 = 1 << 39
64-
ModerateMembers int64 = 1 << 40
24+
CreateInstantInvite int64 = 1 << 0 // CreateInstantInvite - Allows creation of instant invites
25+
KickMembers int64 = 1 << 1 // KickMembers - Allows kicking members
26+
BanMembers int64 = 1 << 2 // BanMembers - Allows banning members
27+
Administrator int64 = 1 << 3 // Administrator - Allows all permissions and bypasses channel permission overwrites
28+
ManageChannels int64 = 1 << 4 // ManageChannels - Allows management and editing of channels
29+
ManageGuild int64 = 1 << 5 // ManageGuild - Allows management and editing of the guild
30+
AddReactions int64 = 1 << 6 // AddReactions - Allows for the addition of reactions to messages
31+
ViewAuditLog int64 = 1 << 7 // ViewAuditLog - Allows for viewing of audit logs
32+
PrioritySpeaker int64 = 1 << 8 // PrioritySpeaker - Allows for using priority speaker in a voice channel
33+
Stream int64 = 1 << 9 // Stream - Allows the user to go live
34+
ViewChannel int64 = 1 << 10 // ViewChannel - Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels
35+
SendMessages int64 = 1 << 11 // SendMessages - Allows for sending messages in a channel (does not allow sending messages in threads)
36+
SendTtsMessages int64 = 1 << 12 // SendTtsMessages - Allows for sending of /tts messages
37+
ManageMessages int64 = 1 << 13 // ManageMessages - Allows for deletion of other users messages
38+
EmbedLinks int64 = 1 << 14 // EmbedLinks - Links sent by users with this permission will be auto-embedded
39+
AttachFiles int64 = 1 << 15 // AttachFiles - Allows for uploading images and files
40+
ReadMessageHistory int64 = 1 << 16 // ReadMessageHistory - Allows for reading of message history
41+
MentionEveryone int64 = 1 << 17 // MentionEveryone - Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel
42+
UseExternalEmojis int64 = 1 << 18 // UseExternalEmojis - Allows the usage of custom emojis from other servers
43+
ViewGuildInsights int64 = 1 << 19 // ViewGuildInsights - Allows for viewing guild insights
44+
Connect int64 = 1 << 20 // Connect - Allows for joining of a voice channel
45+
Speak int64 = 1 << 21 // Speak - Allows for speaking in a voice channel
46+
MuteMembers int64 = 1 << 22 // MuteMembers - Allows for muting members in a voice channel
47+
DeafenMembers int64 = 1 << 23 // DeafenMembers - Allows for deafening of members in a voice channel
48+
MoveMembers int64 = 1 << 24 // MoveMembers - Allows for moving of members between voice channels
49+
UseVoiceActivity int64 = 1 << 25 // UseVoiceActivity - Allows for using voice-activity-detection in a voice channel
50+
ChangeNickname int64 = 1 << 26 // ChangeNickname - Allows for modification of own nickname
51+
ManageNicknames int64 = 1 << 27 // ManageNicknames - Allows for modification of other users nicknames
52+
ManageRoles int64 = 1 << 28 // ManageRoles - Allows management and editing of roles
53+
ManageWebhooks int64 = 1 << 29 // ManageWebhooks - Allows management and editing of webhooks
54+
ManageEmojisAndStickers int64 = 1 << 30 // ManageEmojisAndStickers - Allows management and editing of emojis and stickers
55+
UseApplicationCommands int64 = 1 << 31 // UseApplicationCommands - Allows members to use application commands, including slash commands and context menu commands.
56+
RequestToSpeak int64 = 1 << 32 // RequestToSpeak - Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.)
57+
ManageEvents int64 = 1 << 33 // ManageEvents - Allows for creating, editing, and deleting scheduled events
58+
ManageThreads int64 = 1 << 34 // ManageThreads - Allows for deleting and archiving threads, and viewing all private threads
59+
CreatePublicThreads int64 = 1 << 35 // CreatePublicThreads - Allows for creating public and announcement threads
60+
CreatePrivateThreads int64 = 1 << 36 // CreatePrivateThreads - Allows for creating private threads
61+
UseExternalStickers int64 = 1 << 37 // UseExternalStickers - Allows the usage of custom stickers from other servers
62+
SendMessagesInThreads int64 = 1 << 38 // SendMessagesInThreads - Allows for sending messages in threads
63+
StartEmbeddedActivities int64 = 1 << 39 // StartEmbeddedActivities - Allows for launching activities (applications with the EMBEDDED flag) in a voice channel
64+
ModerateMembers int64 = 1 << 40 // ModerateMembers - Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
6565
)
6666

6767
/* HELPER FUNCTIONS */

0 commit comments

Comments
 (0)