1// Discordgo - Discord bindings for Go
2// Available at https://github.com/bwmarrin/discordgo
3
4// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>.  All rights reserved.
5// Use of this source code is governed by a BSD-style
6// license that can be found in the LICENSE file.
7
8// This file contains all structures for the discordgo package.  These
9// may be moved about later into separate files but I find it easier to have
10// them all located together.
11
12package discordgo
13
14import (
15	"encoding/json"
16	"fmt"
17	"math"
18	"net/http"
19	"strings"
20	"sync"
21	"time"
22
23	"github.com/gorilla/websocket"
24)
25
26// A Session represents a connection to the Discord API.
27type Session struct {
28	sync.RWMutex
29
30	// General configurable settings.
31
32	// Authentication token for this session
33	// TODO: Remove Below, Deprecated, Use Identify struct
34	Token string
35
36	MFA bool
37
38	// Debug for printing JSON request/responses
39	Debug    bool // Deprecated, will be removed.
40	LogLevel int
41
42	// Should the session reconnect the websocket on errors.
43	ShouldReconnectOnError bool
44
45	// Identify is sent during initial handshake with the discord gateway.
46	// https://discord.com/developers/docs/topics/gateway#identify
47	Identify Identify
48
49	// TODO: Remove Below, Deprecated, Use Identify struct
50	// Should the session request compressed websocket data.
51	Compress bool
52
53	// Sharding
54	ShardID    int
55	ShardCount int
56
57	// Should state tracking be enabled.
58	// State tracking is the best way for getting the the users
59	// active guilds and the members of the guilds.
60	StateEnabled bool
61
62	// Whether or not to call event handlers synchronously.
63	// e.g false = launch event handlers in their own goroutines.
64	SyncEvents bool
65
66	// Exposed but should not be modified by User.
67
68	// Whether the Data Websocket is ready
69	DataReady bool // NOTE: Maye be deprecated soon
70
71	// Max number of REST API retries
72	MaxRestRetries int
73
74	// Status stores the currect status of the websocket connection
75	// this is being tested, may stay, may go away.
76	status int32
77
78	// Whether the Voice Websocket is ready
79	VoiceReady bool // NOTE: Deprecated.
80
81	// Whether the UDP Connection is ready
82	UDPReady bool // NOTE: Deprecated
83
84	// Stores a mapping of guild id's to VoiceConnections
85	VoiceConnections map[string]*VoiceConnection
86
87	// Managed state object, updated internally with events when
88	// StateEnabled is true.
89	State *State
90
91	// The http client used for REST requests
92	Client *http.Client
93
94	// The user agent used for REST APIs
95	UserAgent string
96
97	// Stores the last HeartbeatAck that was recieved (in UTC)
98	LastHeartbeatAck time.Time
99
100	// Stores the last Heartbeat sent (in UTC)
101	LastHeartbeatSent time.Time
102
103	// used to deal with rate limits
104	Ratelimiter *RateLimiter
105
106	// Event handlers
107	handlersMu   sync.RWMutex
108	handlers     map[string][]*eventHandlerInstance
109	onceHandlers map[string][]*eventHandlerInstance
110
111	// The websocket connection.
112	wsConn *websocket.Conn
113
114	// When nil, the session is not listening.
115	listening chan interface{}
116
117	// sequence tracks the current gateway api websocket sequence number
118	sequence *int64
119
120	// stores sessions current Discord Gateway
121	gateway string
122
123	// stores session ID of current Gateway connection
124	sessionID string
125
126	// used to make sure gateway websocket writes do not happen concurrently
127	wsMutex sync.Mutex
128}
129
130// UserConnection is a Connection returned from the UserConnections endpoint
131type UserConnection struct {
132	ID           string         `json:"id"`
133	Name         string         `json:"name"`
134	Type         string         `json:"type"`
135	Revoked      bool           `json:"revoked"`
136	Integrations []*Integration `json:"integrations"`
137}
138
139// Integration stores integration information
140type Integration struct {
141	ID                string             `json:"id"`
142	Name              string             `json:"name"`
143	Type              string             `json:"type"`
144	Enabled           bool               `json:"enabled"`
145	Syncing           bool               `json:"syncing"`
146	RoleID            string             `json:"role_id"`
147	EnableEmoticons   bool               `json:"enable_emoticons"`
148	ExpireBehavior    ExpireBehavior     `json:"expire_behavior"`
149	ExpireGracePeriod int                `json:"expire_grace_period"`
150	User              *User              `json:"user"`
151	Account           IntegrationAccount `json:"account"`
152	SyncedAt          Timestamp          `json:"synced_at"`
153}
154
155//ExpireBehavior of Integration
156// https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
157type ExpireBehavior int
158
159// Block of valid ExpireBehaviors
160const (
161	ExpireBehaviorRemoveRole ExpireBehavior = iota
162	ExpireBehaviorKick
163)
164
165// IntegrationAccount is integration account information
166// sent by the UserConnections endpoint
167type IntegrationAccount struct {
168	ID   string `json:"id"`
169	Name string `json:"name"`
170}
171
172// A VoiceRegion stores data for a specific voice region server.
173type VoiceRegion struct {
174	ID       string `json:"id"`
175	Name     string `json:"name"`
176	Hostname string `json:"sample_hostname"`
177	Port     int    `json:"sample_port"`
178}
179
180// A VoiceICE stores data for voice ICE servers.
181type VoiceICE struct {
182	TTL     string       `json:"ttl"`
183	Servers []*ICEServer `json:"servers"`
184}
185
186// A ICEServer stores data for a specific voice ICE server.
187type ICEServer struct {
188	URL        string `json:"url"`
189	Username   string `json:"username"`
190	Credential string `json:"credential"`
191}
192
193// A Invite stores all data related to a specific Discord Guild or Channel invite.
194type Invite struct {
195	Guild          *Guild         `json:"guild"`
196	Channel        *Channel       `json:"channel"`
197	Inviter        *User          `json:"inviter"`
198	Code           string         `json:"code"`
199	CreatedAt      Timestamp      `json:"created_at"`
200	MaxAge         int            `json:"max_age"`
201	Uses           int            `json:"uses"`
202	MaxUses        int            `json:"max_uses"`
203	Revoked        bool           `json:"revoked"`
204	Temporary      bool           `json:"temporary"`
205	Unique         bool           `json:"unique"`
206	TargetUser     *User          `json:"target_user"`
207	TargetUserType TargetUserType `json:"target_user_type"`
208
209	// will only be filled when using InviteWithCounts
210	ApproximatePresenceCount int `json:"approximate_presence_count"`
211	ApproximateMemberCount   int `json:"approximate_member_count"`
212}
213
214// TargetUserType is the type of the target user
215// https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
216type TargetUserType int
217
218// Block contains known TargetUserType values
219const (
220	TargetUserTypeStream TargetUserType = iota
221)
222
223// ChannelType is the type of a Channel
224type ChannelType int
225
226// Block contains known ChannelType values
227const (
228	ChannelTypeGuildText ChannelType = iota
229	ChannelTypeDM
230	ChannelTypeGuildVoice
231	ChannelTypeGroupDM
232	ChannelTypeGuildCategory
233	ChannelTypeGuildNews
234	ChannelTypeGuildStore
235)
236
237// A Channel holds all data related to an individual Discord channel.
238type Channel struct {
239	// The ID of the channel.
240	ID string `json:"id"`
241
242	// The ID of the guild to which the channel belongs, if it is in a guild.
243	// Else, this ID is empty (e.g. DM channels).
244	GuildID string `json:"guild_id"`
245
246	// The name of the channel.
247	Name string `json:"name"`
248
249	// The topic of the channel.
250	Topic string `json:"topic"`
251
252	// The type of the channel.
253	Type ChannelType `json:"type"`
254
255	// The ID of the last message sent in the channel. This is not
256	// guaranteed to be an ID of a valid message.
257	LastMessageID string `json:"last_message_id"`
258
259	// The timestamp of the last pinned message in the channel.
260	// Empty if the channel has no pinned messages.
261	LastPinTimestamp Timestamp `json:"last_pin_timestamp"`
262
263	// Whether the channel is marked as NSFW.
264	NSFW bool `json:"nsfw"`
265
266	// Icon of the group DM channel.
267	Icon string `json:"icon"`
268
269	// The position of the channel, used for sorting in client.
270	Position int `json:"position"`
271
272	// The bitrate of the channel, if it is a voice channel.
273	Bitrate int `json:"bitrate"`
274
275	// The recipients of the channel. This is only populated in DM channels.
276	Recipients []*User `json:"recipients"`
277
278	// The messages in the channel. This is only present in state-cached channels,
279	// and State.MaxMessageCount must be non-zero.
280	Messages []*Message `json:"-"`
281
282	// A list of permission overwrites present for the channel.
283	PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
284
285	// The user limit of the voice channel.
286	UserLimit int `json:"user_limit"`
287
288	// The ID of the parent channel, if the channel is under a category
289	ParentID string `json:"parent_id"`
290
291	// Amount of seconds a user has to wait before sending another message (0-21600)
292	// bots, as well as users with the permission manage_messages or manage_channel, are unaffected
293	RateLimitPerUser int `json:"rate_limit_per_user"`
294
295	// ID of the DM creator Zeroed if guild channel
296	OwnerID string `json:"owner_id"`
297
298	// ApplicationID of the DM creator Zeroed if guild channel or not a bot user
299	ApplicationID string `json:"application_id"`
300}
301
302// Mention returns a string which mentions the channel
303func (c *Channel) Mention() string {
304	return fmt.Sprintf("<#%s>", c.ID)
305}
306
307// A ChannelEdit holds Channel Field data for a channel edit.
308type ChannelEdit struct {
309	Name                 string                 `json:"name,omitempty"`
310	Topic                string                 `json:"topic,omitempty"`
311	NSFW                 bool                   `json:"nsfw,omitempty"`
312	Position             int                    `json:"position"`
313	Bitrate              int                    `json:"bitrate,omitempty"`
314	UserLimit            int                    `json:"user_limit,omitempty"`
315	PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
316	ParentID             string                 `json:"parent_id,omitempty"`
317	RateLimitPerUser     int                    `json:"rate_limit_per_user,omitempty"`
318}
319
320// A ChannelFollow holds data returned after following a news channel
321type ChannelFollow struct {
322	ChannelID string `json:"channel_id"`
323	WebhookID string `json:"webhook_id"`
324}
325
326// PermissionOverwriteType represents the type of resource on which
327// a permission overwrite acts.
328type PermissionOverwriteType int
329
330// The possible permission overwrite types.
331const (
332	PermissionOverwriteTypeRole PermissionOverwriteType = iota
333	PermissionOverwriteTypeMember
334)
335
336// A PermissionOverwrite holds permission overwrite data for a Channel
337type PermissionOverwrite struct {
338	ID    string                  `json:"id"`
339	Type  PermissionOverwriteType `json:"type"`
340	Deny  int64                   `json:"deny,string"`
341	Allow int64                   `json:"allow,string"`
342}
343
344// Emoji struct holds data related to Emoji's
345type Emoji struct {
346	ID            string   `json:"id"`
347	Name          string   `json:"name"`
348	Roles         []string `json:"roles"`
349	User          *User    `json:"user"`
350	RequireColons bool     `json:"require_colons"`
351	Managed       bool     `json:"managed"`
352	Animated      bool     `json:"animated"`
353	Available     bool     `json:"available"`
354}
355
356// MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
357func (e *Emoji) MessageFormat() string {
358	if e.ID != "" && e.Name != "" {
359		if e.Animated {
360			return "<a:" + e.APIName() + ">"
361		}
362
363		return "<:" + e.APIName() + ">"
364	}
365
366	return e.APIName()
367}
368
369// APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
370func (e *Emoji) APIName() string {
371	if e.ID != "" && e.Name != "" {
372		return e.Name + ":" + e.ID
373	}
374	if e.Name != "" {
375		return e.Name
376	}
377	return e.ID
378}
379
380// VerificationLevel type definition
381type VerificationLevel int
382
383// Constants for VerificationLevel levels from 0 to 4 inclusive
384const (
385	VerificationLevelNone VerificationLevel = iota
386	VerificationLevelLow
387	VerificationLevelMedium
388	VerificationLevelHigh
389	VerificationLevelVeryHigh
390)
391
392// ExplicitContentFilterLevel type definition
393type ExplicitContentFilterLevel int
394
395// Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive
396const (
397	ExplicitContentFilterDisabled ExplicitContentFilterLevel = iota
398	ExplicitContentFilterMembersWithoutRoles
399	ExplicitContentFilterAllMembers
400)
401
402// MfaLevel type definition
403type MfaLevel int
404
405// Constants for MfaLevel levels from 0 to 1 inclusive
406const (
407	MfaLevelNone MfaLevel = iota
408	MfaLevelElevated
409)
410
411// PremiumTier type definition
412type PremiumTier int
413
414// Constants for PremiumTier levels from 0 to 3 inclusive
415const (
416	PremiumTierNone PremiumTier = iota
417	PremiumTier1
418	PremiumTier2
419	PremiumTier3
420)
421
422// A Guild holds all data related to a specific Discord Guild.  Guilds are also
423// sometimes referred to as Servers in the Discord client.
424type Guild struct {
425	// The ID of the guild.
426	ID string `json:"id"`
427
428	// The name of the guild. (2–100 characters)
429	Name string `json:"name"`
430
431	// The hash of the guild's icon. Use Session.GuildIcon
432	// to retrieve the icon itself.
433	Icon string `json:"icon"`
434
435	// The voice region of the guild.
436	Region string `json:"region"`
437
438	// The ID of the AFK voice channel.
439	AfkChannelID string `json:"afk_channel_id"`
440
441	// The user ID of the owner of the guild.
442	OwnerID string `json:"owner_id"`
443
444	// If we are the owner of the guild
445	Owner bool `json:"owner"`
446
447	// The time at which the current user joined the guild.
448	// This field is only present in GUILD_CREATE events and websocket
449	// update events, and thus is only present in state-cached guilds.
450	JoinedAt Timestamp `json:"joined_at"`
451
452	// The hash of the guild's discovery splash.
453	DiscoverySplash string `json:"discovery_splash"`
454
455	// The hash of the guild's splash.
456	Splash string `json:"splash"`
457
458	// The timeout, in seconds, before a user is considered AFK in voice.
459	AfkTimeout int `json:"afk_timeout"`
460
461	// The number of members in the guild.
462	// This field is only present in GUILD_CREATE events and websocket
463	// update events, and thus is only present in state-cached guilds.
464	MemberCount int `json:"member_count"`
465
466	// The verification level required for the guild.
467	VerificationLevel VerificationLevel `json:"verification_level"`
468
469	// Whether the guild is considered large. This is
470	// determined by a member threshold in the identify packet,
471	// and is currently hard-coded at 250 members in the library.
472	Large bool `json:"large"`
473
474	// The default message notification setting for the guild.
475	DefaultMessageNotifications MessageNotifications `json:"default_message_notifications"`
476
477	// A list of roles in the guild.
478	Roles []*Role `json:"roles"`
479
480	// A list of the custom emojis present in the guild.
481	Emojis []*Emoji `json:"emojis"`
482
483	// A list of the members in the guild.
484	// This field is only present in GUILD_CREATE events and websocket
485	// update events, and thus is only present in state-cached guilds.
486	Members []*Member `json:"members"`
487
488	// A list of partial presence objects for members in the guild.
489	// This field is only present in GUILD_CREATE events and websocket
490	// update events, and thus is only present in state-cached guilds.
491	Presences []*Presence `json:"presences"`
492
493	// The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned)
494	MaxPresences int `json:"max_presences"`
495
496	// The maximum number of members for the guild
497	MaxMembers int `json:"max_members"`
498
499	// A list of channels in the guild.
500	// This field is only present in GUILD_CREATE events and websocket
501	// update events, and thus is only present in state-cached guilds.
502	Channels []*Channel `json:"channels"`
503
504	// A list of voice states for the guild.
505	// This field is only present in GUILD_CREATE events and websocket
506	// update events, and thus is only present in state-cached guilds.
507	VoiceStates []*VoiceState `json:"voice_states"`
508
509	// Whether this guild is currently unavailable (most likely due to outage).
510	// This field is only present in GUILD_CREATE events and websocket
511	// update events, and thus is only present in state-cached guilds.
512	Unavailable bool `json:"unavailable"`
513
514	// The explicit content filter level
515	ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
516
517	// The list of enabled guild features
518	Features []string `json:"features"`
519
520	// Required MFA level for the guild
521	MfaLevel MfaLevel `json:"mfa_level"`
522
523	// The application id of the guild if bot created.
524	ApplicationID string `json:"application_id"`
525
526	// Whether or not the Server Widget is enabled
527	WidgetEnabled bool `json:"widget_enabled"`
528
529	// The Channel ID for the Server Widget
530	WidgetChannelID string `json:"widget_channel_id"`
531
532	// The Channel ID to which system messages are sent (eg join and leave messages)
533	SystemChannelID string `json:"system_channel_id"`
534
535	// The System channel flags
536	SystemChannelFlags SystemChannelFlag `json:"system_channel_flags"`
537
538	// The ID of the rules channel ID, used for rules.
539	RulesChannelID string `json:"rules_channel_id"`
540
541	// the vanity url code for the guild
542	VanityURLCode string `json:"vanity_url_code"`
543
544	// the description for the guild
545	Description string `json:"description"`
546
547	// The hash of the guild's banner
548	Banner string `json:"banner"`
549
550	// The premium tier of the guild
551	PremiumTier PremiumTier `json:"premium_tier"`
552
553	// The total number of users currently boosting this server
554	PremiumSubscriptionCount int `json:"premium_subscription_count"`
555
556	// The preferred locale of a guild with the "PUBLIC" feature; used in server discovery and notices from Discord; defaults to "en-US"
557	PreferredLocale string `json:"preferred_locale"`
558
559	// The id of the channel where admins and moderators of guilds with the "PUBLIC" feature receive notices from Discord
560	PublicUpdatesChannelID string `json:"public_updates_channel_id"`
561
562	// The maximum amount of users in a video channel
563	MaxVideoChannelUsers int `json:"max_video_channel_users"`
564
565	// Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
566	ApproximateMemberCount int `json:"approximate_member_count"`
567
568	// Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
569	ApproximatePresenceCount int `json:"approximate_presence_count"`
570
571	// Permissions of our user
572	Permissions int64 `json:"permissions,string"`
573}
574
575// MessageNotifications is the notification level for a guild
576// https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
577type MessageNotifications int
578
579// Block containing known MessageNotifications values
580const (
581	MessageNotificationsAllMessages MessageNotifications = iota
582	MessageNotificationsOnlyMentions
583)
584
585// SystemChannelFlag is the type of flags in the system channel (see SystemChannelFlag* consts)
586// https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
587type SystemChannelFlag int
588
589// Block containing known SystemChannelFlag values
590const (
591	SystemChannelFlagsSuppressJoin SystemChannelFlag = 1 << iota
592	SystemChannelFlagsSuppressPremium
593)
594
595// IconURL returns a URL to the guild's icon.
596func (g *Guild) IconURL() string {
597	if g.Icon == "" {
598		return ""
599	}
600
601	if strings.HasPrefix(g.Icon, "a_") {
602		return EndpointGuildIconAnimated(g.ID, g.Icon)
603	}
604
605	return EndpointGuildIcon(g.ID, g.Icon)
606}
607
608// A UserGuild holds a brief version of a Guild
609type UserGuild struct {
610	ID          string `json:"id"`
611	Name        string `json:"name"`
612	Icon        string `json:"icon"`
613	Owner       bool   `json:"owner"`
614	Permissions int64  `json:"permissions,string"`
615}
616
617// A GuildParams stores all the data needed to update discord guild settings
618type GuildParams struct {
619	Name                        string             `json:"name,omitempty"`
620	Region                      string             `json:"region,omitempty"`
621	VerificationLevel           *VerificationLevel `json:"verification_level,omitempty"`
622	DefaultMessageNotifications int                `json:"default_message_notifications,omitempty"` // TODO: Separate type?
623	AfkChannelID                string             `json:"afk_channel_id,omitempty"`
624	AfkTimeout                  int                `json:"afk_timeout,omitempty"`
625	Icon                        string             `json:"icon,omitempty"`
626	OwnerID                     string             `json:"owner_id,omitempty"`
627	Splash                      string             `json:"splash,omitempty"`
628	Banner                      string             `json:"banner,omitempty"`
629}
630
631// A Role stores information about Discord guild member roles.
632type Role struct {
633	// The ID of the role.
634	ID string `json:"id"`
635
636	// The name of the role.
637	Name string `json:"name"`
638
639	// Whether this role is managed by an integration, and
640	// thus cannot be manually added to, or taken from, members.
641	Managed bool `json:"managed"`
642
643	// Whether this role is mentionable.
644	Mentionable bool `json:"mentionable"`
645
646	// Whether this role is hoisted (shows up separately in member list).
647	Hoist bool `json:"hoist"`
648
649	// The hex color of this role.
650	Color int `json:"color"`
651
652	// The position of this role in the guild's role hierarchy.
653	Position int `json:"position"`
654
655	// The permissions of the role on the guild (doesn't include channel overrides).
656	// This is a combination of bit masks; the presence of a certain permission can
657	// be checked by performing a bitwise AND between this int and the permission.
658	Permissions int64 `json:"permissions,string"`
659}
660
661// Mention returns a string which mentions the role
662func (r *Role) Mention() string {
663	return fmt.Sprintf("<@&%s>", r.ID)
664}
665
666// Roles are a collection of Role
667type Roles []*Role
668
669func (r Roles) Len() int {
670	return len(r)
671}
672
673func (r Roles) Less(i, j int) bool {
674	return r[i].Position > r[j].Position
675}
676
677func (r Roles) Swap(i, j int) {
678	r[i], r[j] = r[j], r[i]
679}
680
681// A VoiceState stores the voice states of Guilds
682type VoiceState struct {
683	UserID    string `json:"user_id"`
684	SessionID string `json:"session_id"`
685	ChannelID string `json:"channel_id"`
686	GuildID   string `json:"guild_id"`
687	Suppress  bool   `json:"suppress"`
688	SelfMute  bool   `json:"self_mute"`
689	SelfDeaf  bool   `json:"self_deaf"`
690	Mute      bool   `json:"mute"`
691	Deaf      bool   `json:"deaf"`
692}
693
694// A Presence stores the online, offline, or idle and game status of Guild members.
695type Presence struct {
696	User       *User       `json:"user"`
697	Status     Status      `json:"status"`
698	Activities []*Activity `json:"activities"`
699	Since      *int        `json:"since"`
700}
701
702// A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
703type TimeStamps struct {
704	EndTimestamp   int64 `json:"end,omitempty"`
705	StartTimestamp int64 `json:"start,omitempty"`
706}
707
708// UnmarshalJSON unmarshals JSON into TimeStamps struct
709func (t *TimeStamps) UnmarshalJSON(b []byte) error {
710	temp := struct {
711		End   float64 `json:"end,omitempty"`
712		Start float64 `json:"start,omitempty"`
713	}{}
714	err := json.Unmarshal(b, &temp)
715	if err != nil {
716		return err
717	}
718	t.EndTimestamp = int64(temp.End)
719	t.StartTimestamp = int64(temp.Start)
720	return nil
721}
722
723// An Assets struct contains assets and labels used in the rich presence "playing .." Game
724type Assets struct {
725	LargeImageID string `json:"large_image,omitempty"`
726	SmallImageID string `json:"small_image,omitempty"`
727	LargeText    string `json:"large_text,omitempty"`
728	SmallText    string `json:"small_text,omitempty"`
729}
730
731// A Member stores user information for Guild members. A guild
732// member represents a certain user's presence in a guild.
733type Member struct {
734	// The guild ID on which the member exists.
735	GuildID string `json:"guild_id"`
736
737	// The time at which the member joined the guild, in ISO8601.
738	JoinedAt Timestamp `json:"joined_at"`
739
740	// The nickname of the member, if they have one.
741	Nick string `json:"nick"`
742
743	// Whether the member is deafened at a guild level.
744	Deaf bool `json:"deaf"`
745
746	// Whether the member is muted at a guild level.
747	Mute bool `json:"mute"`
748
749	// The underlying user on which the member is based.
750	User *User `json:"user"`
751
752	// A list of IDs of the roles which are possessed by the member.
753	Roles []string `json:"roles"`
754
755	// When the user used their Nitro boost on the server
756	PremiumSince Timestamp `json:"premium_since"`
757
758	// Is true while the member hasn't accepted the membership screen.
759	Pending bool `json:"pending"`
760}
761
762// Mention creates a member mention
763func (m *Member) Mention() string {
764	return "<@!" + m.User.ID + ">"
765}
766
767// A Settings stores data for a specific users Discord client settings.
768type Settings struct {
769	RenderEmbeds           bool               `json:"render_embeds"`
770	InlineEmbedMedia       bool               `json:"inline_embed_media"`
771	InlineAttachmentMedia  bool               `json:"inline_attachment_media"`
772	EnableTTSCommand       bool               `json:"enable_tts_command"`
773	MessageDisplayCompact  bool               `json:"message_display_compact"`
774	ShowCurrentGame        bool               `json:"show_current_game"`
775	ConvertEmoticons       bool               `json:"convert_emoticons"`
776	Locale                 string             `json:"locale"`
777	Theme                  string             `json:"theme"`
778	GuildPositions         []string           `json:"guild_positions"`
779	RestrictedGuilds       []string           `json:"restricted_guilds"`
780	FriendSourceFlags      *FriendSourceFlags `json:"friend_source_flags"`
781	Status                 Status             `json:"status"`
782	DetectPlatformAccounts bool               `json:"detect_platform_accounts"`
783	DeveloperMode          bool               `json:"developer_mode"`
784}
785
786// Status type definition
787type Status string
788
789// Constants for Status with the different current available status
790const (
791	StatusOnline       Status = "online"
792	StatusIdle         Status = "idle"
793	StatusDoNotDisturb Status = "dnd"
794	StatusInvisible    Status = "invisible"
795	StatusOffline      Status = "offline"
796)
797
798// FriendSourceFlags stores ... TODO :)
799type FriendSourceFlags struct {
800	All           bool `json:"all"`
801	MutualGuilds  bool `json:"mutual_guilds"`
802	MutualFriends bool `json:"mutual_friends"`
803}
804
805// A Relationship between the logged in user and Relationship.User
806type Relationship struct {
807	User *User  `json:"user"`
808	Type int    `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
809	ID   string `json:"id"`
810}
811
812// A TooManyRequests struct holds information received from Discord
813// when receiving a HTTP 429 response.
814type TooManyRequests struct {
815	Bucket     string        `json:"bucket"`
816	Message    string        `json:"message"`
817	RetryAfter time.Duration `json:"retry_after"`
818}
819
820// UnmarshalJSON helps support translation of a milliseconds-based float
821// into a time.Duration on TooManyRequests.
822func (t *TooManyRequests) UnmarshalJSON(b []byte) error {
823	u := struct {
824		Bucket     string  `json:"bucket"`
825		Message    string  `json:"message"`
826		RetryAfter float64 `json:"retry_after"`
827	}{}
828	err := json.Unmarshal(b, &u)
829	if err != nil {
830		return err
831	}
832
833	t.Bucket = u.Bucket
834	t.Message = u.Message
835	whole, frac := math.Modf(u.RetryAfter)
836	t.RetryAfter = time.Duration(whole)*time.Second + time.Duration(frac*1000)*time.Millisecond
837	return nil
838}
839
840// A ReadState stores data on the read state of channels.
841type ReadState struct {
842	MentionCount  int    `json:"mention_count"`
843	LastMessageID string `json:"last_message_id"`
844	ID            string `json:"id"`
845}
846
847// An Ack is used to ack messages
848type Ack struct {
849	Token string `json:"token"`
850}
851
852// A GuildRole stores data for guild roles.
853type GuildRole struct {
854	Role    *Role  `json:"role"`
855	GuildID string `json:"guild_id"`
856}
857
858// A GuildBan stores data for a guild ban.
859type GuildBan struct {
860	Reason string `json:"reason"`
861	User   *User  `json:"user"`
862}
863
864// A GuildEmbed stores data for a guild embed.
865type GuildEmbed struct {
866	Enabled   bool   `json:"enabled"`
867	ChannelID string `json:"channel_id"`
868}
869
870// A GuildAuditLog stores data for a guild audit log.
871// https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
872type GuildAuditLog struct {
873	Webhooks        []*Webhook       `json:"webhooks,omitempty"`
874	Users           []*User          `json:"users,omitempty"`
875	AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"`
876	Integrations    []*Integration   `json:"integrations"`
877}
878
879// AuditLogEntry for a GuildAuditLog
880// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure
881type AuditLogEntry struct {
882	TargetID   string            `json:"target_id"`
883	Changes    []*AuditLogChange `json:"changes"`
884	UserID     string            `json:"user_id"`
885	ID         string            `json:"id"`
886	ActionType *AuditLogAction   `json:"action_type"`
887	Options    *AuditLogOptions  `json:"options"`
888	Reason     string            `json:"reason"`
889}
890
891// AuditLogChange for an AuditLogEntry
892type AuditLogChange struct {
893	NewValue interface{}        `json:"new_value"`
894	OldValue interface{}        `json:"old_value"`
895	Key      *AuditLogChangeKey `json:"key"`
896}
897
898// AuditLogChangeKey value for AuditLogChange
899// https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key
900type AuditLogChangeKey string
901
902// Block of valid AuditLogChangeKey
903const (
904	AuditLogChangeKeyName                       AuditLogChangeKey = "name"
905	AuditLogChangeKeyIconHash                   AuditLogChangeKey = "icon_hash"
906	AuditLogChangeKeySplashHash                 AuditLogChangeKey = "splash_hash"
907	AuditLogChangeKeyOwnerID                    AuditLogChangeKey = "owner_id"
908	AuditLogChangeKeyRegion                     AuditLogChangeKey = "region"
909	AuditLogChangeKeyAfkChannelID               AuditLogChangeKey = "afk_channel_id"
910	AuditLogChangeKeyAfkTimeout                 AuditLogChangeKey = "afk_timeout"
911	AuditLogChangeKeyMfaLevel                   AuditLogChangeKey = "mfa_level"
912	AuditLogChangeKeyVerificationLevel          AuditLogChangeKey = "verification_level"
913	AuditLogChangeKeyExplicitContentFilter      AuditLogChangeKey = "explicit_content_filter"
914	AuditLogChangeKeyDefaultMessageNotification AuditLogChangeKey = "default_message_notifications"
915	AuditLogChangeKeyVanityURLCode              AuditLogChangeKey = "vanity_url_code"
916	AuditLogChangeKeyRoleAdd                    AuditLogChangeKey = "$add"
917	AuditLogChangeKeyRoleRemove                 AuditLogChangeKey = "$remove"
918	AuditLogChangeKeyPruneDeleteDays            AuditLogChangeKey = "prune_delete_days"
919	AuditLogChangeKeyWidgetEnabled              AuditLogChangeKey = "widget_enabled"
920	AuditLogChangeKeyWidgetChannelID            AuditLogChangeKey = "widget_channel_id"
921	AuditLogChangeKeySystemChannelID            AuditLogChangeKey = "system_channel_id"
922	AuditLogChangeKeyPosition                   AuditLogChangeKey = "position"
923	AuditLogChangeKeyTopic                      AuditLogChangeKey = "topic"
924	AuditLogChangeKeyBitrate                    AuditLogChangeKey = "bitrate"
925	AuditLogChangeKeyPermissionOverwrite        AuditLogChangeKey = "permission_overwrites"
926	AuditLogChangeKeyNSFW                       AuditLogChangeKey = "nsfw"
927	AuditLogChangeKeyApplicationID              AuditLogChangeKey = "application_id"
928	AuditLogChangeKeyRateLimitPerUser           AuditLogChangeKey = "rate_limit_per_user"
929	AuditLogChangeKeyPermissions                AuditLogChangeKey = "permissions"
930	AuditLogChangeKeyColor                      AuditLogChangeKey = "color"
931	AuditLogChangeKeyHoist                      AuditLogChangeKey = "hoist"
932	AuditLogChangeKeyMentionable                AuditLogChangeKey = "mentionable"
933	AuditLogChangeKeyAllow                      AuditLogChangeKey = "allow"
934	AuditLogChangeKeyDeny                       AuditLogChangeKey = "deny"
935	AuditLogChangeKeyCode                       AuditLogChangeKey = "code"
936	AuditLogChangeKeyChannelID                  AuditLogChangeKey = "channel_id"
937	AuditLogChangeKeyInviterID                  AuditLogChangeKey = "inviter_id"
938	AuditLogChangeKeyMaxUses                    AuditLogChangeKey = "max_uses"
939	AuditLogChangeKeyUses                       AuditLogChangeKey = "uses"
940	AuditLogChangeKeyMaxAge                     AuditLogChangeKey = "max_age"
941	AuditLogChangeKeyTempoary                   AuditLogChangeKey = "temporary"
942	AuditLogChangeKeyDeaf                       AuditLogChangeKey = "deaf"
943	AuditLogChangeKeyMute                       AuditLogChangeKey = "mute"
944	AuditLogChangeKeyNick                       AuditLogChangeKey = "nick"
945	AuditLogChangeKeyAvatarHash                 AuditLogChangeKey = "avatar_hash"
946	AuditLogChangeKeyID                         AuditLogChangeKey = "id"
947	AuditLogChangeKeyType                       AuditLogChangeKey = "type"
948	AuditLogChangeKeyEnableEmoticons            AuditLogChangeKey = "enable_emoticons"
949	AuditLogChangeKeyExpireBehavior             AuditLogChangeKey = "expire_behavior"
950	AuditLogChangeKeyExpireGracePeriod          AuditLogChangeKey = "expire_grace_period"
951)
952
953// AuditLogOptions optional data for the AuditLog
954// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
955type AuditLogOptions struct {
956	DeleteMemberDays string               `json:"delete_member_days"`
957	MembersRemoved   string               `json:"members_removed"`
958	ChannelID        string               `json:"channel_id"`
959	MessageID        string               `json:"message_id"`
960	Count            string               `json:"count"`
961	ID               string               `json:"id"`
962	Type             *AuditLogOptionsType `json:"type"`
963	RoleName         string               `json:"role_name"`
964}
965
966// AuditLogOptionsType of the AuditLogOption
967// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
968type AuditLogOptionsType string
969
970// Valid Types for AuditLogOptionsType
971const (
972	AuditLogOptionsTypeMember AuditLogOptionsType = "member"
973	AuditLogOptionsTypeRole   AuditLogOptionsType = "role"
974)
975
976// AuditLogAction is the Action of the AuditLog (see AuditLogAction* consts)
977// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
978type AuditLogAction int
979
980// Block contains Discord Audit Log Action Types
981const (
982	AuditLogActionGuildUpdate AuditLogAction = 1
983
984	AuditLogActionChannelCreate          AuditLogAction = 10
985	AuditLogActionChannelUpdate          AuditLogAction = 11
986	AuditLogActionChannelDelete          AuditLogAction = 12
987	AuditLogActionChannelOverwriteCreate AuditLogAction = 13
988	AuditLogActionChannelOverwriteUpdate AuditLogAction = 14
989	AuditLogActionChannelOverwriteDelete AuditLogAction = 15
990
991	AuditLogActionMemberKick       AuditLogAction = 20
992	AuditLogActionMemberPrune      AuditLogAction = 21
993	AuditLogActionMemberBanAdd     AuditLogAction = 22
994	AuditLogActionMemberBanRemove  AuditLogAction = 23
995	AuditLogActionMemberUpdate     AuditLogAction = 24
996	AuditLogActionMemberRoleUpdate AuditLogAction = 25
997
998	AuditLogActionRoleCreate AuditLogAction = 30
999	AuditLogActionRoleUpdate AuditLogAction = 31
1000	AuditLogActionRoleDelete AuditLogAction = 32
1001
1002	AuditLogActionInviteCreate AuditLogAction = 40
1003	AuditLogActionInviteUpdate AuditLogAction = 41
1004	AuditLogActionInviteDelete AuditLogAction = 42
1005
1006	AuditLogActionWebhookCreate AuditLogAction = 50
1007	AuditLogActionWebhookUpdate AuditLogAction = 51
1008	AuditLogActionWebhookDelete AuditLogAction = 52
1009
1010	AuditLogActionEmojiCreate AuditLogAction = 60
1011	AuditLogActionEmojiUpdate AuditLogAction = 61
1012	AuditLogActionEmojiDelete AuditLogAction = 62
1013
1014	AuditLogActionMessageDelete     AuditLogAction = 72
1015	AuditLogActionMessageBulkDelete AuditLogAction = 73
1016	AuditLogActionMessagePin        AuditLogAction = 74
1017	AuditLogActionMessageUnpin      AuditLogAction = 75
1018
1019	AuditLogActionIntegrationCreate AuditLogAction = 80
1020	AuditLogActionIntegrationUpdate AuditLogAction = 81
1021	AuditLogActionIntegrationDelete AuditLogAction = 82
1022)
1023
1024// A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
1025type UserGuildSettingsChannelOverride struct {
1026	Muted                bool   `json:"muted"`
1027	MessageNotifications int    `json:"message_notifications"`
1028	ChannelID            string `json:"channel_id"`
1029}
1030
1031// A UserGuildSettings stores data for a users guild settings.
1032type UserGuildSettings struct {
1033	SupressEveryone      bool                                `json:"suppress_everyone"`
1034	Muted                bool                                `json:"muted"`
1035	MobilePush           bool                                `json:"mobile_push"`
1036	MessageNotifications int                                 `json:"message_notifications"`
1037	GuildID              string                              `json:"guild_id"`
1038	ChannelOverrides     []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
1039}
1040
1041// A UserGuildSettingsEdit stores data for editing UserGuildSettings
1042type UserGuildSettingsEdit struct {
1043	SupressEveryone      bool                                         `json:"suppress_everyone"`
1044	Muted                bool                                         `json:"muted"`
1045	MobilePush           bool                                         `json:"mobile_push"`
1046	MessageNotifications int                                          `json:"message_notifications"`
1047	ChannelOverrides     map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
1048}
1049
1050// An APIErrorMessage is an api error message returned from discord
1051type APIErrorMessage struct {
1052	Code    int    `json:"code"`
1053	Message string `json:"message"`
1054}
1055
1056// Webhook stores the data for a webhook.
1057type Webhook struct {
1058	ID        string      `json:"id"`
1059	Type      WebhookType `json:"type"`
1060	GuildID   string      `json:"guild_id"`
1061	ChannelID string      `json:"channel_id"`
1062	User      *User       `json:"user"`
1063	Name      string      `json:"name"`
1064	Avatar    string      `json:"avatar"`
1065	Token     string      `json:"token"`
1066
1067	// ApplicationID is the bot/OAuth2 application that created this webhook
1068	ApplicationID string `json:"application_id,omitempty"`
1069}
1070
1071// WebhookType is the type of Webhook (see WebhookType* consts) in the Webhook struct
1072// https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
1073type WebhookType int
1074
1075// Valid WebhookType values
1076const (
1077	WebhookTypeIncoming WebhookType = iota
1078	WebhookTypeChannelFollower
1079)
1080
1081// WebhookParams is a struct for webhook params, used in the WebhookExecute command.
1082type WebhookParams struct {
1083	Content         string                  `json:"content,omitempty"`
1084	Username        string                  `json:"username,omitempty"`
1085	AvatarURL       string                  `json:"avatar_url,omitempty"`
1086	TTS             bool                    `json:"tts,omitempty"`
1087	File            string                  `json:"file,omitempty"`
1088	Embeds          []*MessageEmbed         `json:"embeds,omitempty"`
1089	AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
1090}
1091
1092// MessageReaction stores the data for a message reaction.
1093type MessageReaction struct {
1094	UserID    string `json:"user_id"`
1095	MessageID string `json:"message_id"`
1096	Emoji     Emoji  `json:"emoji"`
1097	ChannelID string `json:"channel_id"`
1098	GuildID   string `json:"guild_id,omitempty"`
1099}
1100
1101// GatewayBotResponse stores the data for the gateway/bot response
1102type GatewayBotResponse struct {
1103	URL    string `json:"url"`
1104	Shards int    `json:"shards"`
1105}
1106
1107// GatewayStatusUpdate is sent by the client to indicate a presence or status update
1108// https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
1109type GatewayStatusUpdate struct {
1110	Since  int      `json:"since"`
1111	Game   Activity `json:"game"`
1112	Status string   `json:"status"`
1113	AFK    bool     `json:"afk"`
1114}
1115
1116// Activity defines the Activity sent with GatewayStatusUpdate
1117// https://discord.com/developers/docs/topics/gateway#activity-object
1118type Activity struct {
1119	Name string       `json:"name"`
1120	Type ActivityType `json:"type"`
1121	URL  string       `json:"url,omitempty"`
1122}
1123
1124// ActivityType is the type of Activity (see ActivityType* consts) in the Activity struct
1125// https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
1126type ActivityType int
1127
1128// Valid ActivityType values
1129const (
1130	ActivityTypeGame ActivityType = iota
1131	ActivityTypeStreaming
1132	ActivityTypeListening
1133	//	ActivityTypeWatching // not valid in this use case?
1134	ActivityTypeCustom = 4
1135)
1136
1137// Identify is sent during initial handshake with the discord gateway.
1138// https://discord.com/developers/docs/topics/gateway#identify
1139type Identify struct {
1140	Token              string              `json:"token"`
1141	Properties         IdentifyProperties  `json:"properties"`
1142	Compress           bool                `json:"compress"`
1143	LargeThreshold     int                 `json:"large_threshold"`
1144	Shard              *[2]int             `json:"shard,omitempty"`
1145	Presence           GatewayStatusUpdate `json:"presence,omitempty"`
1146	GuildSubscriptions bool                `json:"guild_subscriptions"`
1147	Intents            Intent              `json:"intents"`
1148}
1149
1150// IdentifyProperties contains the "properties" portion of an Identify packet
1151// https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
1152type IdentifyProperties struct {
1153	OS              string `json:"$os"`
1154	Browser         string `json:"$browser"`
1155	Device          string `json:"$device"`
1156	Referer         string `json:"$referer"`
1157	ReferringDomain string `json:"$referring_domain"`
1158}
1159
1160// Constants for the different bit offsets of text channel permissions
1161const (
1162	// Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
1163	PermissionReadMessages = 1 << (iota + 10)
1164	PermissionSendMessages
1165	PermissionSendTTSMessages
1166	PermissionManageMessages
1167	PermissionEmbedLinks
1168	PermissionAttachFiles
1169	PermissionReadMessageHistory
1170	PermissionMentionEveryone
1171	PermissionUseExternalEmojis
1172)
1173
1174// Constants for the different bit offsets of voice permissions
1175const (
1176	PermissionVoiceConnect = 1 << (iota + 20)
1177	PermissionVoiceSpeak
1178	PermissionVoiceMuteMembers
1179	PermissionVoiceDeafenMembers
1180	PermissionVoiceMoveMembers
1181	PermissionVoiceUseVAD
1182	PermissionVoicePrioritySpeaker = 1 << (iota + 2)
1183)
1184
1185// Constants for general management.
1186const (
1187	PermissionChangeNickname = 1 << (iota + 26)
1188	PermissionManageNicknames
1189	PermissionManageRoles
1190	PermissionManageWebhooks
1191	PermissionManageEmojis
1192)
1193
1194// Constants for the different bit offsets of general permissions
1195const (
1196	PermissionCreateInstantInvite = 1 << iota
1197	PermissionKickMembers
1198	PermissionBanMembers
1199	PermissionAdministrator
1200	PermissionManageChannels
1201	PermissionManageServer
1202	PermissionAddReactions
1203	PermissionViewAuditLogs
1204	PermissionViewChannel = 1 << (iota + 2)
1205
1206	PermissionAllText = PermissionViewChannel |
1207		PermissionSendMessages |
1208		PermissionSendTTSMessages |
1209		PermissionManageMessages |
1210		PermissionEmbedLinks |
1211		PermissionAttachFiles |
1212		PermissionReadMessageHistory |
1213		PermissionMentionEveryone
1214	PermissionAllVoice = PermissionViewChannel |
1215		PermissionVoiceConnect |
1216		PermissionVoiceSpeak |
1217		PermissionVoiceMuteMembers |
1218		PermissionVoiceDeafenMembers |
1219		PermissionVoiceMoveMembers |
1220		PermissionVoiceUseVAD |
1221		PermissionVoicePrioritySpeaker
1222	PermissionAllChannel = PermissionAllText |
1223		PermissionAllVoice |
1224		PermissionCreateInstantInvite |
1225		PermissionManageRoles |
1226		PermissionManageChannels |
1227		PermissionAddReactions |
1228		PermissionViewAuditLogs
1229	PermissionAll = PermissionAllChannel |
1230		PermissionKickMembers |
1231		PermissionBanMembers |
1232		PermissionManageServer |
1233		PermissionAdministrator |
1234		PermissionManageWebhooks |
1235		PermissionManageEmojis
1236)
1237
1238// Block contains Discord JSON Error Response codes
1239const (
1240	ErrCodeUnknownAccount     = 10001
1241	ErrCodeUnknownApplication = 10002
1242	ErrCodeUnknownChannel     = 10003
1243	ErrCodeUnknownGuild       = 10004
1244	ErrCodeUnknownIntegration = 10005
1245	ErrCodeUnknownInvite      = 10006
1246	ErrCodeUnknownMember      = 10007
1247	ErrCodeUnknownMessage     = 10008
1248	ErrCodeUnknownOverwrite   = 10009
1249	ErrCodeUnknownProvider    = 10010
1250	ErrCodeUnknownRole        = 10011
1251	ErrCodeUnknownToken       = 10012
1252	ErrCodeUnknownUser        = 10013
1253	ErrCodeUnknownEmoji       = 10014
1254	ErrCodeUnknownWebhook     = 10015
1255	ErrCodeUnknownBan         = 10026
1256
1257	ErrCodeBotsCannotUseEndpoint  = 20001
1258	ErrCodeOnlyBotsCanUseEndpoint = 20002
1259
1260	ErrCodeMaximumGuildsReached     = 30001
1261	ErrCodeMaximumFriendsReached    = 30002
1262	ErrCodeMaximumPinsReached       = 30003
1263	ErrCodeMaximumGuildRolesReached = 30005
1264	ErrCodeTooManyReactions         = 30010
1265
1266	ErrCodeUnauthorized = 40001
1267
1268	ErrCodeMissingAccess                             = 50001
1269	ErrCodeInvalidAccountType                        = 50002
1270	ErrCodeCannotExecuteActionOnDMChannel            = 50003
1271	ErrCodeEmbedDisabled                             = 50004
1272	ErrCodeCannotEditFromAnotherUser                 = 50005
1273	ErrCodeCannotSendEmptyMessage                    = 50006
1274	ErrCodeCannotSendMessagesToThisUser              = 50007
1275	ErrCodeCannotSendMessagesInVoiceChannel          = 50008
1276	ErrCodeChannelVerificationLevelTooHigh           = 50009
1277	ErrCodeOAuth2ApplicationDoesNotHaveBot           = 50010
1278	ErrCodeOAuth2ApplicationLimitReached             = 50011
1279	ErrCodeInvalidOAuthState                         = 50012
1280	ErrCodeMissingPermissions                        = 50013
1281	ErrCodeInvalidAuthenticationToken                = 50014
1282	ErrCodeNoteTooLong                               = 50015
1283	ErrCodeTooFewOrTooManyMessagesToDelete           = 50016
1284	ErrCodeCanOnlyPinMessageToOriginatingChannel     = 50019
1285	ErrCodeCannotExecuteActionOnSystemMessage        = 50021
1286	ErrCodeMessageProvidedTooOldForBulkDelete        = 50034
1287	ErrCodeInvalidFormBody                           = 50035
1288	ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036
1289
1290	ErrCodeReactionBlocked = 90001
1291)
1292
1293// Intent is the type of a Gateway Intent
1294// https://discord.com/developers/docs/topics/gateway#gateway-intents
1295type Intent int
1296
1297// Constants for the different bit offsets of intents
1298const (
1299	IntentsGuilds Intent = 1 << iota
1300	IntentsGuildMembers
1301	IntentsGuildBans
1302	IntentsGuildEmojis
1303	IntentsGuildIntegrations
1304	IntentsGuildWebhooks
1305	IntentsGuildInvites
1306	IntentsGuildVoiceStates
1307	IntentsGuildPresences
1308	IntentsGuildMessages
1309	IntentsGuildMessageReactions
1310	IntentsGuildMessageTyping
1311	IntentsDirectMessages
1312	IntentsDirectMessageReactions
1313	IntentsDirectMessageTyping
1314
1315	IntentsAllWithoutPrivileged = IntentsGuilds |
1316		IntentsGuildBans |
1317		IntentsGuildEmojis |
1318		IntentsGuildIntegrations |
1319		IntentsGuildWebhooks |
1320		IntentsGuildInvites |
1321		IntentsGuildVoiceStates |
1322		IntentsGuildMessages |
1323		IntentsGuildMessageReactions |
1324		IntentsGuildMessageTyping |
1325		IntentsDirectMessages |
1326		IntentsDirectMessageReactions |
1327		IntentsDirectMessageTyping
1328	IntentsAll = IntentsAllWithoutPrivileged |
1329		IntentsGuildMembers |
1330		IntentsGuildPresences
1331	IntentsNone Intent = 0
1332)
1333
1334// MakeIntent used to help convert a gateway intent value for use in the Identify structure;
1335// this was useful to help support the use of a pointer type when intents were optional.
1336// This is now a no-op, and is not necessary to use.
1337func MakeIntent(intents Intent) Intent {
1338	return intents
1339}
1340