github.com/meowstercatel/discordgo@v0.0.0-20250615204139-29b43d676735/structs.go (about)

     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  
    12  package discordgo
    13  
    14  import (
    15  	"encoding/json"
    16  	"fmt"
    17  	"math"
    18  	"net/http"
    19  	"regexp"
    20  	"sync"
    21  	"time"
    22  
    23  	"github.com/gorilla/websocket"
    24  )
    25  
    26  // A Session represents a connection to the Discord API.
    27  type 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  	// Should voice connections reconnect on a session reconnect.
    46  	ShouldReconnectVoiceOnSessionError bool
    47  
    48  	// Should the session retry requests when rate limited.
    49  	ShouldRetryOnRateLimit bool
    50  
    51  	// Identify is sent during initial handshake with the discord gateway.
    52  	// https://discord.com/developers/docs/topics/gateway#identify
    53  	Identify Identify
    54  
    55  	// TODO: Remove Below, Deprecated, Use Identify struct
    56  	// Should the session request compressed websocket data.
    57  	Compress bool
    58  
    59  	// Sharding
    60  	ShardID    int
    61  	ShardCount int
    62  
    63  	// Should state tracking be enabled.
    64  	// State tracking is the best way for getting the users
    65  	// active guilds and the members of the guilds.
    66  	StateEnabled bool
    67  
    68  	// Whether or not to call event handlers synchronously.
    69  	// e.g. false = launch event handlers in their own goroutines.
    70  	SyncEvents bool
    71  
    72  	// Exposed but should not be modified by User.
    73  
    74  	// Whether the Data Websocket is ready
    75  	DataReady bool // NOTE: Maye be deprecated soon
    76  
    77  	// Max number of REST API retries
    78  	MaxRestRetries int
    79  
    80  	// Status stores the current status of the websocket connection
    81  	// this is being tested, may stay, may go away.
    82  	status int32
    83  
    84  	// Whether the Voice Websocket is ready
    85  	VoiceReady bool // NOTE: Deprecated.
    86  
    87  	// Whether the UDP Connection is ready
    88  	UDPReady bool // NOTE: Deprecated
    89  
    90  	// Stores a mapping of guild id's to VoiceConnections
    91  	VoiceConnections map[string]*VoiceConnection
    92  
    93  	// Managed state object, updated internally with events when
    94  	// StateEnabled is true.
    95  	State *State
    96  
    97  	// The http client used for REST requests
    98  	Client *http.Client
    99  
   100  	// The dialer used for WebSocket connection
   101  	Dialer *websocket.Dialer
   102  
   103  	// The user agent used for REST APIs
   104  	UserAgent string
   105  
   106  	// Stores the last HeartbeatAck that was received (in UTC)
   107  	LastHeartbeatAck time.Time
   108  
   109  	// Stores the last Heartbeat sent (in UTC)
   110  	LastHeartbeatSent time.Time
   111  
   112  	// used to deal with rate limits
   113  	Ratelimiter *RateLimiter
   114  
   115  	// Event handlers
   116  	handlersMu   sync.RWMutex
   117  	handlers     map[string][]*eventHandlerInstance
   118  	onceHandlers map[string][]*eventHandlerInstance
   119  
   120  	// The websocket connection.
   121  	wsConn *websocket.Conn
   122  
   123  	// When nil, the session is not listening.
   124  	listening chan interface{}
   125  
   126  	// sequence tracks the current gateway api websocket sequence number
   127  	sequence *int64
   128  
   129  	// stores sessions current Discord Gateway
   130  	gateway string
   131  
   132  	// stores session ID of current Gateway connection
   133  	sessionID string
   134  
   135  	// used to make sure gateway websocket writes do not happen concurrently
   136  	wsMutex sync.Mutex
   137  }
   138  
   139  // ApplicationIntegrationType dictates where application can be installed and its available interaction contexts.
   140  type ApplicationIntegrationType uint
   141  
   142  const (
   143  	// ApplicationIntegrationGuildInstall indicates that app is installable to guilds.
   144  	ApplicationIntegrationGuildInstall ApplicationIntegrationType = 0
   145  	// ApplicationIntegrationUserInstall indicates that app is installable to users.
   146  	ApplicationIntegrationUserInstall ApplicationIntegrationType = 1
   147  )
   148  
   149  // ApplicationInstallParams represents application's installation parameters
   150  // for default in-app oauth2 authorization link.
   151  type ApplicationInstallParams struct {
   152  	Scopes      []string `json:"scopes"`
   153  	Permissions int64    `json:"permissions,string"`
   154  }
   155  
   156  // ApplicationIntegrationTypeConfig represents application's configuration for a particular integration type.
   157  type ApplicationIntegrationTypeConfig struct {
   158  	OAuth2InstallParams *ApplicationInstallParams `json:"oauth2_install_params,omitempty"`
   159  }
   160  
   161  // Application stores values for a Discord Application
   162  type Application struct {
   163  	ID                     string                                                           `json:"id,omitempty"`
   164  	Name                   string                                                           `json:"name"`
   165  	Icon                   string                                                           `json:"icon,omitempty"`
   166  	Description            string                                                           `json:"description,omitempty"`
   167  	RPCOrigins             []string                                                         `json:"rpc_origins,omitempty"`
   168  	BotPublic              bool                                                             `json:"bot_public,omitempty"`
   169  	BotRequireCodeGrant    bool                                                             `json:"bot_require_code_grant,omitempty"`
   170  	TermsOfServiceURL      string                                                           `json:"terms_of_service_url"`
   171  	PrivacyProxyURL        string                                                           `json:"privacy_policy_url"`
   172  	Owner                  *User                                                            `json:"owner"`
   173  	Summary                string                                                           `json:"summary"`
   174  	VerifyKey              string                                                           `json:"verify_key"`
   175  	Team                   *Team                                                            `json:"team"`
   176  	GuildID                string                                                           `json:"guild_id"`
   177  	PrimarySKUID           string                                                           `json:"primary_sku_id"`
   178  	Slug                   string                                                           `json:"slug"`
   179  	CoverImage             string                                                           `json:"cover_image"`
   180  	Flags                  int                                                              `json:"flags,omitempty"`
   181  	IntegrationTypesConfig map[ApplicationIntegrationType]*ApplicationIntegrationTypeConfig `json:"integration_types,omitempty"`
   182  }
   183  
   184  // ApplicationRoleConnectionMetadataType represents the type of application role connection metadata.
   185  type ApplicationRoleConnectionMetadataType int
   186  
   187  // Application role connection metadata types.
   188  const (
   189  	ApplicationRoleConnectionMetadataIntegerLessThanOrEqual     ApplicationRoleConnectionMetadataType = 1
   190  	ApplicationRoleConnectionMetadataIntegerGreaterThanOrEqual  ApplicationRoleConnectionMetadataType = 2
   191  	ApplicationRoleConnectionMetadataIntegerEqual               ApplicationRoleConnectionMetadataType = 3
   192  	ApplicationRoleConnectionMetadataIntegerNotEqual            ApplicationRoleConnectionMetadataType = 4
   193  	ApplicationRoleConnectionMetadataDatetimeLessThanOrEqual    ApplicationRoleConnectionMetadataType = 5
   194  	ApplicationRoleConnectionMetadataDatetimeGreaterThanOrEqual ApplicationRoleConnectionMetadataType = 6
   195  	ApplicationRoleConnectionMetadataBooleanEqual               ApplicationRoleConnectionMetadataType = 7
   196  	ApplicationRoleConnectionMetadataBooleanNotEqual            ApplicationRoleConnectionMetadataType = 8
   197  )
   198  
   199  // ApplicationRoleConnectionMetadata stores application role connection metadata.
   200  type ApplicationRoleConnectionMetadata struct {
   201  	Type                     ApplicationRoleConnectionMetadataType `json:"type"`
   202  	Key                      string                                `json:"key"`
   203  	Name                     string                                `json:"name"`
   204  	NameLocalizations        map[Locale]string                     `json:"name_localizations"`
   205  	Description              string                                `json:"description"`
   206  	DescriptionLocalizations map[Locale]string                     `json:"description_localizations"`
   207  }
   208  
   209  // ApplicationRoleConnection represents the role connection that an application has attached to a user.
   210  type ApplicationRoleConnection struct {
   211  	PlatformName     string            `json:"platform_name"`
   212  	PlatformUsername string            `json:"platform_username"`
   213  	Metadata         map[string]string `json:"metadata"`
   214  }
   215  
   216  // UserConnection is a Connection returned from the UserConnections endpoint
   217  type UserConnection struct {
   218  	ID           string         `json:"id"`
   219  	Name         string         `json:"name"`
   220  	Type         string         `json:"type"`
   221  	Revoked      bool           `json:"revoked"`
   222  	Integrations []*Integration `json:"integrations"`
   223  }
   224  
   225  // Integration stores integration information
   226  type Integration struct {
   227  	ID                string             `json:"id"`
   228  	Name              string             `json:"name"`
   229  	Type              string             `json:"type"`
   230  	Enabled           bool               `json:"enabled"`
   231  	Syncing           bool               `json:"syncing"`
   232  	RoleID            string             `json:"role_id"`
   233  	EnableEmoticons   bool               `json:"enable_emoticons"`
   234  	ExpireBehavior    ExpireBehavior     `json:"expire_behavior"`
   235  	ExpireGracePeriod int                `json:"expire_grace_period"`
   236  	User              *User              `json:"user"`
   237  	Account           IntegrationAccount `json:"account"`
   238  	SyncedAt          time.Time          `json:"synced_at"`
   239  }
   240  
   241  // ExpireBehavior of Integration
   242  // https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
   243  type ExpireBehavior int
   244  
   245  // Block of valid ExpireBehaviors
   246  const (
   247  	ExpireBehaviorRemoveRole ExpireBehavior = 0
   248  	ExpireBehaviorKick       ExpireBehavior = 1
   249  )
   250  
   251  // IntegrationAccount is integration account information
   252  // sent by the UserConnections endpoint
   253  type IntegrationAccount struct {
   254  	ID   string `json:"id"`
   255  	Name string `json:"name"`
   256  }
   257  
   258  // A VoiceRegion stores data for a specific voice region server.
   259  // https://discord.com/developers/docs/resources/voice#voice-region-object
   260  type VoiceRegion struct {
   261  	ID         string `json:"id"`
   262  	Name       string `json:"name"`
   263  	Optimal    bool   `json:"optimal"`
   264  	Deprecated bool   `json:"deprecated"`
   265  	Custom     bool   `json:"custom"`
   266  }
   267  
   268  // InviteTargetType indicates the type of target of an invite
   269  // https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
   270  type InviteTargetType uint8
   271  
   272  // Invite target types
   273  const (
   274  	InviteTargetStream              InviteTargetType = 1
   275  	InviteTargetEmbeddedApplication InviteTargetType = 2
   276  )
   277  
   278  // A Invite stores all data related to a specific Discord Guild or Channel invite.
   279  type Invite struct {
   280  	Guild             *Guild           `json:"guild"`
   281  	Channel           *Channel         `json:"channel"`
   282  	Inviter           *User            `json:"inviter"`
   283  	Code              string           `json:"code"`
   284  	CreatedAt         time.Time        `json:"created_at"`
   285  	MaxAge            int              `json:"max_age"`
   286  	Uses              int              `json:"uses"`
   287  	MaxUses           int              `json:"max_uses"`
   288  	Revoked           bool             `json:"revoked"`
   289  	Temporary         bool             `json:"temporary"`
   290  	Unique            bool             `json:"unique"`
   291  	TargetUser        *User            `json:"target_user"`
   292  	TargetType        InviteTargetType `json:"target_type"`
   293  	TargetApplication *Application     `json:"target_application"`
   294  
   295  	// will only be filled when using InviteWithCounts
   296  	ApproximatePresenceCount int `json:"approximate_presence_count"`
   297  	ApproximateMemberCount   int `json:"approximate_member_count"`
   298  
   299  	ExpiresAt *time.Time `json:"expires_at"`
   300  }
   301  
   302  // ChannelType is the type of a Channel
   303  type ChannelType int
   304  
   305  // Block contains known ChannelType values
   306  const (
   307  	ChannelTypeGuildText          ChannelType = 0
   308  	ChannelTypeDM                 ChannelType = 1
   309  	ChannelTypeGuildVoice         ChannelType = 2
   310  	ChannelTypeGroupDM            ChannelType = 3
   311  	ChannelTypeGuildCategory      ChannelType = 4
   312  	ChannelTypeGuildNews          ChannelType = 5
   313  	ChannelTypeGuildStore         ChannelType = 6
   314  	ChannelTypeGuildNewsThread    ChannelType = 10
   315  	ChannelTypeGuildPublicThread  ChannelType = 11
   316  	ChannelTypeGuildPrivateThread ChannelType = 12
   317  	ChannelTypeGuildStageVoice    ChannelType = 13
   318  	ChannelTypeGuildDirectory     ChannelType = 14
   319  	ChannelTypeGuildForum         ChannelType = 15
   320  	ChannelTypeGuildMedia         ChannelType = 16
   321  )
   322  
   323  // ChannelFlags represent flags of a channel/thread.
   324  type ChannelFlags int
   325  
   326  // Block containing known ChannelFlags values.
   327  const (
   328  	// ChannelFlagPinned indicates whether the thread is pinned in the forum channel.
   329  	// NOTE: forum threads only.
   330  	ChannelFlagPinned ChannelFlags = 1 << 1
   331  	// ChannelFlagRequireTag indicates whether a tag is required to be specified when creating a thread.
   332  	// NOTE: forum channels only.
   333  	ChannelFlagRequireTag ChannelFlags = 1 << 4
   334  )
   335  
   336  // ForumSortOrderType represents sort order of a forum channel.
   337  type ForumSortOrderType int
   338  
   339  const (
   340  	// ForumSortOrderLatestActivity sorts posts by activity.
   341  	ForumSortOrderLatestActivity ForumSortOrderType = 0
   342  	// ForumSortOrderCreationDate sorts posts by creation time (from most recent to oldest).
   343  	ForumSortOrderCreationDate ForumSortOrderType = 1
   344  )
   345  
   346  // ForumLayout represents layout of a forum channel.
   347  type ForumLayout int
   348  
   349  const (
   350  	// ForumLayoutNotSet represents no default layout.
   351  	ForumLayoutNotSet ForumLayout = 0
   352  	// ForumLayoutListView displays forum posts as a list.
   353  	ForumLayoutListView ForumLayout = 1
   354  	// ForumLayoutGalleryView displays forum posts as a collection of tiles.
   355  	ForumLayoutGalleryView ForumLayout = 2
   356  )
   357  
   358  // A Channel holds all data related to an individual Discord channel.
   359  type Channel struct {
   360  	// The ID of the channel.
   361  	ID string `json:"id"`
   362  
   363  	// The ID of the guild to which the channel belongs, if it is in a guild.
   364  	// Else, this ID is empty (e.g. DM channels).
   365  	GuildID string `json:"guild_id"`
   366  
   367  	// The name of the channel.
   368  	Name string `json:"name"`
   369  
   370  	// The topic of the channel.
   371  	Topic string `json:"topic"`
   372  
   373  	// The type of the channel.
   374  	Type ChannelType `json:"type"`
   375  
   376  	// The ID of the last message sent in the channel. This is not
   377  	// guaranteed to be an ID of a valid message.
   378  	LastMessageID string `json:"last_message_id"`
   379  
   380  	// The timestamp of the last pinned message in the channel.
   381  	// nil if the channel has no pinned messages.
   382  	LastPinTimestamp *time.Time `json:"last_pin_timestamp"`
   383  
   384  	// An approximate count of messages in a thread, stops counting at 50
   385  	MessageCount int `json:"message_count"`
   386  	// An approximate count of users in a thread, stops counting at 50
   387  	MemberCount int `json:"member_count"`
   388  
   389  	// Whether the channel is marked as NSFW.
   390  	NSFW bool `json:"nsfw"`
   391  
   392  	// Icon of the group DM channel.
   393  	Icon string `json:"icon"`
   394  
   395  	// The position of the channel, used for sorting in client.
   396  	Position int `json:"position"`
   397  
   398  	// The bitrate of the channel, if it is a voice channel.
   399  	Bitrate int `json:"bitrate"`
   400  
   401  	// The recipients of the channel. This is only populated in DM channels.
   402  	Recipients []*User `json:"recipients"`
   403  
   404  	// The messages in the channel. This is only present in state-cached channels,
   405  	// and State.MaxMessageCount must be non-zero.
   406  	Messages []*Message `json:"-"`
   407  
   408  	// A list of permission overwrites present for the channel.
   409  	PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
   410  
   411  	// The user limit of the voice channel.
   412  	UserLimit int `json:"user_limit"`
   413  
   414  	// The ID of the parent channel, if the channel is under a category. For threads - id of the channel thread was created in.
   415  	ParentID string `json:"parent_id"`
   416  
   417  	// Amount of seconds a user has to wait before sending another message or creating another thread (0-21600)
   418  	// bots, as well as users with the permission manage_messages or manage_channel, are unaffected
   419  	RateLimitPerUser int `json:"rate_limit_per_user"`
   420  
   421  	// ID of the creator of the group DM or thread
   422  	OwnerID string `json:"owner_id"`
   423  
   424  	// ApplicationID of the DM creator Zeroed if guild channel or not a bot user
   425  	ApplicationID string `json:"application_id"`
   426  
   427  	// Thread-specific fields not needed by other channels
   428  	ThreadMetadata *ThreadMetadata `json:"thread_metadata,omitempty"`
   429  	// Thread member object for the current user, if they have joined the thread, only included on certain API endpoints
   430  	Member *ThreadMember `json:"thread_member"`
   431  
   432  	// All thread members. State channels only.
   433  	Members []*ThreadMember `json:"-"`
   434  
   435  	// Channel flags.
   436  	Flags ChannelFlags `json:"flags"`
   437  
   438  	// The set of tags that can be used in a forum channel.
   439  	AvailableTags []ForumTag `json:"available_tags"`
   440  
   441  	// The IDs of the set of tags that have been applied to a thread in a forum channel.
   442  	AppliedTags []string `json:"applied_tags"`
   443  
   444  	// Emoji to use as the default reaction to a forum post.
   445  	DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"`
   446  
   447  	// The initial RateLimitPerUser to set on newly created threads in a channel.
   448  	// This field is copied to the thread at creation time and does not live update.
   449  	DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user"`
   450  
   451  	// The default sort order type used to order posts in forum channels.
   452  	// Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
   453  	DefaultSortOrder *ForumSortOrderType `json:"default_sort_order"`
   454  
   455  	// The default forum layout view used to display posts in forum channels.
   456  	// Defaults to ForumLayoutNotSet, which indicates a layout view has not been set by a channel admin.
   457  	DefaultForumLayout ForumLayout `json:"default_forum_layout"`
   458  }
   459  
   460  // Mention returns a string which mentions the channel
   461  func (c *Channel) Mention() string {
   462  	return fmt.Sprintf("<#%s>", c.ID)
   463  }
   464  
   465  // IsThread is a helper function to determine if channel is a thread or not
   466  func (c *Channel) IsThread() bool {
   467  	return c.Type == ChannelTypeGuildPublicThread || c.Type == ChannelTypeGuildPrivateThread || c.Type == ChannelTypeGuildNewsThread
   468  }
   469  
   470  // A ChannelEdit holds Channel Field data for a channel edit.
   471  type ChannelEdit struct {
   472  	Name                          string                 `json:"name,omitempty"`
   473  	Topic                         string                 `json:"topic,omitempty"`
   474  	NSFW                          *bool                  `json:"nsfw,omitempty"`
   475  	Position                      *int                   `json:"position,omitempty"`
   476  	Bitrate                       int                    `json:"bitrate,omitempty"`
   477  	UserLimit                     int                    `json:"user_limit,omitempty"`
   478  	PermissionOverwrites          []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
   479  	ParentID                      string                 `json:"parent_id,omitempty"`
   480  	RateLimitPerUser              *int                   `json:"rate_limit_per_user,omitempty"`
   481  	Flags                         *ChannelFlags          `json:"flags,omitempty"`
   482  	DefaultThreadRateLimitPerUser *int                   `json:"default_thread_rate_limit_per_user,omitempty"`
   483  
   484  	// NOTE: threads only
   485  
   486  	Archived            *bool `json:"archived,omitempty"`
   487  	AutoArchiveDuration int   `json:"auto_archive_duration,omitempty"`
   488  	Locked              *bool `json:"locked,omitempty"`
   489  	Invitable           *bool `json:"invitable,omitempty"`
   490  
   491  	// NOTE: forum channels only
   492  
   493  	AvailableTags        *[]ForumTag           `json:"available_tags,omitempty"`
   494  	DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"`
   495  	DefaultSortOrder     *ForumSortOrderType   `json:"default_sort_order,omitempty"` // TODO: null
   496  	DefaultForumLayout   *ForumLayout          `json:"default_forum_layout,omitempty"`
   497  
   498  	// NOTE: forum threads only
   499  	AppliedTags *[]string `json:"applied_tags,omitempty"`
   500  }
   501  
   502  // A ChannelFollow holds data returned after following a news channel
   503  type ChannelFollow struct {
   504  	ChannelID string `json:"channel_id"`
   505  	WebhookID string `json:"webhook_id"`
   506  }
   507  
   508  // PermissionOverwriteType represents the type of resource on which
   509  // a permission overwrite acts.
   510  type PermissionOverwriteType int
   511  
   512  // The possible permission overwrite types.
   513  const (
   514  	PermissionOverwriteTypeRole   PermissionOverwriteType = 0
   515  	PermissionOverwriteTypeMember PermissionOverwriteType = 1
   516  )
   517  
   518  // A PermissionOverwrite holds permission overwrite data for a Channel
   519  type PermissionOverwrite struct {
   520  	ID    string                  `json:"id"`
   521  	Type  PermissionOverwriteType `json:"type"`
   522  	Deny  int64                   `json:"deny,string"`
   523  	Allow int64                   `json:"allow,string"`
   524  }
   525  
   526  // ThreadStart stores all parameters you can use with MessageThreadStartComplex or ThreadStartComplex
   527  type ThreadStart struct {
   528  	Name                string      `json:"name"`
   529  	AutoArchiveDuration int         `json:"auto_archive_duration,omitempty"`
   530  	Type                ChannelType `json:"type,omitempty"`
   531  	Invitable           bool        `json:"invitable"`
   532  	RateLimitPerUser    int         `json:"rate_limit_per_user,omitempty"`
   533  
   534  	// NOTE: forum threads only
   535  	AppliedTags []string `json:"applied_tags,omitempty"`
   536  }
   537  
   538  // ThreadMetadata contains a number of thread-specific channel fields that are not needed by other channel types.
   539  type ThreadMetadata struct {
   540  	// Whether the thread is archived
   541  	Archived bool `json:"archived"`
   542  	// Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
   543  	AutoArchiveDuration int `json:"auto_archive_duration"`
   544  	// Timestamp when the thread's archive status was last changed, used for calculating recent activity
   545  	ArchiveTimestamp time.Time `json:"archive_timestamp"`
   546  	// Whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it
   547  	Locked bool `json:"locked"`
   548  	// Whether non-moderators can add other non-moderators to a thread; only available on private threads
   549  	Invitable bool `json:"invitable"`
   550  }
   551  
   552  // ThreadMember is used to indicate whether a user has joined a thread or not.
   553  // NOTE: ID and UserID are empty (omitted) on the member sent within each thread in the GUILD_CREATE event.
   554  type ThreadMember struct {
   555  	// The id of the thread
   556  	ID string `json:"id,omitempty"`
   557  	// The id of the user
   558  	UserID string `json:"user_id,omitempty"`
   559  	// The time the current user last joined the thread
   560  	JoinTimestamp time.Time `json:"join_timestamp"`
   561  	// Any user-thread settings, currently only used for notifications
   562  	Flags int `json:"flags"`
   563  	// Additional information about the user.
   564  	// NOTE: only present if the withMember parameter is set to true
   565  	// when calling Session.ThreadMembers or Session.ThreadMember.
   566  	Member *Member `json:"member,omitempty"`
   567  }
   568  
   569  // ThreadsList represents a list of threads alongisde with thread member objects for the current user.
   570  type ThreadsList struct {
   571  	Threads []*Channel      `json:"threads"`
   572  	Members []*ThreadMember `json:"members"`
   573  	HasMore bool            `json:"has_more"`
   574  }
   575  
   576  // AddedThreadMember holds information about the user who was added to the thread
   577  type AddedThreadMember struct {
   578  	*ThreadMember
   579  	Member   *Member   `json:"member"`
   580  	Presence *Presence `json:"presence"`
   581  }
   582  
   583  // ForumDefaultReaction specifies emoji to use as the default reaction to a forum post.
   584  // NOTE: Exactly one of EmojiID and EmojiName must be set.
   585  type ForumDefaultReaction struct {
   586  	// The id of a guild's custom emoji.
   587  	EmojiID string `json:"emoji_id,omitempty"`
   588  	// The unicode character of the emoji.
   589  	EmojiName string `json:"emoji_name,omitempty"`
   590  }
   591  
   592  // ForumTag represents a tag that is able to be applied to a thread in a forum channel.
   593  type ForumTag struct {
   594  	ID        string `json:"id,omitempty"`
   595  	Name      string `json:"name"`
   596  	Moderated bool   `json:"moderated"`
   597  	EmojiID   string `json:"emoji_id,omitempty"`
   598  	EmojiName string `json:"emoji_name,omitempty"`
   599  }
   600  
   601  // Emoji struct holds data related to Emoji's
   602  type Emoji struct {
   603  	ID            string   `json:"id"`
   604  	Name          string   `json:"name"`
   605  	Roles         []string `json:"roles"`
   606  	User          *User    `json:"user"`
   607  	RequireColons bool     `json:"require_colons"`
   608  	Managed       bool     `json:"managed"`
   609  	Animated      bool     `json:"animated"`
   610  	Available     bool     `json:"available"`
   611  }
   612  
   613  // EmojiRegex is the regex used to find and identify emojis in messages
   614  var (
   615  	EmojiRegex = regexp.MustCompile(`<(a|):[A-Za-z0-9_~]+:[0-9]{18,20}>`)
   616  )
   617  
   618  // MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
   619  func (e *Emoji) MessageFormat() string {
   620  	if e.ID != "" && e.Name != "" {
   621  		if e.Animated {
   622  			return "<a:" + e.APIName() + ">"
   623  		}
   624  
   625  		return "<:" + e.APIName() + ">"
   626  	}
   627  
   628  	return e.APIName()
   629  }
   630  
   631  // APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
   632  func (e *Emoji) APIName() string {
   633  	if e.ID != "" && e.Name != "" {
   634  		return e.Name + ":" + e.ID
   635  	}
   636  	if e.Name != "" {
   637  		return e.Name
   638  	}
   639  	return e.ID
   640  }
   641  
   642  // EmojiParams represents parameters needed to create or update an Emoji.
   643  type EmojiParams struct {
   644  	// Name of the emoji
   645  	Name string `json:"name,omitempty"`
   646  	// A base64 encoded emoji image, has to be smaller than 256KB.
   647  	// NOTE: can be only set on creation.
   648  	Image string `json:"image,omitempty"`
   649  	// Roles for which this emoji will be available.
   650  	// NOTE: can not be used with application emoji endpoints.
   651  	Roles []string `json:"roles,omitempty"`
   652  }
   653  
   654  // StickerFormat is the file format of the Sticker.
   655  type StickerFormat int
   656  
   657  // Defines all known Sticker types.
   658  const (
   659  	StickerFormatTypePNG    StickerFormat = 1
   660  	StickerFormatTypeAPNG   StickerFormat = 2
   661  	StickerFormatTypeLottie StickerFormat = 3
   662  	StickerFormatTypeGIF    StickerFormat = 4
   663  )
   664  
   665  // StickerType is the type of sticker.
   666  type StickerType int
   667  
   668  // Defines Sticker types.
   669  const (
   670  	StickerTypeStandard StickerType = 1
   671  	StickerTypeGuild    StickerType = 2
   672  )
   673  
   674  // Sticker represents a sticker object that can be sent in a Message.
   675  type Sticker struct {
   676  	ID          string        `json:"id"`
   677  	PackID      string        `json:"pack_id"`
   678  	Name        string        `json:"name"`
   679  	Description string        `json:"description"`
   680  	Tags        string        `json:"tags"`
   681  	Type        StickerType   `json:"type"`
   682  	FormatType  StickerFormat `json:"format_type"`
   683  	Available   bool          `json:"available"`
   684  	GuildID     string        `json:"guild_id"`
   685  	User        *User         `json:"user"`
   686  	SortValue   int           `json:"sort_value"`
   687  }
   688  
   689  // StickerItem represents the smallest amount of data required to render a sticker. A partial sticker object.
   690  type StickerItem struct {
   691  	ID         string        `json:"id"`
   692  	Name       string        `json:"name"`
   693  	FormatType StickerFormat `json:"format_type"`
   694  }
   695  
   696  // StickerPack represents a pack of standard stickers.
   697  type StickerPack struct {
   698  	ID             string     `json:"id"`
   699  	Stickers       []*Sticker `json:"stickers"`
   700  	Name           string     `json:"name"`
   701  	SKUID          string     `json:"sku_id"`
   702  	CoverStickerID string     `json:"cover_sticker_id"`
   703  	Description    string     `json:"description"`
   704  	BannerAssetID  string     `json:"banner_asset_id"`
   705  }
   706  
   707  // VerificationLevel type definition
   708  type VerificationLevel int
   709  
   710  // Constants for VerificationLevel levels from 0 to 4 inclusive
   711  const (
   712  	VerificationLevelNone     VerificationLevel = 0
   713  	VerificationLevelLow      VerificationLevel = 1
   714  	VerificationLevelMedium   VerificationLevel = 2
   715  	VerificationLevelHigh     VerificationLevel = 3
   716  	VerificationLevelVeryHigh VerificationLevel = 4
   717  )
   718  
   719  // ExplicitContentFilterLevel type definition
   720  type ExplicitContentFilterLevel int
   721  
   722  // Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive
   723  const (
   724  	ExplicitContentFilterDisabled            ExplicitContentFilterLevel = 0
   725  	ExplicitContentFilterMembersWithoutRoles ExplicitContentFilterLevel = 1
   726  	ExplicitContentFilterAllMembers          ExplicitContentFilterLevel = 2
   727  )
   728  
   729  // GuildNSFWLevel type definition
   730  type GuildNSFWLevel int
   731  
   732  // Constants for GuildNSFWLevel levels from 0 to 3 inclusive
   733  const (
   734  	GuildNSFWLevelDefault       GuildNSFWLevel = 0
   735  	GuildNSFWLevelExplicit      GuildNSFWLevel = 1
   736  	GuildNSFWLevelSafe          GuildNSFWLevel = 2
   737  	GuildNSFWLevelAgeRestricted GuildNSFWLevel = 3
   738  )
   739  
   740  // MfaLevel type definition
   741  type MfaLevel int
   742  
   743  // Constants for MfaLevel levels from 0 to 1 inclusive
   744  const (
   745  	MfaLevelNone     MfaLevel = 0
   746  	MfaLevelElevated MfaLevel = 1
   747  )
   748  
   749  // PremiumTier type definition
   750  type PremiumTier int
   751  
   752  // Constants for PremiumTier levels from 0 to 3 inclusive
   753  const (
   754  	PremiumTierNone PremiumTier = 0
   755  	PremiumTier1    PremiumTier = 1
   756  	PremiumTier2    PremiumTier = 2
   757  	PremiumTier3    PremiumTier = 3
   758  )
   759  
   760  // A Guild holds all data related to a specific Discord Guild.  Guilds are also
   761  // sometimes referred to as Servers in the Discord client.
   762  type Guild struct {
   763  	// The ID of the guild.
   764  	ID string `json:"id"`
   765  
   766  	// The name of the guild. (2–100 characters)
   767  	Name string `json:"name"`
   768  
   769  	// The hash of the guild's icon. Use Session.GuildIcon
   770  	// to retrieve the icon itself.
   771  	Icon string `json:"icon"`
   772  
   773  	// The voice region of the guild.
   774  	Region string `json:"region"`
   775  
   776  	// The ID of the AFK voice channel.
   777  	AfkChannelID string `json:"afk_channel_id"`
   778  
   779  	// The user ID of the owner of the guild.
   780  	OwnerID string `json:"owner_id"`
   781  
   782  	// If we are the owner of the guild
   783  	Owner bool `json:"owner"`
   784  
   785  	// The time at which the current user joined the guild.
   786  	// This field is only present in GUILD_CREATE events and websocket
   787  	// update events, and thus is only present in state-cached guilds.
   788  	JoinedAt time.Time `json:"joined_at"`
   789  
   790  	// The hash of the guild's discovery splash.
   791  	DiscoverySplash string `json:"discovery_splash"`
   792  
   793  	// The hash of the guild's splash.
   794  	Splash string `json:"splash"`
   795  
   796  	// The timeout, in seconds, before a user is considered AFK in voice.
   797  	AfkTimeout int `json:"afk_timeout"`
   798  
   799  	// The number of members in the guild.
   800  	// This field is only present in GUILD_CREATE events and websocket
   801  	// update events, and thus is only present in state-cached guilds.
   802  	MemberCount int `json:"member_count"`
   803  
   804  	// The verification level required for the guild.
   805  	VerificationLevel VerificationLevel `json:"verification_level"`
   806  
   807  	// Whether the guild is considered large. This is
   808  	// determined by a member threshold in the identify packet,
   809  	// and is currently hard-coded at 250 members in the library.
   810  	Large bool `json:"large"`
   811  
   812  	// The default message notification setting for the guild.
   813  	DefaultMessageNotifications MessageNotifications `json:"default_message_notifications"`
   814  
   815  	// A list of roles in the guild.
   816  	Roles []*Role `json:"roles"`
   817  
   818  	// A list of the custom emojis present in the guild.
   819  	Emojis []*Emoji `json:"emojis"`
   820  
   821  	// A list of the custom stickers present in the guild.
   822  	Stickers []*Sticker `json:"stickers"`
   823  
   824  	// A list of the members in the guild.
   825  	// This field is only present in GUILD_CREATE events and websocket
   826  	// update events, and thus is only present in state-cached guilds.
   827  	Members []*Member `json:"members"`
   828  
   829  	// A list of partial presence objects for members in the guild.
   830  	// This field is only present in GUILD_CREATE events and websocket
   831  	// update events, and thus is only present in state-cached guilds.
   832  	Presences []*Presence `json:"presences"`
   833  
   834  	// The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned)
   835  	MaxPresences int `json:"max_presences"`
   836  
   837  	// The maximum number of members for the guild
   838  	MaxMembers int `json:"max_members"`
   839  
   840  	// A list of channels in the guild.
   841  	// This field is only present in GUILD_CREATE events and websocket
   842  	// update events, and thus is only present in state-cached guilds.
   843  	Channels []*Channel `json:"channels"`
   844  
   845  	// A list of all active threads in the guild that current user has permission to view
   846  	// This field is only present in GUILD_CREATE events and websocket
   847  	// update events and thus is only present in state-cached guilds.
   848  	Threads []*Channel `json:"threads"`
   849  
   850  	// A list of voice states for the guild.
   851  	// This field is only present in GUILD_CREATE events and websocket
   852  	// update events, and thus is only present in state-cached guilds.
   853  	VoiceStates []*VoiceState `json:"voice_states"`
   854  
   855  	// Whether this guild is currently unavailable (most likely due to outage).
   856  	// This field is only present in GUILD_CREATE events and websocket
   857  	// update events, and thus is only present in state-cached guilds.
   858  	Unavailable bool `json:"unavailable"`
   859  
   860  	// The explicit content filter level
   861  	ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
   862  
   863  	// The NSFW Level of the guild
   864  	NSFWLevel GuildNSFWLevel `json:"nsfw_level"`
   865  
   866  	// The list of enabled guild features
   867  	Features []GuildFeature `json:"features"`
   868  
   869  	// Required MFA level for the guild
   870  	MfaLevel MfaLevel `json:"mfa_level"`
   871  
   872  	// The application id of the guild if bot created.
   873  	ApplicationID string `json:"application_id"`
   874  
   875  	// Whether or not the Server Widget is enabled
   876  	WidgetEnabled bool `json:"widget_enabled"`
   877  
   878  	// The Channel ID for the Server Widget
   879  	WidgetChannelID string `json:"widget_channel_id"`
   880  
   881  	// The Channel ID to which system messages are sent (eg join and leave messages)
   882  	SystemChannelID string `json:"system_channel_id"`
   883  
   884  	// The System channel flags
   885  	SystemChannelFlags SystemChannelFlag `json:"system_channel_flags"`
   886  
   887  	// The ID of the rules channel ID, used for rules.
   888  	RulesChannelID string `json:"rules_channel_id"`
   889  
   890  	// the vanity url code for the guild
   891  	VanityURLCode string `json:"vanity_url_code"`
   892  
   893  	// the description for the guild
   894  	Description string `json:"description"`
   895  
   896  	// The hash of the guild's banner
   897  	Banner string `json:"banner"`
   898  
   899  	// The premium tier of the guild
   900  	PremiumTier PremiumTier `json:"premium_tier"`
   901  
   902  	// The total number of users currently boosting this server
   903  	PremiumSubscriptionCount int `json:"premium_subscription_count"`
   904  
   905  	// The preferred locale of a guild with the "PUBLIC" feature; used in server discovery and notices from Discord; defaults to "en-US"
   906  	PreferredLocale string `json:"preferred_locale"`
   907  
   908  	// The id of the channel where admins and moderators of guilds with the "PUBLIC" feature receive notices from Discord
   909  	PublicUpdatesChannelID string `json:"public_updates_channel_id"`
   910  
   911  	// The maximum amount of users in a video channel
   912  	MaxVideoChannelUsers int `json:"max_video_channel_users"`
   913  
   914  	// Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
   915  	ApproximateMemberCount int `json:"approximate_member_count"`
   916  
   917  	// Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
   918  	ApproximatePresenceCount int `json:"approximate_presence_count"`
   919  
   920  	// Permissions of our user
   921  	Permissions int64 `json:"permissions,string"`
   922  
   923  	// Stage instances in the guild
   924  	StageInstances []*StageInstance `json:"stage_instances"`
   925  }
   926  
   927  // A GuildPreview holds data related to a specific public Discord Guild, even if the user is not in the guild.
   928  type GuildPreview struct {
   929  	// The ID of the guild.
   930  	ID string `json:"id"`
   931  
   932  	// The name of the guild. (2–100 characters)
   933  	Name string `json:"name"`
   934  
   935  	// The hash of the guild's icon. Use Session.GuildIcon
   936  	// to retrieve the icon itself.
   937  	Icon string `json:"icon"`
   938  
   939  	// The hash of the guild's splash.
   940  	Splash string `json:"splash"`
   941  
   942  	// The hash of the guild's discovery splash.
   943  	DiscoverySplash string `json:"discovery_splash"`
   944  
   945  	// A list of the custom emojis present in the guild.
   946  	Emojis []*Emoji `json:"emojis"`
   947  
   948  	// The list of enabled guild features
   949  	Features []string `json:"features"`
   950  
   951  	// Approximate number of members in this guild
   952  	// NOTE: this field is only filled when using GuildWithCounts
   953  	ApproximateMemberCount int `json:"approximate_member_count"`
   954  
   955  	// Approximate number of non-offline members in this guild
   956  	// NOTE: this field is only filled when using GuildWithCounts
   957  	ApproximatePresenceCount int `json:"approximate_presence_count"`
   958  
   959  	// the description for the guild
   960  	Description string `json:"description"`
   961  }
   962  
   963  // IconURL returns a URL to the guild's icon.
   964  //
   965  //	size:    The size of the desired icon image as a power of two
   966  //	         Image size can be any power of two between 16 and 4096.
   967  func (g *GuildPreview) IconURL(size string) string {
   968  	return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size)
   969  }
   970  
   971  // GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data.
   972  // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event
   973  type GuildScheduledEvent struct {
   974  	// The ID of the scheduled event
   975  	ID string `json:"id"`
   976  	// The guild id which the scheduled event belongs to
   977  	GuildID string `json:"guild_id"`
   978  	// The channel id in which the scheduled event will be hosted, or null if scheduled entity type is EXTERNAL
   979  	ChannelID string `json:"channel_id"`
   980  	// The id of the user that created the scheduled event
   981  	CreatorID string `json:"creator_id"`
   982  	// The name of the scheduled event (1-100 characters)
   983  	Name string `json:"name"`
   984  	// The description of the scheduled event (1-1000 characters)
   985  	Description string `json:"description"`
   986  	// The time the scheduled event will start
   987  	ScheduledStartTime time.Time `json:"scheduled_start_time"`
   988  	// The time the scheduled event will end, required only when entity_type is EXTERNAL
   989  	ScheduledEndTime *time.Time `json:"scheduled_end_time"`
   990  	// The privacy level of the scheduled event
   991  	PrivacyLevel GuildScheduledEventPrivacyLevel `json:"privacy_level"`
   992  	// The status of the scheduled event
   993  	Status GuildScheduledEventStatus `json:"status"`
   994  	// Type of the entity where event would be hosted
   995  	// See field requirements
   996  	// https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-field-requirements-by-entity-type
   997  	EntityType GuildScheduledEventEntityType `json:"entity_type"`
   998  	// The id of an entity associated with a guild scheduled event
   999  	EntityID string `json:"entity_id"`
  1000  	// Additional metadata for the guild scheduled event
  1001  	EntityMetadata GuildScheduledEventEntityMetadata `json:"entity_metadata"`
  1002  	// The user that created the scheduled event
  1003  	Creator *User `json:"creator"`
  1004  	// The number of users subscribed to the scheduled event
  1005  	UserCount int `json:"user_count"`
  1006  	// The cover image hash of the scheduled event
  1007  	// see https://discord.com/developers/docs/reference#image-formatting for more
  1008  	// information about image formatting
  1009  	Image string `json:"image"`
  1010  }
  1011  
  1012  // GuildScheduledEventParams are the parameters allowed for creating or updating a scheduled event
  1013  // https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
  1014  type GuildScheduledEventParams struct {
  1015  	// The channel id in which the scheduled event will be hosted, or null if scheduled entity type is EXTERNAL
  1016  	ChannelID string `json:"channel_id,omitempty"`
  1017  	// The name of the scheduled event (1-100 characters)
  1018  	Name string `json:"name,omitempty"`
  1019  	// The description of the scheduled event (1-1000 characters)
  1020  	Description string `json:"description,omitempty"`
  1021  	// The time the scheduled event will start
  1022  	ScheduledStartTime *time.Time `json:"scheduled_start_time,omitempty"`
  1023  	// The time the scheduled event will end, required only when entity_type is EXTERNAL
  1024  	ScheduledEndTime *time.Time `json:"scheduled_end_time,omitempty"`
  1025  	// The privacy level of the scheduled event
  1026  	PrivacyLevel GuildScheduledEventPrivacyLevel `json:"privacy_level,omitempty"`
  1027  	// The status of the scheduled event
  1028  	Status GuildScheduledEventStatus `json:"status,omitempty"`
  1029  	// Type of the entity where event would be hosted
  1030  	// See field requirements
  1031  	// https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-field-requirements-by-entity-type
  1032  	EntityType GuildScheduledEventEntityType `json:"entity_type,omitempty"`
  1033  	// Additional metadata for the guild scheduled event
  1034  	EntityMetadata *GuildScheduledEventEntityMetadata `json:"entity_metadata,omitempty"`
  1035  	// The cover image hash of the scheduled event
  1036  	// see https://discord.com/developers/docs/reference#image-formatting for more
  1037  	// information about image formatting
  1038  	Image string `json:"image,omitempty"`
  1039  }
  1040  
  1041  // MarshalJSON is a helper function to marshal GuildScheduledEventParams
  1042  func (p GuildScheduledEventParams) MarshalJSON() ([]byte, error) {
  1043  	type guildScheduledEventParams GuildScheduledEventParams
  1044  
  1045  	if p.EntityType == GuildScheduledEventEntityTypeExternal && p.ChannelID == "" {
  1046  		return Marshal(struct {
  1047  			guildScheduledEventParams
  1048  			ChannelID json.RawMessage `json:"channel_id"`
  1049  		}{
  1050  			guildScheduledEventParams: guildScheduledEventParams(p),
  1051  			ChannelID:                 json.RawMessage("null"),
  1052  		})
  1053  	}
  1054  
  1055  	return Marshal(guildScheduledEventParams(p))
  1056  }
  1057  
  1058  // GuildScheduledEventEntityMetadata holds additional metadata for guild scheduled event.
  1059  type GuildScheduledEventEntityMetadata struct {
  1060  	// location of the event (1-100 characters)
  1061  	// required for events with 'entity_type': EXTERNAL
  1062  	Location string `json:"location"`
  1063  }
  1064  
  1065  // GuildScheduledEventPrivacyLevel is the privacy level of a scheduled event.
  1066  // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level
  1067  type GuildScheduledEventPrivacyLevel int
  1068  
  1069  const (
  1070  	// GuildScheduledEventPrivacyLevelGuildOnly makes the scheduled
  1071  	// event is only accessible to guild members
  1072  	GuildScheduledEventPrivacyLevelGuildOnly GuildScheduledEventPrivacyLevel = 2
  1073  )
  1074  
  1075  // GuildScheduledEventStatus is the status of a scheduled event
  1076  // Valid Guild Scheduled Event Status Transitions :
  1077  // SCHEDULED --> ACTIVE --> COMPLETED
  1078  // SCHEDULED --> CANCELED
  1079  // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status
  1080  type GuildScheduledEventStatus int
  1081  
  1082  const (
  1083  	// GuildScheduledEventStatusScheduled represents the current event is in scheduled state
  1084  	GuildScheduledEventStatusScheduled GuildScheduledEventStatus = 1
  1085  	// GuildScheduledEventStatusActive represents the current event is in active state
  1086  	GuildScheduledEventStatusActive GuildScheduledEventStatus = 2
  1087  	// GuildScheduledEventStatusCompleted represents the current event is in completed state
  1088  	GuildScheduledEventStatusCompleted GuildScheduledEventStatus = 3
  1089  	// GuildScheduledEventStatusCanceled represents the current event is in canceled state
  1090  	GuildScheduledEventStatusCanceled GuildScheduledEventStatus = 4
  1091  )
  1092  
  1093  // GuildScheduledEventEntityType is the type of entity associated with a guild scheduled event.
  1094  // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types
  1095  type GuildScheduledEventEntityType int
  1096  
  1097  const (
  1098  	// GuildScheduledEventEntityTypeStageInstance represents a stage channel
  1099  	GuildScheduledEventEntityTypeStageInstance GuildScheduledEventEntityType = 1
  1100  	// GuildScheduledEventEntityTypeVoice represents a voice channel
  1101  	GuildScheduledEventEntityTypeVoice GuildScheduledEventEntityType = 2
  1102  	// GuildScheduledEventEntityTypeExternal represents an external event
  1103  	GuildScheduledEventEntityTypeExternal GuildScheduledEventEntityType = 3
  1104  )
  1105  
  1106  // GuildScheduledEventUser is a user subscribed to a scheduled event.
  1107  // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object
  1108  type GuildScheduledEventUser struct {
  1109  	GuildScheduledEventID string  `json:"guild_scheduled_event_id"`
  1110  	User                  *User   `json:"user"`
  1111  	Member                *Member `json:"member"`
  1112  }
  1113  
  1114  // GuildOnboardingMode defines the criteria used to satisfy constraints that are required for enabling onboarding.
  1115  // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-mode
  1116  type GuildOnboardingMode int
  1117  
  1118  // Block containing known GuildOnboardingMode values.
  1119  const (
  1120  	// GuildOnboardingModeDefault counts default channels towards constraints.
  1121  	GuildOnboardingModeDefault GuildOnboardingMode = 0
  1122  	// GuildOnboardingModeAdvanced counts default channels and questions towards constraints.
  1123  	GuildOnboardingModeAdvanced GuildOnboardingMode = 1
  1124  )
  1125  
  1126  // GuildOnboarding represents the onboarding flow for a guild.
  1127  // https://discord.com/developers/docs/resources/guild#guild-onboarding-object
  1128  type GuildOnboarding struct {
  1129  	// ID of the guild this onboarding flow is part of.
  1130  	GuildID string `json:"guild_id,omitempty"`
  1131  
  1132  	// Prompts shown during onboarding and in the customize community (Channels & Roles) tab.
  1133  	Prompts *[]GuildOnboardingPrompt `json:"prompts,omitempty"`
  1134  
  1135  	// Channel IDs that members get opted into automatically.
  1136  	DefaultChannelIDs []string `json:"default_channel_ids,omitempty"`
  1137  
  1138  	// Whether onboarding is enabled in the guild.
  1139  	Enabled *bool `json:"enabled,omitempty"`
  1140  
  1141  	// Mode of onboarding.
  1142  	Mode *GuildOnboardingMode `json:"mode,omitempty"`
  1143  }
  1144  
  1145  // GuildOnboardingPromptType is the type of an onboarding prompt.
  1146  // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-types
  1147  type GuildOnboardingPromptType int
  1148  
  1149  // Block containing known GuildOnboardingPromptType values.
  1150  const (
  1151  	GuildOnboardingPromptTypeMultipleChoice GuildOnboardingPromptType = 0
  1152  	GuildOnboardingPromptTypeDropdown       GuildOnboardingPromptType = 1
  1153  )
  1154  
  1155  // GuildOnboardingPrompt is a prompt shown during onboarding and in the customize community (Channels & Roles) tab.
  1156  // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-onboarding-prompt-structure
  1157  type GuildOnboardingPrompt struct {
  1158  	// ID of the prompt.
  1159  	// NOTE: always requires to be a valid snowflake (e.g. "0"), see
  1160  	// https://github.com/discord/discord-api-docs/issues/6320 for more information.
  1161  	ID string `json:"id,omitempty"`
  1162  
  1163  	// Type of the prompt.
  1164  	Type GuildOnboardingPromptType `json:"type"`
  1165  
  1166  	// Options available within the prompt.
  1167  	Options []GuildOnboardingPromptOption `json:"options"`
  1168  
  1169  	// Title of the prompt.
  1170  	Title string `json:"title"`
  1171  
  1172  	// Indicates whether users are limited to selecting one option for the prompt.
  1173  	SingleSelect bool `json:"single_select"`
  1174  
  1175  	// Indicates whether the prompt is required before a user completes the onboarding flow.
  1176  	Required bool `json:"required"`
  1177  
  1178  	// Indicates whether the prompt is present in the onboarding flow.
  1179  	// If false, the prompt will only appear in the customize community (Channels & Roles) tab.
  1180  	InOnboarding bool `json:"in_onboarding"`
  1181  }
  1182  
  1183  // GuildOnboardingPromptOption is an option available within an onboarding prompt.
  1184  // https://discord.com/developers/docs/resources/guild#guild-onboarding-object-prompt-option-structure
  1185  type GuildOnboardingPromptOption struct {
  1186  	// ID of the prompt option.
  1187  	ID string `json:"id,omitempty"`
  1188  
  1189  	// IDs for channels a member is added to when the option is selected.
  1190  	ChannelIDs []string `json:"channel_ids"`
  1191  
  1192  	// IDs for roles assigned to a member when the option is selected.
  1193  	RoleIDs []string `json:"role_ids"`
  1194  
  1195  	// Emoji of the option.
  1196  	// NOTE: when creating or updating a prompt option
  1197  	// EmojiID, EmojiName and EmojiAnimated should be used instead.
  1198  	Emoji *Emoji `json:"emoji,omitempty"`
  1199  
  1200  	// Title of the option.
  1201  	Title string `json:"title"`
  1202  
  1203  	// Description of the option.
  1204  	Description string `json:"description"`
  1205  
  1206  	// ID of the option's emoji.
  1207  	// NOTE: only used when creating or updating a prompt option.
  1208  	EmojiID string `json:"emoji_id,omitempty"`
  1209  	// Name of the option's emoji.
  1210  	// NOTE: only used when creating or updating a prompt option.
  1211  	EmojiName string `json:"emoji_name,omitempty"`
  1212  	// Whether the option's emoji is animated.
  1213  	// NOTE: only used when creating or updating a prompt option.
  1214  	EmojiAnimated *bool `json:"emoji_animated,omitempty"`
  1215  }
  1216  
  1217  // A GuildTemplate represents a replicable template for guild creation
  1218  type GuildTemplate struct {
  1219  	// The unique code for the guild template
  1220  	Code string `json:"code"`
  1221  
  1222  	// The name of the template
  1223  	Name string `json:"name,omitempty"`
  1224  
  1225  	// The description for the template
  1226  	Description *string `json:"description,omitempty"`
  1227  
  1228  	// The number of times this template has been used
  1229  	UsageCount int `json:"usage_count"`
  1230  
  1231  	// The ID of the user who created the template
  1232  	CreatorID string `json:"creator_id"`
  1233  
  1234  	// The user who created the template
  1235  	Creator *User `json:"creator"`
  1236  
  1237  	// The timestamp of when the template was created
  1238  	CreatedAt time.Time `json:"created_at"`
  1239  
  1240  	// The timestamp of when the template was last synced
  1241  	UpdatedAt time.Time `json:"updated_at"`
  1242  
  1243  	// The ID of the guild the template was based on
  1244  	SourceGuildID string `json:"source_guild_id"`
  1245  
  1246  	// The guild 'snapshot' this template contains
  1247  	SerializedSourceGuild *Guild `json:"serialized_source_guild"`
  1248  
  1249  	// Whether the template has unsynced changes
  1250  	IsDirty bool `json:"is_dirty"`
  1251  }
  1252  
  1253  // GuildTemplateParams stores the data needed to create or update a GuildTemplate.
  1254  type GuildTemplateParams struct {
  1255  	// The name of the template (1-100 characters)
  1256  	Name string `json:"name,omitempty"`
  1257  	// The description of the template (0-120 characters)
  1258  	Description string `json:"description,omitempty"`
  1259  }
  1260  
  1261  // MessageNotifications is the notification level for a guild
  1262  // https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
  1263  type MessageNotifications int
  1264  
  1265  // Block containing known MessageNotifications values
  1266  const (
  1267  	MessageNotificationsAllMessages  MessageNotifications = 0
  1268  	MessageNotificationsOnlyMentions MessageNotifications = 1
  1269  )
  1270  
  1271  // SystemChannelFlag is the type of flags in the system channel (see SystemChannelFlag* consts)
  1272  // https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
  1273  type SystemChannelFlag int
  1274  
  1275  // Block containing known SystemChannelFlag values
  1276  const (
  1277  	SystemChannelFlagsSuppressJoinNotifications          SystemChannelFlag = 1 << 0
  1278  	SystemChannelFlagsSuppressPremium                    SystemChannelFlag = 1 << 1
  1279  	SystemChannelFlagsSuppressGuildReminderNotifications SystemChannelFlag = 1 << 2
  1280  	SystemChannelFlagsSuppressJoinNotificationReplies    SystemChannelFlag = 1 << 3
  1281  )
  1282  
  1283  // IconURL returns a URL to the guild's icon.
  1284  //
  1285  //	size:    The size of the desired icon image as a power of two
  1286  //	         Image size can be any power of two between 16 and 4096.
  1287  func (g *Guild) IconURL(size string) string {
  1288  	return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size)
  1289  }
  1290  
  1291  // BannerURL returns a URL to the guild's banner.
  1292  //
  1293  //	size:    The size of the desired banner image as a power of two
  1294  //	         Image size can be any power of two between 16 and 4096.
  1295  func (g *Guild) BannerURL(size string) string {
  1296  	return bannerURL(g.Banner, EndpointGuildBanner(g.ID, g.Banner), EndpointGuildBannerAnimated(g.ID, g.Banner), size)
  1297  }
  1298  
  1299  // A UserGuild holds a brief version of a Guild
  1300  type UserGuild struct {
  1301  	ID          string         `json:"id"`
  1302  	Name        string         `json:"name"`
  1303  	Icon        string         `json:"icon"`
  1304  	Owner       bool           `json:"owner"`
  1305  	Permissions int64          `json:"permissions,string"`
  1306  	Features    []GuildFeature `json:"features"`
  1307  
  1308  	// Approximate number of members in this guild.
  1309  	// NOTE: this field is only filled when withCounts is true.
  1310  	ApproximateMemberCount int `json:"approximate_member_count"`
  1311  
  1312  	// Approximate number of non-offline members in this guild.
  1313  	// NOTE: this field is only filled when withCounts is true.
  1314  	ApproximatePresenceCount int `json:"approximate_presence_count"`
  1315  }
  1316  
  1317  // GuildFeature indicates the presence of a feature in a guild
  1318  type GuildFeature string
  1319  
  1320  // Constants for GuildFeature
  1321  const (
  1322  	GuildFeatureAnimatedBanner                        GuildFeature = "ANIMATED_BANNER"
  1323  	GuildFeatureAnimatedIcon                          GuildFeature = "ANIMATED_ICON"
  1324  	GuildFeatureApplicationCommandPermissionV2        GuildFeature = "APPLICATION_COMMAND_PERMISSIONS_V2"
  1325  	GuildFeatureAutoModeration                        GuildFeature = "AUTO_MODERATION"
  1326  	GuildFeatureBanner                                GuildFeature = "BANNER"
  1327  	GuildFeatureCommunity                             GuildFeature = "COMMUNITY"
  1328  	GuildFeatureCreatorMonetizableProvisional         GuildFeature = "CREATOR_MONETIZABLE_PROVISIONAL"
  1329  	GuildFeatureCreatorStorePage                      GuildFeature = "CREATOR_STORE_PAGE"
  1330  	GuildFeatureDeveloperSupportServer                GuildFeature = "DEVELOPER_SUPPORT_SERVER"
  1331  	GuildFeatureDiscoverable                          GuildFeature = "DISCOVERABLE"
  1332  	GuildFeatureFeaturable                            GuildFeature = "FEATURABLE"
  1333  	GuildFeatureInvitesDisabled                       GuildFeature = "INVITES_DISABLED"
  1334  	GuildFeatureInviteSplash                          GuildFeature = "INVITE_SPLASH"
  1335  	GuildFeatureMemberVerificationGateEnabled         GuildFeature = "MEMBER_VERIFICATION_GATE_ENABLED"
  1336  	GuildFeatureMoreSoundboard                        GuildFeature = "MORE_SOUNDBOARD"
  1337  	GuildFeatureMoreStickers                          GuildFeature = "MORE_STICKERS"
  1338  	GuildFeatureNews                                  GuildFeature = "NEWS"
  1339  	GuildFeaturePartnered                             GuildFeature = "PARTNERED"
  1340  	GuildFeaturePreviewEnabled                        GuildFeature = "PREVIEW_ENABLED"
  1341  	GuildFeatureRaidAlertsDisabled                    GuildFeature = "RAID_ALERTS_DISABLED"
  1342  	GuildFeatureRoleIcons                             GuildFeature = "ROLE_ICONS"
  1343  	GuildFeatureRoleSubscriptionsAvailableForPurchase GuildFeature = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE"
  1344  	GuildFeatureRoleSubscriptionsEnabled              GuildFeature = "ROLE_SUBSCRIPTIONS_ENABLED"
  1345  	GuildFeatureSoundboard                            GuildFeature = "SOUNDBOARD"
  1346  	GuildFeatureTicketedEventsEnabled                 GuildFeature = "TICKETED_EVENTS_ENABLED"
  1347  	GuildFeatureVanityURL                             GuildFeature = "VANITY_URL"
  1348  	GuildFeatureVerified                              GuildFeature = "VERIFIED"
  1349  	GuildFeatureVipRegions                            GuildFeature = "VIP_REGIONS"
  1350  	GuildFeatureWelcomeScreenEnabled                  GuildFeature = "WELCOME_SCREEN_ENABLED"
  1351  )
  1352  
  1353  // A GuildParams stores all the data needed to update discord guild settings
  1354  type GuildParams struct {
  1355  	Name                        string             `json:"name,omitempty"`
  1356  	Region                      string             `json:"region,omitempty"`
  1357  	VerificationLevel           *VerificationLevel `json:"verification_level,omitempty"`
  1358  	DefaultMessageNotifications int                `json:"default_message_notifications,omitempty"` // TODO: Separate type?
  1359  	ExplicitContentFilter       int                `json:"explicit_content_filter,omitempty"`
  1360  	AfkChannelID                string             `json:"afk_channel_id,omitempty"`
  1361  	AfkTimeout                  int                `json:"afk_timeout,omitempty"`
  1362  	Icon                        string             `json:"icon,omitempty"`
  1363  	OwnerID                     string             `json:"owner_id,omitempty"`
  1364  	Splash                      string             `json:"splash,omitempty"`
  1365  	DiscoverySplash             string             `json:"discovery_splash,omitempty"`
  1366  	Banner                      string             `json:"banner,omitempty"`
  1367  	SystemChannelID             string             `json:"system_channel_id,omitempty"`
  1368  	SystemChannelFlags          SystemChannelFlag  `json:"system_channel_flags,omitempty"`
  1369  	RulesChannelID              string             `json:"rules_channel_id,omitempty"`
  1370  	PublicUpdatesChannelID      string             `json:"public_updates_channel_id,omitempty"`
  1371  	PreferredLocale             Locale             `json:"preferred_locale,omitempty"`
  1372  	Features                    []GuildFeature     `json:"features,omitempty"`
  1373  	Description                 string             `json:"description,omitempty"`
  1374  	PremiumProgressBarEnabled   *bool              `json:"premium_progress_bar_enabled,omitempty"`
  1375  }
  1376  
  1377  // A Role stores information about Discord guild member roles.
  1378  type Role struct {
  1379  	// The ID of the role.
  1380  	ID string `json:"id"`
  1381  
  1382  	// The name of the role.
  1383  	Name string `json:"name"`
  1384  
  1385  	// Whether this role is managed by an integration, and
  1386  	// thus cannot be manually added to, or taken from, members.
  1387  	Managed bool `json:"managed"`
  1388  
  1389  	// Whether this role is mentionable.
  1390  	Mentionable bool `json:"mentionable"`
  1391  
  1392  	// Whether this role is hoisted (shows up separately in member list).
  1393  	Hoist bool `json:"hoist"`
  1394  
  1395  	// The hex color of this role.
  1396  	Color int `json:"color"`
  1397  
  1398  	// The position of this role in the guild's role hierarchy.
  1399  	Position int `json:"position"`
  1400  
  1401  	// The permissions of the role on the guild (doesn't include channel overrides).
  1402  	// This is a combination of bit masks; the presence of a certain permission can
  1403  	// be checked by performing a bitwise AND between this int and the permission.
  1404  	Permissions int64 `json:"permissions,string"`
  1405  
  1406  	// The hash of the role icon. Use Role.IconURL to retrieve the icon's URL.
  1407  	Icon string `json:"icon"`
  1408  
  1409  	// The emoji assigned to this role.
  1410  	UnicodeEmoji string `json:"unicode_emoji"`
  1411  
  1412  	// The flags of the role, which describe its extra features.
  1413  	// This is a combination of bit masks; the presence of a certain flag can
  1414  	// be checked by performing a bitwise AND between this int and the flag.
  1415  	Flags RoleFlags `json:"flags"`
  1416  }
  1417  
  1418  // RoleFlags represent the flags of a Role.
  1419  // https://discord.com/developers/docs/topics/permissions#role-object-role-flags
  1420  type RoleFlags int
  1421  
  1422  // Block containing known RoleFlags values.
  1423  const (
  1424  	// RoleFlagInPrompt indicates whether the Role is selectable by members in an onboarding prompt.
  1425  	RoleFlagInPrompt RoleFlags = 1 << 0
  1426  )
  1427  
  1428  // Mention returns a string which mentions the role
  1429  func (r *Role) Mention() string {
  1430  	return fmt.Sprintf("<@&%s>", r.ID)
  1431  }
  1432  
  1433  // IconURL returns the URL of the role's icon.
  1434  //
  1435  //	size:    The size of the desired role icon as a power of two
  1436  //	         Image size can be any power of two between 16 and 4096.
  1437  func (r *Role) IconURL(size string) string {
  1438  	if r.Icon == "" {
  1439  		return ""
  1440  	}
  1441  
  1442  	URL := EndpointRoleIcon(r.ID, r.Icon)
  1443  
  1444  	if size != "" {
  1445  		return URL + "?size=" + size
  1446  	}
  1447  	return URL
  1448  }
  1449  
  1450  // RoleParams represents the parameters needed to create or update a Role
  1451  type RoleParams struct {
  1452  	// The role's name
  1453  	Name string `json:"name,omitempty"`
  1454  	// The color the role should have (as a decimal, not hex)
  1455  	Color *int `json:"color,omitempty"`
  1456  	// Whether to display the role's users separately
  1457  	Hoist *bool `json:"hoist,omitempty"`
  1458  	// The overall permissions number of the role
  1459  	Permissions *int64 `json:"permissions,omitempty,string"`
  1460  	// Whether this role is mentionable
  1461  	Mentionable *bool `json:"mentionable,omitempty"`
  1462  	// The role's unicode emoji.
  1463  	// NOTE: can only be set if the guild has the ROLE_ICONS feature.
  1464  	UnicodeEmoji *string `json:"unicode_emoji,omitempty"`
  1465  	// The role's icon image encoded in base64.
  1466  	// NOTE: can only be set if the guild has the ROLE_ICONS feature.
  1467  	Icon *string `json:"icon,omitempty"`
  1468  }
  1469  
  1470  // Roles are a collection of Role
  1471  type Roles []*Role
  1472  
  1473  func (r Roles) Len() int {
  1474  	return len(r)
  1475  }
  1476  
  1477  func (r Roles) Less(i, j int) bool {
  1478  	return r[i].Position > r[j].Position
  1479  }
  1480  
  1481  func (r Roles) Swap(i, j int) {
  1482  	r[i], r[j] = r[j], r[i]
  1483  }
  1484  
  1485  // A VoiceState stores the voice states of Guilds
  1486  type VoiceState struct {
  1487  	GuildID                 string     `json:"guild_id"`
  1488  	ChannelID               string     `json:"channel_id"`
  1489  	UserID                  string     `json:"user_id"`
  1490  	Member                  *Member    `json:"member"`
  1491  	SessionID               string     `json:"session_id"`
  1492  	Deaf                    bool       `json:"deaf"`
  1493  	Mute                    bool       `json:"mute"`
  1494  	SelfDeaf                bool       `json:"self_deaf"`
  1495  	SelfMute                bool       `json:"self_mute"`
  1496  	SelfStream              bool       `json:"self_stream"`
  1497  	SelfVideo               bool       `json:"self_video"`
  1498  	Suppress                bool       `json:"suppress"`
  1499  	RequestToSpeakTimestamp *time.Time `json:"request_to_speak_timestamp"`
  1500  }
  1501  
  1502  // A Presence stores the online, offline, or idle and game status of Guild members.
  1503  type Presence struct {
  1504  	User         *User        `json:"user"`
  1505  	Status       Status       `json:"status"`
  1506  	Activities   []*Activity  `json:"activities"`
  1507  	Since        *int         `json:"since"`
  1508  	ClientStatus ClientStatus `json:"client_status"`
  1509  }
  1510  
  1511  // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
  1512  type TimeStamps struct {
  1513  	EndTimestamp   int64 `json:"end,omitempty"`
  1514  	StartTimestamp int64 `json:"start,omitempty"`
  1515  }
  1516  
  1517  // UnmarshalJSON unmarshals JSON into TimeStamps struct
  1518  func (t *TimeStamps) UnmarshalJSON(b []byte) error {
  1519  	temp := struct {
  1520  		End   float64 `json:"end,omitempty"`
  1521  		Start float64 `json:"start,omitempty"`
  1522  	}{}
  1523  	err := Unmarshal(b, &temp)
  1524  	if err != nil {
  1525  		return err
  1526  	}
  1527  	t.EndTimestamp = int64(temp.End)
  1528  	t.StartTimestamp = int64(temp.Start)
  1529  	return nil
  1530  }
  1531  
  1532  // An Assets struct contains assets and labels used in the rich presence "playing .." Game
  1533  type Assets struct {
  1534  	LargeImageID string `json:"large_image,omitempty"`
  1535  	SmallImageID string `json:"small_image,omitempty"`
  1536  	LargeText    string `json:"large_text,omitempty"`
  1537  	SmallText    string `json:"small_text,omitempty"`
  1538  }
  1539  
  1540  // MemberFlags represent flags of a guild member.
  1541  // https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-flags
  1542  type MemberFlags int
  1543  
  1544  // Block containing known MemberFlags values.
  1545  const (
  1546  	// MemberFlagDidRejoin indicates whether the Member has left and rejoined the guild.
  1547  	MemberFlagDidRejoin MemberFlags = 1 << 0
  1548  	// MemberFlagCompletedOnboarding indicates whether the Member has completed onboarding.
  1549  	MemberFlagCompletedOnboarding MemberFlags = 1 << 1
  1550  	// MemberFlagBypassesVerification indicates whether the Member is exempt from guild verification requirements.
  1551  	MemberFlagBypassesVerification MemberFlags = 1 << 2
  1552  	// MemberFlagStartedOnboarding indicates whether the Member has started onboarding.
  1553  	MemberFlagStartedOnboarding MemberFlags = 1 << 3
  1554  )
  1555  
  1556  // A Member stores user information for Guild members. A guild
  1557  // member represents a certain user's presence in a guild.
  1558  type Member struct {
  1559  	// The guild ID on which the member exists.
  1560  	GuildID string `json:"guild_id"`
  1561  
  1562  	// The time at which the member joined the guild.
  1563  	JoinedAt time.Time `json:"joined_at"`
  1564  
  1565  	// The nickname of the member, if they have one.
  1566  	Nick string `json:"nick"`
  1567  
  1568  	// Whether the member is deafened at a guild level.
  1569  	Deaf bool `json:"deaf"`
  1570  
  1571  	// Whether the member is muted at a guild level.
  1572  	Mute bool `json:"mute"`
  1573  
  1574  	// The hash of the avatar for the guild member, if any.
  1575  	Avatar string `json:"avatar"`
  1576  
  1577  	// The hash of the banner for the guild member, if any.
  1578  	Banner string `json:"banner"`
  1579  
  1580  	// The underlying user on which the member is based.
  1581  	User *User `json:"user"`
  1582  
  1583  	// A list of IDs of the roles which are possessed by the member.
  1584  	Roles []string `json:"roles"`
  1585  
  1586  	// When the user used their Nitro boost on the server
  1587  	PremiumSince *time.Time `json:"premium_since"`
  1588  
  1589  	// The flags of this member. This is a combination of bit masks; the presence of a certain
  1590  	// flag can be checked by performing a bitwise AND between this int and the flag.
  1591  	Flags MemberFlags `json:"flags"`
  1592  
  1593  	// Is true while the member hasn't accepted the membership screen.
  1594  	Pending bool `json:"pending"`
  1595  
  1596  	// Total permissions of the member in the channel, including overrides, returned when in the interaction object.
  1597  	Permissions int64 `json:"permissions,string"`
  1598  
  1599  	// The time at which the member's timeout will expire.
  1600  	// Time in the past or nil if the user is not timed out.
  1601  	CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
  1602  }
  1603  
  1604  // Mention creates a member mention
  1605  func (m *Member) Mention() string {
  1606  	return "<@!" + m.User.ID + ">"
  1607  }
  1608  
  1609  // AvatarURL returns the URL of the member's avatar
  1610  //
  1611  //	size:    The size of the user's avatar as a power of two
  1612  //	         if size is an empty string, no size parameter will
  1613  //	         be added to the URL.
  1614  func (m *Member) AvatarURL(size string) string {
  1615  	if m.Avatar == "" {
  1616  		return m.User.AvatarURL(size)
  1617  	}
  1618  	// The default/empty avatar case should be handled by the above condition
  1619  	return avatarURL(m.Avatar, "", EndpointGuildMemberAvatar(m.GuildID, m.User.ID, m.Avatar),
  1620  		EndpointGuildMemberAvatarAnimated(m.GuildID, m.User.ID, m.Avatar), size)
  1621  
  1622  }
  1623  
  1624  // BannerURL returns the URL of the member's banner image.
  1625  //
  1626  //	size:    The size of the desired banner image as a power of two
  1627  //	         Image size can be any power of two between 16 and 4096.
  1628  func (m *Member) BannerURL(size string) string {
  1629  	if m.Banner == "" {
  1630  		return m.User.BannerURL(size)
  1631  	}
  1632  	return bannerURL(
  1633  		m.Banner,
  1634  		EndpointGuildMemberBanner(m.GuildID, m.User.ID, m.Banner),
  1635  		EndpointGuildMemberBannerAnimated(m.GuildID, m.User.ID, m.Banner),
  1636  		size,
  1637  	)
  1638  }
  1639  
  1640  // DisplayName returns the member's guild nickname if they have one,
  1641  // otherwise it returns their discord display name.
  1642  func (m *Member) DisplayName() string {
  1643  	if m.Nick != "" {
  1644  		return m.Nick
  1645  	}
  1646  	return m.User.DisplayName()
  1647  }
  1648  
  1649  // ClientStatus stores the online, offline, idle, or dnd status of each device of a Guild member.
  1650  type ClientStatus struct {
  1651  	Desktop Status `json:"desktop"`
  1652  	Mobile  Status `json:"mobile"`
  1653  	Web     Status `json:"web"`
  1654  }
  1655  
  1656  // Status type definition
  1657  type Status string
  1658  
  1659  // Constants for Status with the different current available status
  1660  const (
  1661  	StatusOnline       Status = "online"
  1662  	StatusIdle         Status = "idle"
  1663  	StatusDoNotDisturb Status = "dnd"
  1664  	StatusInvisible    Status = "invisible"
  1665  	StatusOffline      Status = "offline"
  1666  )
  1667  
  1668  // A TooManyRequests struct holds information received from Discord
  1669  // when receiving a HTTP 429 response.
  1670  type TooManyRequests struct {
  1671  	Bucket     string        `json:"bucket"`
  1672  	Message    string        `json:"message"`
  1673  	RetryAfter time.Duration `json:"retry_after"`
  1674  }
  1675  
  1676  // UnmarshalJSON helps support translation of a milliseconds-based float
  1677  // into a time.Duration on TooManyRequests.
  1678  func (t *TooManyRequests) UnmarshalJSON(b []byte) error {
  1679  	u := struct {
  1680  		Bucket     string  `json:"bucket"`
  1681  		Message    string  `json:"message"`
  1682  		RetryAfter float64 `json:"retry_after"`
  1683  	}{}
  1684  	err := Unmarshal(b, &u)
  1685  	if err != nil {
  1686  		return err
  1687  	}
  1688  
  1689  	t.Bucket = u.Bucket
  1690  	t.Message = u.Message
  1691  	whole, frac := math.Modf(u.RetryAfter)
  1692  	t.RetryAfter = time.Duration(whole)*time.Second + time.Duration(frac*1000)*time.Millisecond
  1693  	return nil
  1694  }
  1695  
  1696  // A ReadState stores data on the read state of channels.
  1697  type ReadState struct {
  1698  	MentionCount  int    `json:"mention_count"`
  1699  	LastMessageID string `json:"last_message_id"`
  1700  	ID            string `json:"id"`
  1701  }
  1702  
  1703  // A GuildRole stores data for guild roles.
  1704  type GuildRole struct {
  1705  	Role    *Role  `json:"role"`
  1706  	GuildID string `json:"guild_id"`
  1707  }
  1708  
  1709  // A GuildBan stores data for a guild ban.
  1710  type GuildBan struct {
  1711  	Reason string `json:"reason"`
  1712  	User   *User  `json:"user"`
  1713  }
  1714  
  1715  // AutoModerationRule stores data for an auto moderation rule.
  1716  type AutoModerationRule struct {
  1717  	ID              string                         `json:"id,omitempty"`
  1718  	GuildID         string                         `json:"guild_id,omitempty"`
  1719  	Name            string                         `json:"name,omitempty"`
  1720  	CreatorID       string                         `json:"creator_id,omitempty"`
  1721  	EventType       AutoModerationRuleEventType    `json:"event_type,omitempty"`
  1722  	TriggerType     AutoModerationRuleTriggerType  `json:"trigger_type,omitempty"`
  1723  	TriggerMetadata *AutoModerationTriggerMetadata `json:"trigger_metadata,omitempty"`
  1724  	Actions         []AutoModerationAction         `json:"actions,omitempty"`
  1725  	Enabled         *bool                          `json:"enabled,omitempty"`
  1726  	ExemptRoles     *[]string                      `json:"exempt_roles,omitempty"`
  1727  	ExemptChannels  *[]string                      `json:"exempt_channels,omitempty"`
  1728  }
  1729  
  1730  // AutoModerationRuleEventType indicates in what event context a rule should be checked.
  1731  type AutoModerationRuleEventType int
  1732  
  1733  // Auto moderation rule event types.
  1734  const (
  1735  	// AutoModerationEventMessageSend is checked when a member sends or edits a message in the guild
  1736  	AutoModerationEventMessageSend AutoModerationRuleEventType = 1
  1737  )
  1738  
  1739  // AutoModerationRuleTriggerType represents the type of content which can trigger the rule.
  1740  type AutoModerationRuleTriggerType int
  1741  
  1742  // Auto moderation rule trigger types.
  1743  const (
  1744  	AutoModerationEventTriggerKeyword       AutoModerationRuleTriggerType = 1
  1745  	AutoModerationEventTriggerHarmfulLink   AutoModerationRuleTriggerType = 2
  1746  	AutoModerationEventTriggerSpam          AutoModerationRuleTriggerType = 3
  1747  	AutoModerationEventTriggerKeywordPreset AutoModerationRuleTriggerType = 4
  1748  )
  1749  
  1750  // AutoModerationKeywordPreset represents an internally pre-defined wordset.
  1751  type AutoModerationKeywordPreset uint
  1752  
  1753  // Auto moderation keyword presets.
  1754  const (
  1755  	AutoModerationKeywordPresetProfanity     AutoModerationKeywordPreset = 1
  1756  	AutoModerationKeywordPresetSexualContent AutoModerationKeywordPreset = 2
  1757  	AutoModerationKeywordPresetSlurs         AutoModerationKeywordPreset = 3
  1758  )
  1759  
  1760  // AutoModerationTriggerMetadata represents additional metadata used to determine whether rule should be triggered.
  1761  type AutoModerationTriggerMetadata struct {
  1762  	// Substrings which will be searched for in content.
  1763  	// NOTE: should be only used with keyword trigger type.
  1764  	KeywordFilter []string `json:"keyword_filter,omitempty"`
  1765  	// Regular expression patterns which will be matched against content (maximum of 10).
  1766  	// NOTE: should be only used with keyword trigger type.
  1767  	RegexPatterns []string `json:"regex_patterns,omitempty"`
  1768  
  1769  	// Internally pre-defined wordsets which will be searched for in content.
  1770  	// NOTE: should be only used with keyword preset trigger type.
  1771  	Presets []AutoModerationKeywordPreset `json:"presets,omitempty"`
  1772  
  1773  	// Substrings which should not trigger the rule.
  1774  	// NOTE: should be only used with keyword or keyword preset trigger type.
  1775  	AllowList *[]string `json:"allow_list,omitempty"`
  1776  
  1777  	// Total number of unique role and user mentions allowed per message.
  1778  	// NOTE: should be only used with mention spam trigger type.
  1779  	MentionTotalLimit int `json:"mention_total_limit,omitempty"`
  1780  }
  1781  
  1782  // AutoModerationActionType represents an action which will execute whenever a rule is triggered.
  1783  type AutoModerationActionType int
  1784  
  1785  // Auto moderation actions types.
  1786  const (
  1787  	AutoModerationRuleActionBlockMessage     AutoModerationActionType = 1
  1788  	AutoModerationRuleActionSendAlertMessage AutoModerationActionType = 2
  1789  	AutoModerationRuleActionTimeout          AutoModerationActionType = 3
  1790  )
  1791  
  1792  // AutoModerationActionMetadata represents additional metadata needed during execution for a specific action type.
  1793  type AutoModerationActionMetadata struct {
  1794  	// Channel to which user content should be logged.
  1795  	// NOTE: should be only used with send alert message action type.
  1796  	ChannelID string `json:"channel_id,omitempty"`
  1797  
  1798  	// Timeout duration in seconds (maximum of 2419200 - 4 weeks).
  1799  	// NOTE: should be only used with timeout action type.
  1800  	Duration int `json:"duration_seconds,omitempty"`
  1801  
  1802  	// Additional explanation that will be shown to members whenever their message is blocked (maximum of 150 characters).
  1803  	// NOTE: should be only used with block message action type.
  1804  	CustomMessage string `json:"custom_message,omitempty"`
  1805  }
  1806  
  1807  // AutoModerationAction stores data for an auto moderation action.
  1808  type AutoModerationAction struct {
  1809  	Type     AutoModerationActionType      `json:"type"`
  1810  	Metadata *AutoModerationActionMetadata `json:"metadata,omitempty"`
  1811  }
  1812  
  1813  // A GuildEmbed stores data for a guild embed.
  1814  type GuildEmbed struct {
  1815  	Enabled   *bool  `json:"enabled,omitempty"`
  1816  	ChannelID string `json:"channel_id,omitempty"`
  1817  }
  1818  
  1819  // A GuildAuditLog stores data for a guild audit log.
  1820  // https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
  1821  type GuildAuditLog struct {
  1822  	Webhooks        []*Webhook       `json:"webhooks,omitempty"`
  1823  	Users           []*User          `json:"users,omitempty"`
  1824  	AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"`
  1825  	Integrations    []*Integration   `json:"integrations"`
  1826  }
  1827  
  1828  // AuditLogEntry for a GuildAuditLog
  1829  // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure
  1830  type AuditLogEntry struct {
  1831  	TargetID   string            `json:"target_id"`
  1832  	Changes    []*AuditLogChange `json:"changes"`
  1833  	UserID     string            `json:"user_id"`
  1834  	ID         string            `json:"id"`
  1835  	ActionType *AuditLogAction   `json:"action_type"`
  1836  	Options    *AuditLogOptions  `json:"options"`
  1837  	Reason     string            `json:"reason"`
  1838  }
  1839  
  1840  // AuditLogChange for an AuditLogEntry
  1841  type AuditLogChange struct {
  1842  	NewValue interface{}        `json:"new_value"`
  1843  	OldValue interface{}        `json:"old_value"`
  1844  	Key      *AuditLogChangeKey `json:"key"`
  1845  }
  1846  
  1847  // AuditLogChangeKey value for AuditLogChange
  1848  // https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key
  1849  type AuditLogChangeKey string
  1850  
  1851  // Block of valid AuditLogChangeKey
  1852  const (
  1853  	// AuditLogChangeKeyAfkChannelID is sent when afk channel changed (snowflake) - guild
  1854  	AuditLogChangeKeyAfkChannelID AuditLogChangeKey = "afk_channel_id"
  1855  	// AuditLogChangeKeyAfkTimeout is sent when afk timeout duration changed (int) - guild
  1856  	AuditLogChangeKeyAfkTimeout AuditLogChangeKey = "afk_timeout"
  1857  	// AuditLogChangeKeyAllow is sent when a permission on a text or voice channel was allowed for a role (string) - role
  1858  	AuditLogChangeKeyAllow AuditLogChangeKey = "allow"
  1859  	// AudirChangeKeyApplicationID is sent when application id of the added or removed webhook or bot (snowflake) - channel
  1860  	AuditLogChangeKeyApplicationID AuditLogChangeKey = "application_id"
  1861  	// AuditLogChangeKeyArchived is sent when thread was archived/unarchived (bool) - thread
  1862  	AuditLogChangeKeyArchived AuditLogChangeKey = "archived"
  1863  	// AuditLogChangeKeyAsset is sent when asset is changed (string) - sticker
  1864  	AuditLogChangeKeyAsset AuditLogChangeKey = "asset"
  1865  	// AuditLogChangeKeyAutoArchiveDuration is sent when auto archive duration changed (int) - thread
  1866  	AuditLogChangeKeyAutoArchiveDuration AuditLogChangeKey = "auto_archive_duration"
  1867  	// AuditLogChangeKeyAvailable is sent when availability of sticker changed (bool) - sticker
  1868  	AuditLogChangeKeyAvailable AuditLogChangeKey = "available"
  1869  	// AuditLogChangeKeyAvatarHash is sent when user avatar changed (string) - user
  1870  	AuditLogChangeKeyAvatarHash AuditLogChangeKey = "avatar_hash"
  1871  	// AuditLogChangeKeyBannerHash is sent when guild banner changed (string) - guild
  1872  	AuditLogChangeKeyBannerHash AuditLogChangeKey = "banner_hash"
  1873  	// AuditLogChangeKeyBitrate is sent when voice channel bitrate changed (int) - channel
  1874  	AuditLogChangeKeyBitrate AuditLogChangeKey = "bitrate"
  1875  	// AuditLogChangeKeyChannelID is sent when channel for invite code or guild scheduled event changed (snowflake) - invite or guild scheduled event
  1876  	AuditLogChangeKeyChannelID AuditLogChangeKey = "channel_id"
  1877  	// AuditLogChangeKeyCode is sent when invite code changed (string) - invite
  1878  	AuditLogChangeKeyCode AuditLogChangeKey = "code"
  1879  	// AuditLogChangeKeyColor is sent when role color changed (int) - role
  1880  	AuditLogChangeKeyColor AuditLogChangeKey = "color"
  1881  	// AuditLogChangeKeyCommunicationDisabledUntil is sent when member timeout state changed (ISO8601 timestamp) - member
  1882  	AuditLogChangeKeyCommunicationDisabledUntil AuditLogChangeKey = "communication_disabled_until"
  1883  	// AuditLogChangeKeyDeaf is sent when user server deafened/undeafened (bool) - member
  1884  	AuditLogChangeKeyDeaf AuditLogChangeKey = "deaf"
  1885  	// AuditLogChangeKeyDefaultAutoArchiveDuration is sent when default auto archive duration for newly created threads changed (int) - channel
  1886  	AuditLogChangeKeyDefaultAutoArchiveDuration AuditLogChangeKey = "default_auto_archive_duration"
  1887  	// AuditLogChangeKeyDefaultMessageNotification is sent when default message notification level changed (int) - guild
  1888  	AuditLogChangeKeyDefaultMessageNotification AuditLogChangeKey = "default_message_notifications"
  1889  	// AuditLogChangeKeyDeny is sent when a permission on a text or voice channel was denied for a role (string) - role
  1890  	AuditLogChangeKeyDeny AuditLogChangeKey = "deny"
  1891  	// AuditLogChangeKeyDescription is sent when description changed (string) - guild, sticker, or guild scheduled event
  1892  	AuditLogChangeKeyDescription AuditLogChangeKey = "description"
  1893  	// AuditLogChangeKeyDiscoverySplashHash is sent when discovery splash changed (string) - guild
  1894  	AuditLogChangeKeyDiscoverySplashHash AuditLogChangeKey = "discovery_splash_hash"
  1895  	// AuditLogChangeKeyEnableEmoticons is sent when integration emoticons enabled/disabled (bool) - integration
  1896  	AuditLogChangeKeyEnableEmoticons AuditLogChangeKey = "enable_emoticons"
  1897  	// AuditLogChangeKeyEntityType is sent when entity type of guild scheduled event was changed (int) - guild scheduled event
  1898  	AuditLogChangeKeyEntityType AuditLogChangeKey = "entity_type"
  1899  	// AuditLogChangeKeyExpireBehavior is sent when integration expiring subscriber behavior changed (int) - integration
  1900  	AuditLogChangeKeyExpireBehavior AuditLogChangeKey = "expire_behavior"
  1901  	// AuditLogChangeKeyExpireGracePeriod is sent when integration expire grace period changed (int) - integration
  1902  	AuditLogChangeKeyExpireGracePeriod AuditLogChangeKey = "expire_grace_period"
  1903  	// AuditLogChangeKeyExplicitContentFilter is sent when change in whose messages are scanned and deleted for explicit content in the server is made (int) - guild
  1904  	AuditLogChangeKeyExplicitContentFilter AuditLogChangeKey = "explicit_content_filter"
  1905  	// AuditLogChangeKeyFormatType is sent when format type of sticker changed (int - sticker format type) - sticker
  1906  	AuditLogChangeKeyFormatType AuditLogChangeKey = "format_type"
  1907  	// AuditLogChangeKeyGuildID is sent when guild sticker is in changed (snowflake) - sticker
  1908  	AuditLogChangeKeyGuildID AuditLogChangeKey = "guild_id"
  1909  	// AuditLogChangeKeyHoist is sent when role is now displayed/no longer displayed separate from online users (bool) - role
  1910  	AuditLogChangeKeyHoist AuditLogChangeKey = "hoist"
  1911  	// AuditLogChangeKeyIconHash is sent when icon changed (string) - guild or role
  1912  	AuditLogChangeKeyIconHash AuditLogChangeKey = "icon_hash"
  1913  	// AuditLogChangeKeyID is sent when the id of the changed entity - sometimes used in conjunction with other keys (snowflake) - any
  1914  	AuditLogChangeKeyID AuditLogChangeKey = "id"
  1915  	// AuditLogChangeKeyInvitable is sent when private thread is now invitable/uninvitable (bool) - thread
  1916  	AuditLogChangeKeyInvitable AuditLogChangeKey = "invitable"
  1917  	// AuditLogChangeKeyInviterID is sent when person who created invite code changed (snowflake) - invite
  1918  	AuditLogChangeKeyInviterID AuditLogChangeKey = "inviter_id"
  1919  	// AuditLogChangeKeyLocation is sent when channel id for guild scheduled event changed (string) - guild scheduled event
  1920  	AuditLogChangeKeyLocation AuditLogChangeKey = "location"
  1921  	// AuditLogChangeKeyLocked is sent when thread was locked/unlocked (bool) - thread
  1922  	AuditLogChangeKeyLocked AuditLogChangeKey = "locked"
  1923  	// AuditLogChangeKeyMaxAge is sent when invite code expiration time changed (int) - invite
  1924  	AuditLogChangeKeyMaxAge AuditLogChangeKey = "max_age"
  1925  	// AuditLogChangeKeyMaxUses is sent when max number of times invite code can be used changed (int) - invite
  1926  	AuditLogChangeKeyMaxUses AuditLogChangeKey = "max_uses"
  1927  	// AuditLogChangeKeyMentionable is sent when role is now mentionable/unmentionable (bool) - role
  1928  	AuditLogChangeKeyMentionable AuditLogChangeKey = "mentionable"
  1929  	// AuditLogChangeKeyMfaLevel is sent when two-factor auth requirement changed (int - mfa level) - guild
  1930  	AuditLogChangeKeyMfaLevel AuditLogChangeKey = "mfa_level"
  1931  	// AuditLogChangeKeyMute is sent when user server muted/unmuted (bool) - member
  1932  	AuditLogChangeKeyMute AuditLogChangeKey = "mute"
  1933  	// AuditLogChangeKeyName is sent when name changed (string) - any
  1934  	AuditLogChangeKeyName AuditLogChangeKey = "name"
  1935  	// AuditLogChangeKeyNick is sent when user nickname changed (string) - member
  1936  	AuditLogChangeKeyNick AuditLogChangeKey = "nick"
  1937  	// AuditLogChangeKeyNSFW is sent when channel nsfw restriction changed (bool) - channel
  1938  	AuditLogChangeKeyNSFW AuditLogChangeKey = "nsfw"
  1939  	// AuditLogChangeKeyOwnerID is sent when owner changed (snowflake) - guild
  1940  	AuditLogChangeKeyOwnerID AuditLogChangeKey = "owner_id"
  1941  	// AuditLogChangeKeyPermissionOverwrite is sent when permissions on a channel changed (array of channel overwrite objects) - channel
  1942  	AuditLogChangeKeyPermissionOverwrite AuditLogChangeKey = "permission_overwrites"
  1943  	// AuditLogChangeKeyPermissions is sent when permissions for a role changed (string) - role
  1944  	AuditLogChangeKeyPermissions AuditLogChangeKey = "permissions"
  1945  	// AuditLogChangeKeyPosition is sent when text or voice channel position changed (int) - channel
  1946  	AuditLogChangeKeyPosition AuditLogChangeKey = "position"
  1947  	// AuditLogChangeKeyPreferredLocale is sent when preferred locale changed (string) - guild
  1948  	AuditLogChangeKeyPreferredLocale AuditLogChangeKey = "preferred_locale"
  1949  	// AuditLogChangeKeyPrivacylevel is sent when privacy level of the stage instance changed (integer - privacy level) - stage instance or guild scheduled event
  1950  	AuditLogChangeKeyPrivacylevel AuditLogChangeKey = "privacy_level"
  1951  	// AuditLogChangeKeyPruneDeleteDays is sent when number of days after which inactive and role-unassigned members are kicked changed (int) - guild
  1952  	AuditLogChangeKeyPruneDeleteDays AuditLogChangeKey = "prune_delete_days"
  1953  	// AuditLogChangeKeyPublicUpdatesChannelID is sent when id of the public updates channel changed (snowflake) - guild
  1954  	AuditLogChangeKeyPublicUpdatesChannelID AuditLogChangeKey = "public_updates_channel_id"
  1955  	// AuditLogChangeKeyRateLimitPerUser is sent when amount of seconds a user has to wait before sending another message changed (int) - channel
  1956  	AuditLogChangeKeyRateLimitPerUser AuditLogChangeKey = "rate_limit_per_user"
  1957  	// AuditLogChangeKeyRegion is sent when region changed (string) - guild
  1958  	AuditLogChangeKeyRegion AuditLogChangeKey = "region"
  1959  	// AuditLogChangeKeyRulesChannelID is sent when id of the rules channel changed (snowflake) - guild
  1960  	AuditLogChangeKeyRulesChannelID AuditLogChangeKey = "rules_channel_id"
  1961  	// AuditLogChangeKeySplashHash is sent when invite splash page artwork changed (string) - guild
  1962  	AuditLogChangeKeySplashHash AuditLogChangeKey = "splash_hash"
  1963  	// AuditLogChangeKeyStatus is sent when status of guild scheduled event was changed (int - guild scheduled event status) - guild scheduled event
  1964  	AuditLogChangeKeyStatus AuditLogChangeKey = "status"
  1965  	// AuditLogChangeKeySystemChannelID is sent when id of the system channel changed (snowflake) - guild
  1966  	AuditLogChangeKeySystemChannelID AuditLogChangeKey = "system_channel_id"
  1967  	// AuditLogChangeKeyTags is sent when related emoji of sticker changed (string) - sticker
  1968  	AuditLogChangeKeyTags AuditLogChangeKey = "tags"
  1969  	// AuditLogChangeKeyTemporary is sent when invite code is now temporary or never expires (bool) - invite
  1970  	AuditLogChangeKeyTemporary AuditLogChangeKey = "temporary"
  1971  	// TODO: remove when compatibility is not required
  1972  	AuditLogChangeKeyTempoary = AuditLogChangeKeyTemporary
  1973  	// AuditLogChangeKeyTopic is sent when text channel topic or stage instance topic changed (string) - channel or stage instance
  1974  	AuditLogChangeKeyTopic AuditLogChangeKey = "topic"
  1975  	// AuditLogChangeKeyType is sent when type of entity created (int or string) - any
  1976  	AuditLogChangeKeyType AuditLogChangeKey = "type"
  1977  	// AuditLogChangeKeyUnicodeEmoji is sent when role unicode emoji changed (string) - role
  1978  	AuditLogChangeKeyUnicodeEmoji AuditLogChangeKey = "unicode_emoji"
  1979  	// AuditLogChangeKeyUserLimit is sent when new user limit in a voice channel set (int) - voice channel
  1980  	AuditLogChangeKeyUserLimit AuditLogChangeKey = "user_limit"
  1981  	// AuditLogChangeKeyUses is sent when number of times invite code used changed (int) - invite
  1982  	AuditLogChangeKeyUses AuditLogChangeKey = "uses"
  1983  	// AuditLogChangeKeyVanityURLCode is sent when guild invite vanity url changed (string) - guild
  1984  	AuditLogChangeKeyVanityURLCode AuditLogChangeKey = "vanity_url_code"
  1985  	// AuditLogChangeKeyVerificationLevel is sent when required verification level changed (int - verification level) - guild
  1986  	AuditLogChangeKeyVerificationLevel AuditLogChangeKey = "verification_level"
  1987  	// AuditLogChangeKeyWidgetChannelID is sent when channel id of the server widget changed (snowflake) - guild
  1988  	AuditLogChangeKeyWidgetChannelID AuditLogChangeKey = "widget_channel_id"
  1989  	// AuditLogChangeKeyWidgetEnabled is sent when server widget enabled/disabled (bool) - guild
  1990  	AuditLogChangeKeyWidgetEnabled AuditLogChangeKey = "widget_enabled"
  1991  	// AuditLogChangeKeyRoleAdd is sent when new role added (array of partial role objects) - guild
  1992  	AuditLogChangeKeyRoleAdd AuditLogChangeKey = "$add"
  1993  	// AuditLogChangeKeyRoleRemove is sent when role removed (array of partial role objects) - guild
  1994  	AuditLogChangeKeyRoleRemove AuditLogChangeKey = "$remove"
  1995  )
  1996  
  1997  // AuditLogOptions optional data for the AuditLog
  1998  // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
  1999  type AuditLogOptions struct {
  2000  	DeleteMemberDays              string               `json:"delete_member_days"`
  2001  	MembersRemoved                string               `json:"members_removed"`
  2002  	ChannelID                     string               `json:"channel_id"`
  2003  	MessageID                     string               `json:"message_id"`
  2004  	Count                         string               `json:"count"`
  2005  	ID                            string               `json:"id"`
  2006  	Type                          *AuditLogOptionsType `json:"type"`
  2007  	RoleName                      string               `json:"role_name"`
  2008  	ApplicationID                 string               `json:"application_id"`
  2009  	AutoModerationRuleName        string               `json:"auto_moderation_rule_name"`
  2010  	AutoModerationRuleTriggerType string               `json:"auto_moderation_rule_trigger_type"`
  2011  	IntegrationType               string               `json:"integration_type"`
  2012  }
  2013  
  2014  // AuditLogOptionsType of the AuditLogOption
  2015  // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
  2016  type AuditLogOptionsType string
  2017  
  2018  // Valid Types for AuditLogOptionsType
  2019  const (
  2020  	AuditLogOptionsTypeRole   AuditLogOptionsType = "0"
  2021  	AuditLogOptionsTypeMember AuditLogOptionsType = "1"
  2022  )
  2023  
  2024  // AuditLogAction is the Action of the AuditLog (see AuditLogAction* consts)
  2025  // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
  2026  type AuditLogAction int
  2027  
  2028  // Block contains Discord Audit Log Action Types
  2029  const (
  2030  	AuditLogActionGuildUpdate AuditLogAction = 1
  2031  
  2032  	AuditLogActionChannelCreate          AuditLogAction = 10
  2033  	AuditLogActionChannelUpdate          AuditLogAction = 11
  2034  	AuditLogActionChannelDelete          AuditLogAction = 12
  2035  	AuditLogActionChannelOverwriteCreate AuditLogAction = 13
  2036  	AuditLogActionChannelOverwriteUpdate AuditLogAction = 14
  2037  	AuditLogActionChannelOverwriteDelete AuditLogAction = 15
  2038  
  2039  	AuditLogActionMemberKick       AuditLogAction = 20
  2040  	AuditLogActionMemberPrune      AuditLogAction = 21
  2041  	AuditLogActionMemberBanAdd     AuditLogAction = 22
  2042  	AuditLogActionMemberBanRemove  AuditLogAction = 23
  2043  	AuditLogActionMemberUpdate     AuditLogAction = 24
  2044  	AuditLogActionMemberRoleUpdate AuditLogAction = 25
  2045  	AuditLogActionMemberMove       AuditLogAction = 26
  2046  	AuditLogActionMemberDisconnect AuditLogAction = 27
  2047  	AuditLogActionBotAdd           AuditLogAction = 28
  2048  
  2049  	AuditLogActionRoleCreate AuditLogAction = 30
  2050  	AuditLogActionRoleUpdate AuditLogAction = 31
  2051  	AuditLogActionRoleDelete AuditLogAction = 32
  2052  
  2053  	AuditLogActionInviteCreate AuditLogAction = 40
  2054  	AuditLogActionInviteUpdate AuditLogAction = 41
  2055  	AuditLogActionInviteDelete AuditLogAction = 42
  2056  
  2057  	AuditLogActionWebhookCreate AuditLogAction = 50
  2058  	AuditLogActionWebhookUpdate AuditLogAction = 51
  2059  	AuditLogActionWebhookDelete AuditLogAction = 52
  2060  
  2061  	AuditLogActionEmojiCreate AuditLogAction = 60
  2062  	AuditLogActionEmojiUpdate AuditLogAction = 61
  2063  	AuditLogActionEmojiDelete AuditLogAction = 62
  2064  
  2065  	AuditLogActionMessageDelete     AuditLogAction = 72
  2066  	AuditLogActionMessageBulkDelete AuditLogAction = 73
  2067  	AuditLogActionMessagePin        AuditLogAction = 74
  2068  	AuditLogActionMessageUnpin      AuditLogAction = 75
  2069  
  2070  	AuditLogActionIntegrationCreate   AuditLogAction = 80
  2071  	AuditLogActionIntegrationUpdate   AuditLogAction = 81
  2072  	AuditLogActionIntegrationDelete   AuditLogAction = 82
  2073  	AuditLogActionStageInstanceCreate AuditLogAction = 83
  2074  	AuditLogActionStageInstanceUpdate AuditLogAction = 84
  2075  	AuditLogActionStageInstanceDelete AuditLogAction = 85
  2076  
  2077  	AuditLogActionStickerCreate AuditLogAction = 90
  2078  	AuditLogActionStickerUpdate AuditLogAction = 91
  2079  	AuditLogActionStickerDelete AuditLogAction = 92
  2080  
  2081  	AuditLogGuildScheduledEventCreate AuditLogAction = 100
  2082  	AuditLogGuildScheduledEventUpdate AuditLogAction = 101
  2083  	AuditLogGuildScheduledEventDelete AuditLogAction = 102
  2084  
  2085  	AuditLogActionThreadCreate AuditLogAction = 110
  2086  	AuditLogActionThreadUpdate AuditLogAction = 111
  2087  	AuditLogActionThreadDelete AuditLogAction = 112
  2088  
  2089  	AuditLogActionApplicationCommandPermissionUpdate AuditLogAction = 121
  2090  
  2091  	AuditLogActionAutoModerationRuleCreate                AuditLogAction = 140
  2092  	AuditLogActionAutoModerationRuleUpdate                AuditLogAction = 141
  2093  	AuditLogActionAutoModerationRuleDelete                AuditLogAction = 142
  2094  	AuditLogActionAutoModerationBlockMessage              AuditLogAction = 143
  2095  	AuditLogActionAutoModerationFlagToChannel             AuditLogAction = 144
  2096  	AuditLogActionAutoModerationUserCommunicationDisabled AuditLogAction = 145
  2097  
  2098  	AuditLogActionCreatorMonetizationRequestCreated AuditLogAction = 150
  2099  	AuditLogActionCreatorMonetizationTermsAccepted  AuditLogAction = 151
  2100  
  2101  	AuditLogActionOnboardingPromptCreate AuditLogAction = 163
  2102  	AuditLogActionOnboardingPromptUpdate AuditLogAction = 164
  2103  	AuditLogActionOnboardingPromptDelete AuditLogAction = 165
  2104  	AuditLogActionOnboardingCreate       AuditLogAction = 166
  2105  	AuditLogActionOnboardingUpdate       AuditLogAction = 167
  2106  
  2107  	AuditLogActionHomeSettingsCreate = 190
  2108  	AuditLogActionHomeSettingsUpdate = 191
  2109  )
  2110  
  2111  // GuildMemberParams stores data needed to update a member
  2112  // https://discord.com/developers/docs/resources/guild#modify-guild-member
  2113  type GuildMemberParams struct {
  2114  	// Value to set user's nickname to.
  2115  	Nick string `json:"nick,omitempty"`
  2116  	// Array of role ids the member is assigned.
  2117  	Roles *[]string `json:"roles,omitempty"`
  2118  	// ID of channel to move user to (if they are connected to voice).
  2119  	// Set to "" to remove user from a voice channel.
  2120  	ChannelID *string `json:"channel_id,omitempty"`
  2121  	// Whether the user is muted in voice channels.
  2122  	Mute *bool `json:"mute,omitempty"`
  2123  	// Whether the user is deafened in voice channels.
  2124  	Deaf *bool `json:"deaf,omitempty"`
  2125  	// When the user's timeout will expire and the user will be able
  2126  	// to communicate in the guild again (up to 28 days in the future).
  2127  	// Set to time.Time{} to remove timeout.
  2128  	CommunicationDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"`
  2129  }
  2130  
  2131  // MarshalJSON is a helper function to marshal GuildMemberParams.
  2132  func (p GuildMemberParams) MarshalJSON() (res []byte, err error) {
  2133  	type guildMemberParams GuildMemberParams
  2134  	v := struct {
  2135  		guildMemberParams
  2136  		ChannelID                  json.RawMessage `json:"channel_id,omitempty"`
  2137  		CommunicationDisabledUntil json.RawMessage `json:"communication_disabled_until,omitempty"`
  2138  	}{guildMemberParams: guildMemberParams(p)}
  2139  
  2140  	if p.ChannelID != nil {
  2141  		if *p.ChannelID == "" {
  2142  			v.ChannelID = json.RawMessage(`null`)
  2143  		} else {
  2144  			res, err = json.Marshal(p.ChannelID)
  2145  			if err != nil {
  2146  				return
  2147  			}
  2148  			v.ChannelID = res
  2149  		}
  2150  	}
  2151  
  2152  	if p.CommunicationDisabledUntil != nil {
  2153  		if p.CommunicationDisabledUntil.IsZero() {
  2154  			v.CommunicationDisabledUntil = json.RawMessage(`null`)
  2155  		} else {
  2156  			res, err = json.Marshal(p.CommunicationDisabledUntil)
  2157  			if err != nil {
  2158  				return
  2159  			}
  2160  			v.CommunicationDisabledUntil = res
  2161  		}
  2162  	}
  2163  
  2164  	return json.Marshal(v)
  2165  }
  2166  
  2167  // GuildMemberAddParams stores data needed to add a user to a guild.
  2168  // NOTE: All fields are optional, except AccessToken.
  2169  type GuildMemberAddParams struct {
  2170  	// Valid access_token for the user.
  2171  	AccessToken string `json:"access_token"`
  2172  	// Value to set users nickname to.
  2173  	Nick string `json:"nick,omitempty"`
  2174  	// A list of role ID's to set on the member.
  2175  	Roles []string `json:"roles,omitempty"`
  2176  	// Whether the user is muted.
  2177  	Mute bool `json:"mute,omitempty"`
  2178  	// Whether the user is deafened.
  2179  	Deaf bool `json:"deaf,omitempty"`
  2180  }
  2181  
  2182  // An APIErrorMessage is an api error message returned from discord
  2183  type APIErrorMessage struct {
  2184  	Code    int    `json:"code"`
  2185  	Message string `json:"message"`
  2186  }
  2187  
  2188  // MessageReaction stores the data for a message reaction.
  2189  type MessageReaction struct {
  2190  	UserID    string `json:"user_id"`
  2191  	MessageID string `json:"message_id"`
  2192  	Emoji     Emoji  `json:"emoji"`
  2193  	ChannelID string `json:"channel_id"`
  2194  	GuildID   string `json:"guild_id,omitempty"`
  2195  }
  2196  
  2197  // GatewayBotResponse stores the data for the gateway/bot response
  2198  type GatewayBotResponse struct {
  2199  	URL               string             `json:"url"`
  2200  	Shards            int                `json:"shards"`
  2201  	SessionStartLimit SessionInformation `json:"session_start_limit"`
  2202  }
  2203  
  2204  // SessionInformation provides the information for max concurrency sharding
  2205  type SessionInformation struct {
  2206  	Total          int `json:"total,omitempty"`
  2207  	Remaining      int `json:"remaining,omitempty"`
  2208  	ResetAfter     int `json:"reset_after,omitempty"`
  2209  	MaxConcurrency int `json:"max_concurrency,omitempty"`
  2210  }
  2211  
  2212  // GatewayStatusUpdate is sent by the client to indicate a presence or status update
  2213  // https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
  2214  type GatewayStatusUpdate struct {
  2215  	Since  int      `json:"since"`
  2216  	Game   Activity `json:"game"`
  2217  	Status string   `json:"status"`
  2218  	AFK    bool     `json:"afk"`
  2219  }
  2220  
  2221  // Activity defines the Activity sent with GatewayStatusUpdate
  2222  // https://discord.com/developers/docs/topics/gateway#activity-object
  2223  type Activity struct {
  2224  	Name          string       `json:"name"`
  2225  	Type          ActivityType `json:"type"`
  2226  	URL           string       `json:"url,omitempty"`
  2227  	CreatedAt     time.Time    `json:"created_at"`
  2228  	ApplicationID string       `json:"application_id,omitempty"`
  2229  	State         string       `json:"state,omitempty"`
  2230  	Details       string       `json:"details,omitempty"`
  2231  	Timestamps    TimeStamps   `json:"timestamps,omitempty"`
  2232  	Emoji         Emoji        `json:"emoji,omitempty"`
  2233  	Party         Party        `json:"party,omitempty"`
  2234  	Assets        Assets       `json:"assets,omitempty"`
  2235  	Secrets       Secrets      `json:"secrets,omitempty"`
  2236  	Instance      bool         `json:"instance,omitempty"`
  2237  	Flags         int          `json:"flags,omitempty"`
  2238  }
  2239  
  2240  // UnmarshalJSON is a custom unmarshaljson to make CreatedAt a time.Time instead of an int
  2241  func (activity *Activity) UnmarshalJSON(b []byte) error {
  2242  	temp := struct {
  2243  		Name          string       `json:"name"`
  2244  		Type          ActivityType `json:"type"`
  2245  		URL           string       `json:"url,omitempty"`
  2246  		CreatedAt     int64        `json:"created_at"`
  2247  		ApplicationID json.Number  `json:"application_id,omitempty"`
  2248  		State         string       `json:"state,omitempty"`
  2249  		Details       string       `json:"details,omitempty"`
  2250  		Timestamps    TimeStamps   `json:"timestamps,omitempty"`
  2251  		Emoji         Emoji        `json:"emoji,omitempty"`
  2252  		Party         Party        `json:"party,omitempty"`
  2253  		Assets        Assets       `json:"assets,omitempty"`
  2254  		Secrets       Secrets      `json:"secrets,omitempty"`
  2255  		Instance      bool         `json:"instance,omitempty"`
  2256  		Flags         int          `json:"flags,omitempty"`
  2257  	}{}
  2258  	err := Unmarshal(b, &temp)
  2259  	if err != nil {
  2260  		return err
  2261  	}
  2262  	activity.ApplicationID = temp.ApplicationID.String()
  2263  	activity.CreatedAt = time.Unix(0, temp.CreatedAt*1000000)
  2264  	activity.Assets = temp.Assets
  2265  	activity.Details = temp.Details
  2266  	activity.Emoji = temp.Emoji
  2267  	activity.Flags = temp.Flags
  2268  	activity.Instance = temp.Instance
  2269  	activity.Name = temp.Name
  2270  	activity.Party = temp.Party
  2271  	activity.Secrets = temp.Secrets
  2272  	activity.State = temp.State
  2273  	activity.Timestamps = temp.Timestamps
  2274  	activity.Type = temp.Type
  2275  	activity.URL = temp.URL
  2276  	return nil
  2277  }
  2278  
  2279  // Party defines the Party field in the Activity struct
  2280  // https://discord.com/developers/docs/topics/gateway#activity-object
  2281  type Party struct {
  2282  	ID   string `json:"id,omitempty"`
  2283  	Size []int  `json:"size,omitempty"`
  2284  }
  2285  
  2286  // Secrets defines the Secrets field for the Activity struct
  2287  // https://discord.com/developers/docs/topics/gateway#activity-object
  2288  type Secrets struct {
  2289  	Join     string `json:"join,omitempty"`
  2290  	Spectate string `json:"spectate,omitempty"`
  2291  	Match    string `json:"match,omitempty"`
  2292  }
  2293  
  2294  // ActivityType is the type of Activity (see ActivityType* consts) in the Activity struct
  2295  // https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
  2296  type ActivityType int
  2297  
  2298  // Valid ActivityType values
  2299  const (
  2300  	ActivityTypeGame      ActivityType = 0
  2301  	ActivityTypeStreaming ActivityType = 1
  2302  	ActivityTypeListening ActivityType = 2
  2303  	ActivityTypeWatching  ActivityType = 3
  2304  	ActivityTypeCustom    ActivityType = 4
  2305  	ActivityTypeCompeting ActivityType = 5
  2306  )
  2307  
  2308  // Identify is sent during initial handshake with the discord gateway.
  2309  // https://discord.com/developers/docs/topics/gateway#identify
  2310  type Identify struct {
  2311  	Token          string              `json:"token"`
  2312  	Properties     IdentifyProperties  `json:"properties"`
  2313  	Compress       bool                `json:"compress"`
  2314  	LargeThreshold int                 `json:"large_threshold"`
  2315  	Shard          *[2]int             `json:"shard,omitempty"`
  2316  	Presence       GatewayStatusUpdate `json:"presence,omitempty"`
  2317  	Intents        Intent              `json:"intents"`
  2318  }
  2319  
  2320  // IdentifyProperties contains the "properties" portion of an Identify packet
  2321  // https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
  2322  type IdentifyProperties struct {
  2323  	OS              string `json:"$os"`
  2324  	Browser         string `json:"$browser"`
  2325  	Device          string `json:"$device"`
  2326  	Referer         string `json:"$referer"`
  2327  	ReferringDomain string `json:"$referring_domain"`
  2328  }
  2329  
  2330  // StageInstance holds information about a live stage.
  2331  // https://discord.com/developers/docs/resources/stage-instance#stage-instance-resource
  2332  type StageInstance struct {
  2333  	// The id of this Stage instance
  2334  	ID string `json:"id"`
  2335  	// The guild id of the associated Stage channel
  2336  	GuildID string `json:"guild_id"`
  2337  	// The id of the associated Stage channel
  2338  	ChannelID string `json:"channel_id"`
  2339  	// The topic of the Stage instance (1-120 characters)
  2340  	Topic string `json:"topic"`
  2341  	// The privacy level of the Stage instance
  2342  	// https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
  2343  	PrivacyLevel StageInstancePrivacyLevel `json:"privacy_level"`
  2344  	// Whether or not Stage Discovery is disabled (deprecated)
  2345  	DiscoverableDisabled bool `json:"discoverable_disabled"`
  2346  	// The id of the scheduled event for this Stage instance
  2347  	GuildScheduledEventID string `json:"guild_scheduled_event_id"`
  2348  }
  2349  
  2350  // StageInstanceParams represents the parameters needed to create or edit a stage instance
  2351  type StageInstanceParams struct {
  2352  	// ChannelID represents the id of the Stage channel
  2353  	ChannelID string `json:"channel_id,omitempty"`
  2354  	// Topic of the Stage instance (1-120 characters)
  2355  	Topic string `json:"topic,omitempty"`
  2356  	// PrivacyLevel of the Stage instance (default GUILD_ONLY)
  2357  	PrivacyLevel StageInstancePrivacyLevel `json:"privacy_level,omitempty"`
  2358  	// SendStartNotification will notify @everyone that a Stage instance has started
  2359  	SendStartNotification bool `json:"send_start_notification,omitempty"`
  2360  }
  2361  
  2362  // StageInstancePrivacyLevel represents the privacy level of a Stage instance
  2363  // https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
  2364  type StageInstancePrivacyLevel int
  2365  
  2366  const (
  2367  	// StageInstancePrivacyLevelPublic The Stage instance is visible publicly. (deprecated)
  2368  	StageInstancePrivacyLevelPublic StageInstancePrivacyLevel = 1
  2369  	// StageInstancePrivacyLevelGuildOnly The Stage instance is visible to only guild members.
  2370  	StageInstancePrivacyLevelGuildOnly StageInstancePrivacyLevel = 2
  2371  )
  2372  
  2373  // PollLayoutType represents the layout of a poll.
  2374  type PollLayoutType int
  2375  
  2376  // Valid PollLayoutType values.
  2377  const (
  2378  	PollLayoutTypeDefault PollLayoutType = 1
  2379  )
  2380  
  2381  // PollMedia contains common data used by question and answers.
  2382  type PollMedia struct {
  2383  	Text  string          `json:"text,omitempty"`
  2384  	Emoji *ComponentEmoji `json:"emoji,omitempty"` // TODO: rename the type
  2385  }
  2386  
  2387  // PollAnswer represents a single answer in a poll.
  2388  type PollAnswer struct {
  2389  	// NOTE: should not be set on creation.
  2390  	AnswerID int        `json:"answer_id,omitempty"`
  2391  	Media    *PollMedia `json:"poll_media"`
  2392  }
  2393  
  2394  // PollAnswerCount stores counted poll votes for a single answer.
  2395  type PollAnswerCount struct {
  2396  	ID      int  `json:"id"`
  2397  	Count   int  `json:"count"`
  2398  	MeVoted bool `json:"me_voted"`
  2399  }
  2400  
  2401  // PollResults contains voting results on a poll.
  2402  type PollResults struct {
  2403  	Finalized    bool               `json:"is_finalized"`
  2404  	AnswerCounts []*PollAnswerCount `json:"answer_counts"`
  2405  }
  2406  
  2407  // Poll contains all poll related data.
  2408  type Poll struct {
  2409  	Question         PollMedia      `json:"question"`
  2410  	Answers          []PollAnswer   `json:"answers"`
  2411  	AllowMultiselect bool           `json:"allow_multiselect"`
  2412  	LayoutType       PollLayoutType `json:"layout_type,omitempty"`
  2413  
  2414  	// NOTE: should be set only on creation, when fetching use Expiry.
  2415  	Duration int `json:"duration,omitempty"`
  2416  
  2417  	// NOTE: available only when fetching.
  2418  
  2419  	Results *PollResults `json:"results,omitempty"`
  2420  	// NOTE: as Discord documentation notes, this field might be null even when fetching.
  2421  	Expiry *time.Time `json:"expiry,omitempty"`
  2422  }
  2423  
  2424  // SKUType is the type of SKU (see SKUType* consts)
  2425  // https://discord.com/developers/docs/monetization/skus
  2426  type SKUType int
  2427  
  2428  // Valid SKUType values
  2429  const (
  2430  	SKUTypeDurable      SKUType = 2
  2431  	SKUTypeConsumable   SKUType = 3
  2432  	SKUTypeSubscription SKUType = 5
  2433  	// SKUTypeSubscriptionGroup is a system-generated group for each subscription SKU.
  2434  	SKUTypeSubscriptionGroup SKUType = 6
  2435  )
  2436  
  2437  // SKUFlags is a bitfield of flags used to differentiate user and server subscriptions (see SKUFlag* consts)
  2438  // https://discord.com/developers/docs/monetization/skus#sku-object-sku-flags
  2439  type SKUFlags int
  2440  
  2441  const (
  2442  	// SKUFlagAvailable indicates that the SKU is available for purchase.
  2443  	SKUFlagAvailable SKUFlags = 1 << 2
  2444  	// SKUFlagGuildSubscription indicates that the SKU is a guild subscription.
  2445  	SKUFlagGuildSubscription SKUFlags = 1 << 7
  2446  	// SKUFlagUserSubscription indicates that the SKU is a user subscription.
  2447  	SKUFlagUserSubscription SKUFlags = 1 << 8
  2448  )
  2449  
  2450  // SKU (stock-keeping units) represent premium offerings
  2451  type SKU struct {
  2452  	// The ID of the SKU
  2453  	ID string `json:"id"`
  2454  
  2455  	// The Type of the SKU
  2456  	Type SKUType `json:"type"`
  2457  
  2458  	// The ID of the parent application
  2459  	ApplicationID string `json:"application_id"`
  2460  
  2461  	// Customer-facing name of the SKU.
  2462  	Name string `json:"name"`
  2463  
  2464  	// System-generated URL slug based on the SKU's name.
  2465  	Slug string `json:"slug"`
  2466  
  2467  	// SKUFlags combined as a bitfield. The presence of a certain flag can be checked
  2468  	// by performing a bitwise AND operation between this int and the flag.
  2469  	Flags SKUFlags `json:"flags"`
  2470  }
  2471  
  2472  // Subscription represents a user making recurring payments for at least one SKU over an ongoing period.
  2473  // https://discord.com/developers/docs/resources/subscription#subscription-object
  2474  type Subscription struct {
  2475  	// ID of the subscription
  2476  	ID string `json:"id"`
  2477  
  2478  	// ID of the user who is subscribed
  2479  	UserID string `json:"user_id"`
  2480  
  2481  	// List of SKUs subscribed to
  2482  	SKUIDs []string `json:"sku_ids"`
  2483  
  2484  	// List of entitlements granted for this subscription
  2485  	EntitlementIDs []string `json:"entitlement_ids"`
  2486  
  2487  	// List of SKUs that this user will be subscribed to at renewal
  2488  	RenewalSKUIDs []string `json:"renewal_sku_ids,omitempty"`
  2489  
  2490  	// Start of the current subscription period
  2491  	CurrentPeriodStart time.Time `json:"current_period_start"`
  2492  
  2493  	// End of the current subscription period
  2494  	CurrentPeriodEnd time.Time `json:"current_period_end"`
  2495  
  2496  	// Current status of the subscription
  2497  	Status SubscriptionStatus `json:"status"`
  2498  
  2499  	// When the subscription was canceled. Only present if the subscription has been canceled.
  2500  	CanceledAt *time.Time `json:"canceled_at,omitempty"`
  2501  
  2502  	// ISO3166-1 alpha-2 country code of the payment source used to purchase the subscription. Missing unless queried with a private OAuth scope.
  2503  	Country string `json:"country,omitempty"`
  2504  }
  2505  
  2506  // SubscriptionStatus is the current status of a Subscription Object
  2507  // https://discord.com/developers/docs/resources/subscription#subscription-statuses
  2508  type SubscriptionStatus int
  2509  
  2510  // Valid SubscriptionStatus values
  2511  const (
  2512  	SubscriptionStatusActive   = 0
  2513  	SubscriptionStatusEnding   = 1
  2514  	SubscriptionStatusInactive = 2
  2515  )
  2516  
  2517  // EntitlementType is the type of entitlement (see EntitlementType* consts)
  2518  // https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
  2519  type EntitlementType int
  2520  
  2521  // Valid EntitlementType values
  2522  const (
  2523  	EntitlementTypePurchase                = 1
  2524  	EntitlementTypePremiumSubscription     = 2
  2525  	EntitlementTypeDeveloperGift           = 3
  2526  	EntitlementTypeTestModePurchase        = 4
  2527  	EntitlementTypeFreePurchase            = 5
  2528  	EntitlementTypeUserGift                = 6
  2529  	EntitlementTypePremiumPurchase         = 7
  2530  	EntitlementTypeApplicationSubscription = 8
  2531  )
  2532  
  2533  // Entitlement represents that a user or guild has access to a premium offering
  2534  // in your application.
  2535  type Entitlement struct {
  2536  	// The ID of the entitlement
  2537  	ID string `json:"id"`
  2538  
  2539  	// The ID of the SKU
  2540  	SKUID string `json:"sku_id"`
  2541  
  2542  	// The ID of the parent application
  2543  	ApplicationID string `json:"application_id"`
  2544  
  2545  	// The ID of the user that is granted access to the entitlement's sku
  2546  	// Only available for user subscriptions.
  2547  	UserID string `json:"user_id,omitempty"`
  2548  
  2549  	// The type of the entitlement
  2550  	Type EntitlementType `json:"type"`
  2551  
  2552  	// The entitlement was deleted
  2553  	Deleted bool `json:"deleted"`
  2554  
  2555  	// The start date at which the entitlement is valid.
  2556  	// Not present when using test entitlements.
  2557  	StartsAt *time.Time `json:"starts_at,omitempty"`
  2558  
  2559  	// The date at which the entitlement is no longer valid.
  2560  	// Not present when using test entitlements or when receiving an ENTITLEMENT_CREATE event.
  2561  	EndsAt *time.Time `json:"ends_at,omitempty"`
  2562  
  2563  	// The ID of the guild that is granted access to the entitlement's sku.
  2564  	// Only available for guild subscriptions.
  2565  	GuildID string `json:"guild_id,omitempty"`
  2566  
  2567  	// Whether or not the entitlement has been consumed.
  2568  	// Only available for consumable items.
  2569  	Consumed *bool `json:"consumed,omitempty"`
  2570  
  2571  	// The SubscriptionID of the entitlement.
  2572  	// Not present when using test entitlements.
  2573  	SubscriptionID string `json:"subscription_id,omitempty"`
  2574  }
  2575  
  2576  // EntitlementOwnerType is the type of entitlement (see EntitlementOwnerType* consts)
  2577  type EntitlementOwnerType int
  2578  
  2579  // Valid EntitlementOwnerType values
  2580  const (
  2581  	EntitlementOwnerTypeGuildSubscription EntitlementOwnerType = 1
  2582  	EntitlementOwnerTypeUserSubscription  EntitlementOwnerType = 2
  2583  )
  2584  
  2585  // EntitlementTest is used to test granting an entitlement to a user or guild
  2586  type EntitlementTest struct {
  2587  	// The ID of the SKU to grant the entitlement to
  2588  	SKUID string `json:"sku_id"`
  2589  
  2590  	// The ID of the guild or user to grant the entitlement to
  2591  	OwnerID string `json:"owner_id"`
  2592  
  2593  	// OwnerType is the type of which the entitlement should be created
  2594  	OwnerType EntitlementOwnerType `json:"owner_type"`
  2595  }
  2596  
  2597  // EntitlementFilterOptions are the options for filtering Entitlements
  2598  type EntitlementFilterOptions struct {
  2599  	// Optional user ID to look up for.
  2600  	UserID string
  2601  
  2602  	// Optional array of SKU IDs to check for.
  2603  	SkuIDs []string
  2604  
  2605  	// Optional timestamp to retrieve Entitlements before this time.
  2606  	Before *time.Time
  2607  
  2608  	// Optional timestamp to retrieve Entitlements after this time.
  2609  	After *time.Time
  2610  
  2611  	// Optional maximum number of entitlements to return (1-100, default 100).
  2612  	Limit int
  2613  
  2614  	// Optional guild ID to look up for.
  2615  	GuildID string
  2616  
  2617  	// Optional whether or not ended entitlements should be omitted.
  2618  	ExcludeEnded bool
  2619  }
  2620  
  2621  // Constants for the different bit offsets of text channel permissions
  2622  const (
  2623  	// Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
  2624  	PermissionReadMessages = 1 << 10
  2625  
  2626  	// Allows for sending messages in a channel and creating threads in a forum (does not allow sending messages in threads).
  2627  	PermissionSendMessages = 1 << 11
  2628  
  2629  	// Allows for sending of /tts messages.
  2630  	PermissionSendTTSMessages = 1 << 12
  2631  
  2632  	// Allows for deletion of other users messages.
  2633  	PermissionManageMessages = 1 << 13
  2634  
  2635  	// Links sent by users with this permission will be auto-embedded.
  2636  	PermissionEmbedLinks = 1 << 14
  2637  
  2638  	// Allows for uploading images and files.
  2639  	PermissionAttachFiles = 1 << 15
  2640  
  2641  	// Allows for reading of message history.
  2642  	PermissionReadMessageHistory = 1 << 16
  2643  
  2644  	// 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.
  2645  	PermissionMentionEveryone = 1 << 17
  2646  
  2647  	// Allows the usage of custom emojis from other servers.
  2648  	PermissionUseExternalEmojis = 1 << 18
  2649  
  2650  	// Deprecated: PermissionUseSlashCommands has been replaced by PermissionUseApplicationCommands
  2651  	PermissionUseSlashCommands = 1 << 31
  2652  
  2653  	// Allows members to use application commands, including slash commands and context menu commands.
  2654  	PermissionUseApplicationCommands = 1 << 31
  2655  
  2656  	// Allows for deleting and archiving threads, and viewing all private threads.
  2657  	PermissionManageThreads = 1 << 34
  2658  
  2659  	// Allows for creating public and announcement threads.
  2660  	PermissionCreatePublicThreads = 1 << 35
  2661  
  2662  	// Allows for creating private threads.
  2663  	PermissionCreatePrivateThreads = 1 << 36
  2664  
  2665  	// Allows the usage of custom stickers from other servers.
  2666  	PermissionUseExternalStickers = 1 << 37
  2667  
  2668  	// Allows for sending messages in threads.
  2669  	PermissionSendMessagesInThreads = 1 << 38
  2670  
  2671  	// Allows sending voice messages.
  2672  	PermissionSendVoiceMessages = 1 << 46
  2673  
  2674  	// Allows sending polls.
  2675  	PermissionSendPolls = 1 << 49
  2676  
  2677  	// Allows user-installed apps to send public responses. When disabled, users will still be allowed to use their apps but the responses will be ephemeral. This only applies to apps not also installed to the server.
  2678  	PermissionUseExternalApps = 1 << 50
  2679  )
  2680  
  2681  // Constants for the different bit offsets of voice permissions
  2682  const (
  2683  	// Allows for using priority speaker in a voice channel.
  2684  	PermissionVoicePrioritySpeaker = 1 << 8
  2685  
  2686  	// Allows the user to go live.
  2687  	PermissionVoiceStreamVideo = 1 << 9
  2688  
  2689  	// Allows for joining of a voice channel.
  2690  	PermissionVoiceConnect = 1 << 20
  2691  
  2692  	// Allows for speaking in a voice channel.
  2693  	PermissionVoiceSpeak = 1 << 21
  2694  
  2695  	// Allows for muting members in a voice channel.
  2696  	PermissionVoiceMuteMembers = 1 << 22
  2697  
  2698  	// Allows for deafening of members in a voice channel.
  2699  	PermissionVoiceDeafenMembers = 1 << 23
  2700  
  2701  	// Allows for moving of members between voice channels.
  2702  	PermissionVoiceMoveMembers = 1 << 24
  2703  
  2704  	// Allows for using voice-activity-detection in a voice channel.
  2705  	PermissionVoiceUseVAD = 1 << 25
  2706  
  2707  	// Allows for requesting to speak in stage channels.
  2708  	PermissionVoiceRequestToSpeak = 1 << 32
  2709  
  2710  	// Deprecated: PermissionUseActivities has been replaced by PermissionUseEmbeddedActivities.
  2711  	PermissionUseActivities = 1 << 39
  2712  
  2713  	// Allows for using Activities (applications with the EMBEDDED flag) in a voice channel.
  2714  	PermissionUseEmbeddedActivities = 1 << 39
  2715  
  2716  	// Allows for using soundboard in a voice channel.
  2717  	PermissionUseSoundboard = 1 << 42
  2718  
  2719  	// Allows the usage of custom soundboard sounds from other servers.
  2720  	PermissionUseExternalSounds = 1 << 45
  2721  )
  2722  
  2723  // Constants for general management.
  2724  const (
  2725  	// Allows for modification of own nickname.
  2726  	PermissionChangeNickname = 1 << 26
  2727  
  2728  	// Allows for modification of other users nicknames.
  2729  	PermissionManageNicknames = 1 << 27
  2730  
  2731  	// Allows management and editing of roles.
  2732  	PermissionManageRoles = 1 << 28
  2733  
  2734  	// Allows management and editing of webhooks.
  2735  	PermissionManageWebhooks = 1 << 29
  2736  
  2737  	// Deprecated: PermissionManageEmojis has been replaced by PermissionManageGuildExpressions.
  2738  	PermissionManageEmojis = 1 << 30
  2739  
  2740  	// Allows for editing and deleting emojis, stickers, and soundboard sounds created by all users.
  2741  	PermissionManageGuildExpressions = 1 << 30
  2742  
  2743  	// Allows for editing and deleting scheduled events created by all users.
  2744  	PermissionManageEvents = 1 << 33
  2745  
  2746  	// Allows for viewing role subscription insights.
  2747  	PermissionViewCreatorMonetizationAnalytics = 1 << 41
  2748  
  2749  	// Allows for creating emojis, stickers, and soundboard sounds, and editing and deleting those created by the current user.
  2750  	PermissionCreateGuildExpressions = 1 << 43
  2751  
  2752  	// Allows for creating scheduled events, and editing and deleting those created by the current user.
  2753  	PermissionCreateEvents = 1 << 44
  2754  )
  2755  
  2756  // Constants for the different bit offsets of general permissions
  2757  const (
  2758  	// Allows creation of instant invites.
  2759  	PermissionCreateInstantInvite = 1 << 0
  2760  
  2761  	// Allows kicking members.
  2762  	PermissionKickMembers = 1 << 1
  2763  
  2764  	// Allows banning members.
  2765  	PermissionBanMembers = 1 << 2
  2766  
  2767  	// Allows all permissions and bypasses channel permission overwrites.
  2768  	PermissionAdministrator = 1 << 3
  2769  
  2770  	// Allows management and editing of channels.
  2771  	PermissionManageChannels = 1 << 4
  2772  
  2773  	// Deprecated: PermissionManageServer has been replaced by PermissionManageGuild.
  2774  	PermissionManageServer = 1 << 5
  2775  
  2776  	// Allows management and editing of the guild.
  2777  	PermissionManageGuild = 1 << 5
  2778  
  2779  	// Allows for the addition of reactions to messages.
  2780  	PermissionAddReactions = 1 << 6
  2781  
  2782  	// Allows for viewing of audit logs.
  2783  	PermissionViewAuditLogs = 1 << 7
  2784  
  2785  	// Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels.
  2786  	PermissionViewChannel = 1 << 10
  2787  
  2788  	// Allows for viewing guild insights.
  2789  	PermissionViewGuildInsights = 1 << 19
  2790  
  2791  	// 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.
  2792  	PermissionModerateMembers = 1 << 40
  2793  
  2794  	PermissionAllText = PermissionViewChannel |
  2795  		PermissionSendMessages |
  2796  		PermissionSendTTSMessages |
  2797  		PermissionManageMessages |
  2798  		PermissionEmbedLinks |
  2799  		PermissionAttachFiles |
  2800  		PermissionReadMessageHistory |
  2801  		PermissionMentionEveryone
  2802  	PermissionAllVoice = PermissionViewChannel |
  2803  		PermissionVoiceConnect |
  2804  		PermissionVoiceSpeak |
  2805  		PermissionVoiceMuteMembers |
  2806  		PermissionVoiceDeafenMembers |
  2807  		PermissionVoiceMoveMembers |
  2808  		PermissionVoiceUseVAD |
  2809  		PermissionVoicePrioritySpeaker
  2810  	PermissionAllChannel = PermissionAllText |
  2811  		PermissionAllVoice |
  2812  		PermissionCreateInstantInvite |
  2813  		PermissionManageRoles |
  2814  		PermissionManageChannels |
  2815  		PermissionAddReactions |
  2816  		PermissionViewAuditLogs
  2817  	PermissionAll = PermissionAllChannel |
  2818  		PermissionKickMembers |
  2819  		PermissionBanMembers |
  2820  		PermissionManageServer |
  2821  		PermissionAdministrator |
  2822  		PermissionManageWebhooks |
  2823  		PermissionManageEmojis
  2824  )
  2825  
  2826  // Block contains Discord JSON Error Response codes
  2827  const (
  2828  	ErrCodeGeneralError = 0
  2829  
  2830  	ErrCodeUnknownAccount                        = 10001
  2831  	ErrCodeUnknownApplication                    = 10002
  2832  	ErrCodeUnknownChannel                        = 10003
  2833  	ErrCodeUnknownGuild                          = 10004
  2834  	ErrCodeUnknownIntegration                    = 10005
  2835  	ErrCodeUnknownInvite                         = 10006
  2836  	ErrCodeUnknownMember                         = 10007
  2837  	ErrCodeUnknownMessage                        = 10008
  2838  	ErrCodeUnknownOverwrite                      = 10009
  2839  	ErrCodeUnknownProvider                       = 10010
  2840  	ErrCodeUnknownRole                           = 10011
  2841  	ErrCodeUnknownToken                          = 10012
  2842  	ErrCodeUnknownUser                           = 10013
  2843  	ErrCodeUnknownEmoji                          = 10014
  2844  	ErrCodeUnknownWebhook                        = 10015
  2845  	ErrCodeUnknownWebhookService                 = 10016
  2846  	ErrCodeUnknownSession                        = 10020
  2847  	ErrCodeUnknownBan                            = 10026
  2848  	ErrCodeUnknownSKU                            = 10027
  2849  	ErrCodeUnknownStoreListing                   = 10028
  2850  	ErrCodeUnknownEntitlement                    = 10029
  2851  	ErrCodeUnknownBuild                          = 10030
  2852  	ErrCodeUnknownLobby                          = 10031
  2853  	ErrCodeUnknownBranch                         = 10032
  2854  	ErrCodeUnknownStoreDirectoryLayout           = 10033
  2855  	ErrCodeUnknownRedistributable                = 10036
  2856  	ErrCodeUnknownGiftCode                       = 10038
  2857  	ErrCodeUnknownStream                         = 10049
  2858  	ErrCodeUnknownPremiumServerSubscribeCooldown = 10050
  2859  	ErrCodeUnknownGuildTemplate                  = 10057
  2860  	ErrCodeUnknownDiscoveryCategory              = 10059
  2861  	ErrCodeUnknownSticker                        = 10060
  2862  	ErrCodeUnknownInteraction                    = 10062
  2863  	ErrCodeUnknownApplicationCommand             = 10063
  2864  	ErrCodeUnknownApplicationCommandPermissions  = 10066
  2865  	ErrCodeUnknownStageInstance                  = 10067
  2866  	ErrCodeUnknownGuildMemberVerificationForm    = 10068
  2867  	ErrCodeUnknownGuildWelcomeScreen             = 10069
  2868  	ErrCodeUnknownGuildScheduledEvent            = 10070
  2869  	ErrCodeUnknownGuildScheduledEventUser        = 10071
  2870  	ErrUnknownTag                                = 10087
  2871  
  2872  	ErrCodeBotsCannotUseEndpoint                                            = 20001
  2873  	ErrCodeOnlyBotsCanUseEndpoint                                           = 20002
  2874  	ErrCodeExplicitContentCannotBeSentToTheDesiredRecipients                = 20009
  2875  	ErrCodeYouAreNotAuthorizedToPerformThisActionOnThisApplication          = 20012
  2876  	ErrCodeThisActionCannotBePerformedDueToSlowmodeRateLimit                = 20016
  2877  	ErrCodeOnlyTheOwnerOfThisAccountCanPerformThisAction                    = 20018
  2878  	ErrCodeMessageCannotBeEditedDueToAnnouncementRateLimits                 = 20022
  2879  	ErrCodeChannelHasHitWriteRateLimit                                      = 20028
  2880  	ErrCodeTheWriteActionYouArePerformingOnTheServerHasHitTheWriteRateLimit = 20029
  2881  	ErrCodeStageTopicContainsNotAllowedWordsForPublicStages                 = 20031
  2882  	ErrCodeGuildPremiumSubscriptionLevelTooLow                              = 20035
  2883  
  2884  	ErrCodeMaximumGuildsReached                                     = 30001
  2885  	ErrCodeMaximumPinsReached                                       = 30003
  2886  	ErrCodeMaximumNumberOfRecipientsReached                         = 30004
  2887  	ErrCodeMaximumGuildRolesReached                                 = 30005
  2888  	ErrCodeMaximumNumberOfWebhooksReached                           = 30007
  2889  	ErrCodeMaximumNumberOfEmojisReached                             = 30008
  2890  	ErrCodeTooManyReactions                                         = 30010
  2891  	ErrCodeMaximumNumberOfGuildChannelsReached                      = 30013
  2892  	ErrCodeMaximumNumberOfAttachmentsInAMessageReached              = 30015
  2893  	ErrCodeMaximumNumberOfInvitesReached                            = 30016
  2894  	ErrCodeMaximumNumberOfAnimatedEmojisReached                     = 30018
  2895  	ErrCodeMaximumNumberOfServerMembersReached                      = 30019
  2896  	ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached        = 30030
  2897  	ErrCodeGuildAlreadyHasATemplate                                 = 30031
  2898  	ErrCodeMaximumNumberOfThreadParticipantsReached                 = 30033
  2899  	ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded    = 30035
  2900  	ErrCodeMaximumNumberOfBansFetchesHasBeenReached                 = 30037
  2901  	ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached    = 30038
  2902  	ErrCodeMaximumNumberOfStickersReached                           = 30039
  2903  	ErrCodeMaximumNumberOfPruneRequestsHasBeenReached               = 30040
  2904  	ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached  = 30042
  2905  	ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached    = 30046
  2906  	ErrCodeMaximumNumberOfPinnedThreadsInForumChannelHasBeenReached = 30047
  2907  	ErrCodeMaximumNumberOfTagsInForumChannelHasBeenReached          = 30048
  2908  
  2909  	ErrCodeUnauthorized                           = 40001
  2910  	ErrCodeActionRequiredVerifiedAccount          = 40002
  2911  	ErrCodeOpeningDirectMessagesTooFast           = 40003
  2912  	ErrCodeSendMessagesHasBeenTemporarilyDisabled = 40004
  2913  	ErrCodeRequestEntityTooLarge                  = 40005
  2914  	ErrCodeFeatureTemporarilyDisabledServerSide   = 40006
  2915  	ErrCodeUserIsBannedFromThisGuild              = 40007
  2916  	ErrCodeTargetIsNotConnectedToVoice            = 40032
  2917  	ErrCodeMessageAlreadyCrossposted              = 40033
  2918  	ErrCodeAnApplicationWithThatNameAlreadyExists = 40041
  2919  	ErrCodeInteractionHasAlreadyBeenAcknowledged  = 40060
  2920  	ErrCodeTagNamesMustBeUnique                   = 40061
  2921  
  2922  	ErrCodeMissingAccess                                                = 50001
  2923  	ErrCodeInvalidAccountType                                           = 50002
  2924  	ErrCodeCannotExecuteActionOnDMChannel                               = 50003
  2925  	ErrCodeEmbedDisabled                                                = 50004
  2926  	ErrCodeGuildWidgetDisabled                                          = 50004
  2927  	ErrCodeCannotEditFromAnotherUser                                    = 50005
  2928  	ErrCodeCannotSendEmptyMessage                                       = 50006
  2929  	ErrCodeCannotSendMessagesToThisUser                                 = 50007
  2930  	ErrCodeCannotSendMessagesInVoiceChannel                             = 50008
  2931  	ErrCodeChannelVerificationLevelTooHigh                              = 50009
  2932  	ErrCodeOAuth2ApplicationDoesNotHaveBot                              = 50010
  2933  	ErrCodeOAuth2ApplicationLimitReached                                = 50011
  2934  	ErrCodeInvalidOAuthState                                            = 50012
  2935  	ErrCodeMissingPermissions                                           = 50013
  2936  	ErrCodeInvalidAuthenticationToken                                   = 50014
  2937  	ErrCodeTooFewOrTooManyMessagesToDelete                              = 50016
  2938  	ErrCodeCanOnlyPinMessageToOriginatingChannel                        = 50019
  2939  	ErrCodeInviteCodeWasEitherInvalidOrTaken                            = 50020
  2940  	ErrCodeCannotExecuteActionOnSystemMessage                           = 50021
  2941  	ErrCodeCannotExecuteActionOnThisChannelType                         = 50024
  2942  	ErrCodeInvalidOAuth2AccessTokenProvided                             = 50025
  2943  	ErrCodeMissingRequiredOAuth2Scope                                   = 50026
  2944  	ErrCodeInvalidWebhookTokenProvided                                  = 50027
  2945  	ErrCodeInvalidRole                                                  = 50028
  2946  	ErrCodeInvalidRecipients                                            = 50033
  2947  	ErrCodeMessageProvidedTooOldForBulkDelete                           = 50034
  2948  	ErrCodeInvalidFormBody                                              = 50035
  2949  	ErrCodeInviteAcceptedToGuildApplicationsBotNotIn                    = 50036
  2950  	ErrCodeInvalidAPIVersionProvided                                    = 50041
  2951  	ErrCodeFileUploadedExceedsTheMaximumSize                            = 50045
  2952  	ErrCodeInvalidFileUploaded                                          = 50046
  2953  	ErrCodeInvalidGuild                                                 = 50055
  2954  	ErrCodeInvalidMessageType                                           = 50068
  2955  	ErrCodeCannotDeleteAChannelRequiredForCommunityGuilds               = 50074
  2956  	ErrCodeInvalidStickerSent                                           = 50081
  2957  	ErrCodePerformedOperationOnArchivedThread                           = 50083
  2958  	ErrCodeBeforeValueIsEarlierThanThreadCreationDate                   = 50085
  2959  	ErrCodeCommunityServerChannelsMustBeTextChannels                    = 50086
  2960  	ErrCodeThisServerIsNotAvailableInYourLocation                       = 50095
  2961  	ErrCodeThisServerNeedsMonetizationEnabledInOrderToPerformThisAction = 50097
  2962  	ErrCodeThisServerNeedsMoreBoostsToPerformThisAction                 = 50101
  2963  	ErrCodeTheRequestBodyContainsInvalidJSON                            = 50109
  2964  
  2965  	ErrCodeNoUsersWithDiscordTagExist = 80004
  2966  
  2967  	ErrCodeReactionBlocked = 90001
  2968  
  2969  	ErrCodeAPIResourceIsCurrentlyOverloaded = 130000
  2970  
  2971  	ErrCodeTheStageIsAlreadyOpen = 150006
  2972  
  2973  	ErrCodeCannotReplyWithoutPermissionToReadMessageHistory = 160002
  2974  	ErrCodeThreadAlreadyCreatedForThisMessage               = 160004
  2975  	ErrCodeThreadIsLocked                                   = 160005
  2976  	ErrCodeMaximumNumberOfActiveThreadsReached              = 160006
  2977  	ErrCodeMaximumNumberOfActiveAnnouncementThreadsReached  = 160007
  2978  
  2979  	ErrCodeInvalidJSONForUploadedLottieFile                    = 170001
  2980  	ErrCodeUploadedLottiesCannotContainRasterizedImages        = 170002
  2981  	ErrCodeStickerMaximumFramerateExceeded                     = 170003
  2982  	ErrCodeStickerFrameCountExceedsMaximumOfOneThousandFrames  = 170004
  2983  	ErrCodeLottieAnimationMaximumDimensionsExceeded            = 170005
  2984  	ErrCodeStickerFrameRateOutOfRange                          = 170006
  2985  	ErrCodeStickerAnimationDurationExceedsMaximumOfFiveSeconds = 170007
  2986  
  2987  	ErrCodeCannotUpdateAFinishedEvent             = 180000
  2988  	ErrCodeFailedToCreateStageNeededForStageEvent = 180002
  2989  
  2990  	ErrCodeCannotEnableOnboardingRequirementsAreNotMet  = 350000
  2991  	ErrCodeCannotUpdateOnboardingWhileBelowRequirements = 350001
  2992  )
  2993  
  2994  // Intent is the type of a Gateway Intent
  2995  // https://discord.com/developers/docs/topics/gateway#gateway-intents
  2996  type Intent int
  2997  
  2998  // Constants for the different bit offsets of intents
  2999  const (
  3000  	IntentGuilds                      Intent = 1 << 0
  3001  	IntentGuildMembers                Intent = 1 << 1
  3002  	IntentGuildModeration             Intent = 1 << 2
  3003  	IntentGuildEmojis                 Intent = 1 << 3
  3004  	IntentGuildIntegrations           Intent = 1 << 4
  3005  	IntentGuildWebhooks               Intent = 1 << 5
  3006  	IntentGuildInvites                Intent = 1 << 6
  3007  	IntentGuildVoiceStates            Intent = 1 << 7
  3008  	IntentGuildPresences              Intent = 1 << 8
  3009  	IntentGuildMessages               Intent = 1 << 9
  3010  	IntentGuildMessageReactions       Intent = 1 << 10
  3011  	IntentGuildMessageTyping          Intent = 1 << 11
  3012  	IntentDirectMessages              Intent = 1 << 12
  3013  	IntentDirectMessageReactions      Intent = 1 << 13
  3014  	IntentDirectMessageTyping         Intent = 1 << 14
  3015  	IntentMessageContent              Intent = 1 << 15
  3016  	IntentGuildScheduledEvents        Intent = 1 << 16
  3017  	IntentAutoModerationConfiguration Intent = 1 << 20
  3018  	IntentAutoModerationExecution     Intent = 1 << 21
  3019  	IntentGuildMessagePolls           Intent = 1 << 24
  3020  	IntentDirectMessagePolls          Intent = 1 << 25
  3021  
  3022  	// TODO: remove when compatibility is not needed
  3023  
  3024  	IntentGuildBans Intent = IntentGuildModeration
  3025  
  3026  	IntentsGuilds                 Intent = 1 << 0
  3027  	IntentsGuildMembers           Intent = 1 << 1
  3028  	IntentsGuildBans              Intent = 1 << 2
  3029  	IntentsGuildEmojis            Intent = 1 << 3
  3030  	IntentsGuildIntegrations      Intent = 1 << 4
  3031  	IntentsGuildWebhooks          Intent = 1 << 5
  3032  	IntentsGuildInvites           Intent = 1 << 6
  3033  	IntentsGuildVoiceStates       Intent = 1 << 7
  3034  	IntentsGuildPresences         Intent = 1 << 8
  3035  	IntentsGuildMessages          Intent = 1 << 9
  3036  	IntentsGuildMessageReactions  Intent = 1 << 10
  3037  	IntentsGuildMessageTyping     Intent = 1 << 11
  3038  	IntentsDirectMessages         Intent = 1 << 12
  3039  	IntentsDirectMessageReactions Intent = 1 << 13
  3040  	IntentsDirectMessageTyping    Intent = 1 << 14
  3041  	IntentsMessageContent         Intent = 1 << 15
  3042  	IntentsGuildScheduledEvents   Intent = 1 << 16
  3043  
  3044  	IntentsAllWithoutPrivileged = IntentGuilds |
  3045  		IntentGuildBans |
  3046  		IntentGuildEmojis |
  3047  		IntentGuildIntegrations |
  3048  		IntentGuildWebhooks |
  3049  		IntentGuildInvites |
  3050  		IntentGuildVoiceStates |
  3051  		IntentGuildMessages |
  3052  		IntentGuildMessageReactions |
  3053  		IntentGuildMessageTyping |
  3054  		IntentDirectMessages |
  3055  		IntentDirectMessageReactions |
  3056  		IntentDirectMessageTyping |
  3057  		IntentGuildScheduledEvents |
  3058  		IntentAutoModerationConfiguration |
  3059  		IntentAutoModerationExecution
  3060  
  3061  	IntentsAll = IntentsAllWithoutPrivileged |
  3062  		IntentGuildMembers |
  3063  		IntentGuildPresences |
  3064  		IntentMessageContent
  3065  
  3066  	IntentsNone Intent = 0
  3067  )
  3068  
  3069  // MakeIntent used to help convert a gateway intent value for use in the Identify structure;
  3070  // this was useful to help support the use of a pointer type when intents were optional.
  3071  // This is now a no-op, and is not necessary to use.
  3072  func MakeIntent(intents Intent) Intent {
  3073  	return intents
  3074  }