api

package
v3.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: ISC Imports: 18 Imported by: 132

Documentation

Overview

Package api provides an interface to interact with the Discord REST API. It handles rate limiting, as well as authorizing and more.

Index

Constants

View Source
const AttachmentSpoilerPrefix = "SPOILER_"
View Source
const MaxGuildFetchLimit = 100

MaxGuildFetchLimit is the limit of max guilds per request, as imposed by Discord.

View Source
const MaxMemberFetchLimit = 1000
View Source
const MaxMessageReactionFetchLimit = 100

Variables

View Source
var (
	BaseEndpoint = "https://discord.com"
	Version      = "9"
	Path         = "/api/v" + Version

	Endpoint           = BaseEndpoint + Path + "/"
	EndpointGateway    = Endpoint + "gateway"
	EndpointGatewayBot = EndpointGateway + "/bot"
)
View Source
var (
	EndpointAuth  = Endpoint + "auth/"
	EndpointLogin = EndpointAuth + "login"
	EndpointTOTP  = EndpointAuth + "mfa/totp"
)
View Source
var (
	EndpointUsers = Endpoint + "users/"
	EndpointMe    = EndpointUsers + "@me"
)
View Source
var EndpointApplications = Endpoint + "applications/"
View Source
var EndpointChannels = Endpoint + "channels/"
View Source
var EndpointGuilds = Endpoint + "guilds/"
View Source
var EndpointInteractions = Endpoint + "interactions/"
View Source
var EndpointInvites = Endpoint + "invites/"
View Source
var EndpointStageInstances = Endpoint + "stage-instances/"
View Source
var EndpointWebhooks = Endpoint + "webhooks/"
View Source
var ErrEmptyMessage = errors.New("message is empty")

ErrEmptyMessage is returned if either a SendMessageData or an ExecuteWebhookData is missing content, embeds, and files.

View Source
var ErrInvalidImageCT = errors.New("unknown image content-type")
View Source
var ErrInvalidImageData = errors.New("invalid image data")
View Source
var NullImage = &Image{}

NullImage is an *Image value that marshals to a null value. Use this to unset the image. It exists mostly for documentation purposes.

View Source
var UserAgent = "DiscordBot (https://github.com/diamondburned/arikawa/v3)"

Functions

func GatewayURL

func GatewayURL(ctx context.Context) (string, error)

GatewayURL asks Discord for a Websocket URL to the Gateway.

Types

type Ack

type Ack struct {
	Token *string `json:"token"`
}

Ack is the read state of a channel. This is undocumented.

type ActiveThreads

type ActiveThreads struct {
	// Threads are the active threads, ordered by descending ID.
	Threads []discord.Channel `json:"threads"`
	// Members contains a thread member for each of the Threads the current
	// user has joined.
	Members []discord.ThreadMember `json:"members"`
}

https://discord.com/developers/docs/resources/guild#list-active-threads-response-body

type AddMemberData

type AddMemberData struct {
	// Token is an oauth2 access token granted with the guilds.join to the
	// bot's application for the user you want to add to the guild.
	Token string `json:"access_token"`
	// Nick is the value to set users nickname to.
	//
	// Requires MANAGE_NICKNAMES.
	Nick option.String `json:"nick,omitempty"`
	// Roles is an array of role ids the member is assigned.
	//
	// Requires MANAGE_ROLES.
	Roles *[]discord.RoleID `json:"roles,omitempty"`
	// Mute specifies whether the user is muted in voice channels.
	//
	// Requires MUTE_MEMBERS.
	Mute option.Bool `json:"mute,omitempty"`
	// Deaf specifies whether the user is deafened in voice channels.
	//
	// Requires DEAFEN_MEMBERS.
	Deaf option.Bool `json:"deaf,omitempty"`
}

https://discord.com/developers/docs/resources/guild#add-guild-member-json-params

type AddRoleData

type AddRoleData struct {
	AuditLogReason
}

type AllowedMentionType

type AllowedMentionType string

AllowedMentionType is a constant that tells Discord what is allowed to parse from a message content. This can help prevent things such as an unintentional @everyone mention.

const (
	// AllowRoleMention makes Discord parse roles in the content.
	AllowRoleMention AllowedMentionType = "roles"
	// AllowUserMention makes Discord parse user mentions in the content.
	AllowUserMention AllowedMentionType = "users"
	// AllowEveryoneMention makes Discord parse @everyone mentions.
	AllowEveryoneMention AllowedMentionType = "everyone"
)

https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types

type AllowedMentions

type AllowedMentions struct {
	// Parse is an array of allowed mention types to parse from the content.
	Parse []AllowedMentionType `json:"parse"`
	// Roles is an array of role_ids to mention (Max size of 100).
	Roles []discord.RoleID `json:"roles,omitempty"`
	// Users is an array of user_ids to mention (Max size of 100).
	Users []discord.UserID `json:"users,omitempty"`
	// RepliedUser is used specifically for inline replies to specify, whether
	// to mention the author of the message you are replying to or not.
	RepliedUser option.Bool `json:"replied_user,omitempty"`
}

AllowedMentions is a allowlist of mentions for a message.

Allowlists

Roles and Users are slices that act as allowlists for IDs that are allowed to be mentioned. For example, if only 1 ID is provided in Users, then only that ID will be parsed in the message. No other IDs will be. The same example also applies for roles.

If Parse is an empty slice and both Users and Roles are empty slices, then no mentions will be parsed.

Constraints

If the Users slice is not empty, then Parse must not have AllowUserMention. Likewise, if the Roles slice is not empty, then Parse must not have AllowRoleMention. This is because everything provided in Parse will make Discord parse it completely, meaning they would be mutually exclusive with Roles and Users.

https://discord.com/developers/docs/resources/channel#allowed-mentions-object

func (AllowedMentions) Verify

func (am AllowedMentions) Verify() error

Verify checks the AllowedMentions against constraints mentioned in AllowedMentions' documentation. This will be called on SendMessageComplex.

type AuditLogData

type AuditLogData struct {
	// UserID filters the log for actions made by a user.
	UserID discord.UserID `schema:"user_id,omitempty"`
	// ActionType is the type of audit log event.
	ActionType discord.AuditLogEvent `schema:"action_type,omitempty"`
	// Before filters the log before a certain entry ID.
	Before discord.AuditLogEntryID `schema:"before,omitempty"`
	// Limit limits how many entries are returned (default 50, minimum 1,
	// maximum 100).
	Limit uint `schema:"limit"`
}

https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters

type AuditLogReason

type AuditLogReason string

AuditLogReason is the type embedded in data structs when the action performed by calling that api endpoint supports attaching a custom audit log reason.

func (AuditLogReason) Header

func (r AuditLogReason) Header() http.Header

Header returns a http.Header containing the reason, or nil if the reason is empty.

type AutocompleteChoices

type AutocompleteChoices interface {
	// contains filtered or unexported methods
}

AutocompleteChoices are the choices to send back to Discord when sending a ApplicationCommandAutocompleteResult interaction response.

The following types implement this interface:

  • AutocompleteStringChoices
  • AutocompleteIntegerChoices
  • AutocompleteNumberChoices

type AutocompleteIntegerChoices

type AutocompleteIntegerChoices []discord.IntegerChoice

AutocompleteIntegerChoices are integer choices to send back to Discord as autocomplete results.

type AutocompleteNumberChoices

type AutocompleteNumberChoices []discord.NumberChoice

AutocompleteNumberChoices are number choices to send back to Discord as autocomplete results.

type AutocompleteStringChoices

type AutocompleteStringChoices []discord.StringChoice

AutocompleteStringChoices are string choices to send back to Discord as autocomplete results.

type BanData

type BanData struct {
	// DeleteDays is the number of days to delete messages for (0-7).
	DeleteDays option.Uint `schema:"delete_message_days,omitempty"`

	AuditLogReason `schema:"-"`
}

https://discord.com/developers/docs/resources/guild#create-guild-ban-query-string-params

type BotData

type BotData struct {
	URL        string             `json:"url"`
	Shards     int                `json:"shards,omitempty"`
	StartLimit *SessionStartLimit `json:"session_start_limit"`
}

BotData contains the GatewayURL as well as extra metadata on how to shard bots.

type Client

type Client struct {
	*httputil.Client
	*Session
	AcquireOptions rate.AcquireOptions
}

func NewClient

func NewClient(token string) *Client

func NewCustomClient

func NewCustomClient(token string, httpClient *httputil.Client) *Client

func (*Client) Ack

func (c *Client) Ack(channelID discord.ChannelID, messageID discord.MessageID, ack *Ack) error

Ack marks the read state of a channel. This is undocumented. The method will write to the ack variable passed in. If this method is called asynchronously, then ack should be mutex guarded.

func (*Client) ActiveThreads

func (c *Client) ActiveThreads(guildID discord.GuildID) (*ActiveThreads, error)

ActiveThreads returns all the active threads in the guild, including public and private threads.

func (*Client) AddMember

func (c *Client) AddMember(
	guildID discord.GuildID, userID discord.UserID, data AddMemberData) (*discord.Member, error)

AddMember adds a user to the guild, provided you have a valid oauth2 access token for the user with the guilds.join scope. Returns a 201 Created with the guild member as the body, or 204 No Content if the user is already a member of the guild.

Fires a Guild Member Add Gateway event.

The Authorization header must be a Bot token (belonging to the same application used for authorization), and the bot must be a member of the guild with CREATE_INSTANT_INVITE permission.

func (*Client) AddRecipient

func (c *Client) AddRecipient(
	channelID discord.ChannelID, userID discord.UserID, accessToken, nickname string) error

AddRecipient adds a user to a group direct message. As accessToken is needed, clearly this endpoint should only be used for OAuth. AccessToken can be obtained with the "gdm.join" scope.

func (*Client) AddRole

func (c *Client) AddRole(
	guildID discord.GuildID,
	userID discord.UserID, roleID discord.RoleID, data AddRoleData) error

AddRole adds a role to a guild member.

Requires the MANAGE_ROLES permission.

func (*Client) AddThreadMember

func (c *Client) AddThreadMember(threadID discord.ChannelID, userID discord.UserID) error

AddThreadMember adds another member to a thread. Requires the ability to send messages in the thread. Also requires the thread is not archived.

Fires a Thread Members Update Gateway event.

func (*Client) AttachIntegration

func (c *Client) AttachIntegration(
	guildID discord.GuildID,
	integrationID discord.IntegrationID, integrationType discord.Service) error

AttachIntegration attaches an integration object from the current user to the guild.

Requires the MANAGE_GUILD permission.

Fires a Guild Integrations Update Gateway event.

func (*Client) AuditLog

func (c *Client) AuditLog(guildID discord.GuildID, data AuditLogData) (*discord.AuditLog, error)

AuditLog returns an audit log object for the guild.

Requires the VIEW_AUDIT_LOG permission.

func (*Client) Ban

func (c *Client) Ban(guildID discord.GuildID, userID discord.UserID, data BanData) error

Ban creates a guild ban, and optionally delete previous messages sent by the banned user.

Requires the BAN_MEMBERS permission.

Fires a Guild Ban Add Gateway event.

func (*Client) Bans

func (c *Client) Bans(guildID discord.GuildID) ([]discord.Ban, error)

Bans returns a list of ban objects for the users banned from this guild.

Requires the BAN_MEMBERS permission.

func (*Client) BatchEditCommandPermissions

func (c *Client) BatchEditCommandPermissions(
	appID discord.AppID, guildID discord.GuildID,
	data []BatchEditCommandPermissionsData) ([]discord.GuildCommandPermissions, error)

BatchEditCommandPermissions batch edits permissions for all commands in a guild. Up to 10 permission overwrites can be added for a command.

Existing permissions for the command will be overwritten in that guild. Deleting or renaming a command will permanently delete all permissions for that command.

func (*Client) BotURL

func (c *Client) BotURL() (*BotData, error)

BotURL fetches the Gateway URL along with extra metadata. The token passed in will NOT be prefixed with Bot.

func (*Client) BulkOverwriteCommands

func (c *Client) BulkOverwriteCommands(
	appID discord.AppID, commands []CreateCommandData) ([]discord.Command, error)

BulkOverwriteCommands takes a slice of application commands, overwriting existing commands that are registered globally for this application. Updates will be available in all guilds after 1 hour.

Commands that do not already exist will count toward daily application command create limits.

func (*Client) BulkOverwriteGuildCommands

func (c *Client) BulkOverwriteGuildCommands(
	appID discord.AppID,
	guildID discord.GuildID, commands []CreateCommandData) ([]discord.Command, error)

BulkOverwriteGuildCommands takes a slice of application commands, overwriting existing commands that are registered for the guild.

func (*Client) Channel

func (c *Client) Channel(channelID discord.ChannelID) (*discord.Channel, error)

Channel gets a channel by ID. Returns a channel object.

func (*Client) ChannelInvites

func (c *Client) ChannelInvites(channelID discord.ChannelID) ([]discord.Invite, error)

ChannelInvites returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels.

Requires the MANAGE_CHANNELS permission.

func (*Client) ChannelWebhooks

func (c *Client) ChannelWebhooks(channelID discord.ChannelID) ([]discord.Webhook, error)

ChannelWebhooks returns the webhooks of the channel with the given ID.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) Channels

func (c *Client) Channels(guildID discord.GuildID) ([]discord.Channel, error)

Channels returns a list of guild channel objects.

func (*Client) Command

func (c *Client) Command(
	appID discord.AppID, commandID discord.CommandID) (*discord.Command, error)

func (*Client) CommandPermissions

func (c *Client) CommandPermissions(
	appID discord.AppID, guildID discord.GuildID,
	commandID discord.CommandID) (*discord.GuildCommandPermissions, error)

CommandPermissions fetches command permissions for a specific command for the application in a guild.

func (*Client) Commands

func (c *Client) Commands(appID discord.AppID) ([]discord.Command, error)

func (*Client) CreateChannel

func (c *Client) CreateChannel(
	guildID discord.GuildID, data CreateChannelData) (*discord.Channel, error)

CreateChannel creates a new channel object for the guild.

Requires the MANAGE_CHANNELS permission. If setting permission overwrites, only permissions your bot has in the guild can be allowed/denied. Setting MANAGE_ROLES permission in channels is only possible for guild administrators. Returns the new channel object on success.

Fires a ChannelCreate Gateway event.

func (*Client) CreateCommand

func (c *Client) CreateCommand(
	appID discord.AppID, data CreateCommandData) (*discord.Command, error)

func (*Client) CreateEmoji

func (c *Client) CreateEmoji(
	guildID discord.GuildID, data CreateEmojiData) (*discord.Emoji, error)

CreateEmoji creates a new emoji in the guild. This endpoint requires MANAGE_EMOJIS. ContentType must be "image/jpeg", "image/png", or "image/gif". However, ContentType can also be automatically detected (though shouldn't be relied on).

Emojis and animated emojis have a maximum file size of 256kb.

func (*Client) CreateGuild

func (c *Client) CreateGuild(data CreateGuildData) (*discord.Guild, error)

CreateGuild creates a new guild. Returns a guild object on success. Fires a Guild Create Gateway event.

This endpoint can be used only by bots in less than 10 guilds.

func (*Client) CreateGuildCommand

func (c *Client) CreateGuildCommand(
	appID discord.AppID,
	guildID discord.GuildID, data CreateCommandData) (*discord.Command, error)

func (*Client) CreateInteractionFollowup deprecated

func (c *Client) CreateInteractionFollowup(
	appID discord.AppID, token string, data InteractionResponseData) (*discord.Message, error)

CreateInteractionFollowup creates a followup message for an interaction.

Deprecated: use FollowUpInteraction instead.

func (*Client) CreateInvite

func (c *Client) CreateInvite(
	channelID discord.ChannelID, data CreateInviteData) (*discord.Invite, error)

CreateInvite creates a new invite object for the channel. Only usable for guild channels.

Requires the CREATE_INSTANT_INVITE permission.

func (*Client) CreatePrivateChannel

func (c *Client) CreatePrivateChannel(recipientID discord.UserID) (*discord.Channel, error)

CreatePrivateChannel creates a new DM channel with a user.

func (*Client) CreateRole

func (c *Client) CreateRole(guildID discord.GuildID, data CreateRoleData) (*discord.Role, error)

CreateRole creates a new role for the guild.

Requires the MANAGE_ROLES permission.

Fires a Guild Role Create Gateway event.

func (*Client) CreateStageInstance

func (c *Client) CreateStageInstance(
	data CreateStageInstanceData) (*discord.StageInstance, error)

CreateStageInstance creates a new Stage instance associated to a Stage channel.

It requires the user to be a moderator of the Stage channel.

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(
	channelID discord.ChannelID, data CreateWebhookData) (*discord.Webhook, error)

CreateWebhook creates a new webhook.

Webhooks cannot be named "clyde".

Requires the MANAGE_WEBHOOKS permission.

func (*Client) CrosspostMessage

func (c *Client) CrosspostMessage(
	channelID discord.ChannelID, messageID discord.MessageID) (*discord.Message, error)

CrosspostMessage crossposts a message in a news channel to following channels. This endpoint requires the SEND_MESSAGES permission if the current user sent the message, or additionally the MANAGE_MESSAGES permission for all other messages.

func (*Client) CurrentApplication

func (c *Client) CurrentApplication() (*discord.Application, error)

CurrentApplication returns the current bot account's Discord application. It can be used to get the application ID.

func (*Client) DeleteAllReactions

func (c *Client) DeleteAllReactions(
	channelID discord.ChannelID, messageID discord.MessageID) error

DeleteAllReactions deletes all reactions on a message.

This endpoint requires the MANAGE_MESSAGES permission to be present on the current user.

Fires a Message Reaction Remove All Gateway event.

func (*Client) DeleteChannel

func (c *Client) DeleteChannel(
	channelID discord.ChannelID, reason AuditLogReason) error

DeleteChannel deletes a channel, or closes a private message. Requires the MANAGE_CHANNELS permission for the guild. Deleting a category does not delete its child channels: they will have their parent_id removed and a Channel Update Gateway event will fire for each of them.

Fires a Channel Delete Gateway event.

func (*Client) DeleteChannelPermission

func (c *Client) DeleteChannelPermission(
	channelID discord.ChannelID, overwriteID discord.Snowflake, reason AuditLogReason) error

DeleteChannelPermission deletes a channel permission overwrite for a user or role in a channel. Only usable for guild channels.

Requires the MANAGE_ROLES permission.

func (*Client) DeleteCommand

func (c *Client) DeleteCommand(appID discord.AppID, commandID discord.CommandID) error

func (*Client) DeleteEmoji

func (c *Client) DeleteEmoji(
	guildID discord.GuildID, emojiID discord.EmojiID, reason AuditLogReason) error

DeleteEmoji deletes the given emoji.

Requires the MANAGE_EMOJIS permission.

Fires a Guild Emojis Update Gateway event.

func (*Client) DeleteGuild

func (c *Client) DeleteGuild(id discord.GuildID) error

DeleteGuild deletes a guild permanently. The User must be owner.

Fires a Guild Delete Gateway event.

func (*Client) DeleteGuildCommand

func (c *Client) DeleteGuildCommand(
	appID discord.AppID, guildID discord.GuildID, commandID discord.CommandID) error

func (*Client) DeleteInteractionFollowup

func (c *Client) DeleteInteractionFollowup(
	appID discord.AppID, messageID discord.MessageID, token string) error

DeleteInteractionFollowup deletes a followup message for an interaction.

func (*Client) DeleteInteractionResponse

func (c *Client) DeleteInteractionResponse(appID discord.AppID, token string) error

DeleteInteractionResponse deletes the initial interaction response.

func (*Client) DeleteInvite

func (c *Client) DeleteInvite(code string, reason AuditLogReason) (*discord.Invite, error)

DeleteInvite deletes an invite.

Requires the MANAGE_CHANNELS permission on the channel this invite belongs to, or MANAGE_GUILD to remove any invite across the guild.

Fires an Invite Delete Gateway event.

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(
	channelID discord.ChannelID, messageID discord.MessageID, reason AuditLogReason) error

DeleteMessage delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission.

func (*Client) DeleteMessages

func (c *Client) DeleteMessages(
	channelID discord.ChannelID, messageIDs []discord.MessageID, reason AuditLogReason) error

DeleteMessages deletes multiple messages in a single request. This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission. This endpoint only works for bots.

This endpoint will not delete messages older than 2 weeks, and will fail if any message provided is older than that or if any duplicate message IDs are provided.

Because the underlying endpoint only supports a maximum of 100 message IDs per request, DeleteMessages will make a total of messageIDs/100 rounded up requests.

Fires a Message Delete Bulk Gateway event.

func (*Client) DeleteReactions

func (c *Client) DeleteReactions(
	channelID discord.ChannelID, messageID discord.MessageID, emoji discord.APIEmoji) error

DeleteReactions deletes all the reactions for a given emoji on a message.

This endpoint requires the MANAGE_MESSAGES permission to be present on the current user.

Fires a Message Reaction Remove Emoji Gateway event.

func (*Client) DeleteRelationship

func (c *Client) DeleteRelationship(userID discord.UserID) error

DeleteRelationship deletes the relationship between the current user and the given user.

func (*Client) DeleteRole

func (c *Client) DeleteRole(
	guildID discord.GuildID, roleID discord.RoleID, reason AuditLogReason) error

DeleteRole deletes a guild role.

Requires the MANAGE_ROLES permission.

func (*Client) DeleteScheduledEvent

func (c *Client) DeleteScheduledEvent(guildID discord.GuildID, eventID discord.EventID) error

DeleteScheduledEvent deletes a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event

func (*Client) DeleteStageInstance

func (c *Client) DeleteStageInstance(channelID discord.ChannelID, reason AuditLogReason) error

func (*Client) DeleteUserReaction

func (c *Client) DeleteUserReaction(
	channelID discord.ChannelID,
	messageID discord.MessageID, userID discord.UserID, emoji discord.APIEmoji) error

DeleteUserReaction deletes another user's reaction.

This endpoint requires the MANAGE_MESSAGES permission to be present on the current user.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(webhookID discord.WebhookID) error

DeleteWebhook deletes a webhook permanently.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) EditChannelPermission

func (c *Client) EditChannelPermission(
	channelID discord.ChannelID,
	overwriteID discord.Snowflake, data EditChannelPermissionData) error

EditChannelPermission edits the channel's permission overwrites for a user or role in a channel. Only usable for guild channels.

Requires the MANAGE_ROLES permission.

func (*Client) EditCommand

func (c *Client) EditCommand(
	appID discord.AppID,
	commandID discord.CommandID, data CreateCommandData) (*discord.Command, error)

func (*Client) EditCommandPermissions

func (c *Client) EditCommandPermissions(
	appID discord.AppID, guildID discord.GuildID, commandID discord.CommandID,
	permissions []discord.CommandPermissions) (*discord.GuildCommandPermissions, error)

EditCommandPermissions edits command permissions for a specific command for the application in a guild. Up to 10 permission overwrites can be added for a command.

Existing permissions for the command will be overwritten in that guild. Deleting or renaming a command will permanently delete all permissions for that command.

func (*Client) EditEmbeds

func (c *Client) EditEmbeds(
	channelID discord.ChannelID,
	messageID discord.MessageID, embeds ...discord.Embed) (*discord.Message, error)

EditEmbeds edits the embed of a previously sent message. For more documentation, refer to EditMessageComplex.

func (*Client) EditGuildCommand

func (c *Client) EditGuildCommand(
	appID discord.AppID, guildID discord.GuildID,
	commandID discord.CommandID, data CreateCommandData) (*discord.Command, error)

func (*Client) EditInteractionFollowup

func (c *Client) EditInteractionFollowup(
	appID discord.AppID, messageID discord.MessageID,
	token string, data EditInteractionResponseData) (*discord.Message, error)

func (*Client) EditInteractionResponse

func (c *Client) EditInteractionResponse(
	appID discord.AppID,
	token string, data EditInteractionResponseData) (*discord.Message, error)

EditInteractionResponse edits the initial Interaction response.

func (*Client) EditMessage

func (c *Client) EditMessage(
	channelID discord.ChannelID, messageID discord.MessageID,
	content string, embeds ...discord.Embed) (*discord.Message, error)

EditMessage edits a previously sent message. If content or embeds are empty the original content or embed will remain untouched. This means EditMessage will only update, but not remove parts of the message.

For more documentation, refer to EditMessageComplex.

func (*Client) EditMessageComplex

func (c *Client) EditMessageComplex(
	channelID discord.ChannelID,
	messageID discord.MessageID, data EditMessageData) (*discord.Message, error)

EditMessageComplex edits a previously sent message. The fields Content, Embed, AllowedMentions and Flags can be edited by the original message author. Other users can only edit flags and only if they have the MANAGE_MESSAGES permission in the corresponding channel. When specifying flags, ensure to include all previously set flags/bits in addition to ones that you are modifying. Only flags documented in EditMessageData may be modified by users (unsupported flag changes are currently ignored without error).

Fires a Message Update Gateway event.

func (*Client) EditScheduledEvent

func (c *Client) EditScheduledEvent(guildID discord.GuildID, eventID discord.EventID, reason AuditLogReason,
	data EditScheduledEventData) (*discord.GuildScheduledEvent, error)

EditScheduledEvent modifies the attributes of a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event

func (*Client) EditText

func (c *Client) EditText(
	channelID discord.ChannelID,
	messageID discord.MessageID, content string) (*discord.Message, error)

EditText edits the contents of a previously sent message. For more documentation, refer to EditMessageComplex.

func (*Client) Emoji

func (c *Client) Emoji(guildID discord.GuildID, emojiID discord.EmojiID) (*discord.Emoji, error)

Emoji returns an emoji object for the given guild and emoji IDs.

func (*Client) Emojis

func (c *Client) Emojis(guildID discord.GuildID) ([]discord.Emoji, error)

Emojis returns a list of emoji objects for the given guild.

func (*Client) FollowUpInteraction added in v3.1.0

func (c *Client) FollowUpInteraction(
	appID discord.AppID, token string, data InteractionResponseData) (*discord.Message, error)

FollowUpInteraction creates a followup message for an interaction.

func (*Client) GetBan

func (c *Client) GetBan(guildID discord.GuildID, userID discord.UserID) (*discord.Ban, error)

GetBan returns a ban object for the given user.

Requires the BAN_MEMBERS permission.

func (*Client) Guild

func (c *Client) Guild(id discord.GuildID) (*discord.Guild, error)

Guild returns the guild object for the given id.

ApproximateMembers and ApproximatePresences will not be set.

func (*Client) GuildCommand

func (c *Client) GuildCommand(
	appID discord.AppID,
	guildID discord.GuildID, commandID discord.CommandID) (*discord.Command, error)

func (*Client) GuildCommandPermissions

func (c *Client) GuildCommandPermissions(
	appID discord.AppID, guildID discord.GuildID) ([]discord.GuildCommandPermissions, error)

GuildCommandPermissions fetches command permissions for all commands for the application in a guild.

func (*Client) GuildCommands

func (c *Client) GuildCommands(
	appID discord.AppID, guildID discord.GuildID) ([]discord.Command, error)

func (*Client) GuildInvites

func (c *Client) GuildInvites(guildID discord.GuildID) ([]discord.Invite, error)

GuildInvites returns a list of invite objects (with invite metadata) for the guild.

Requires the MANAGE_GUILD permission.

func (*Client) GuildPreview

func (c *Client) GuildPreview(id discord.GuildID) (*discord.GuildPreview, error)

GuildPreview returns the guild preview object for the given id, even if the user is not in the guild.

This endpoint is only for public guilds.

func (*Client) GuildVanityInvite

func (c *Client) GuildVanityInvite(guildID discord.GuildID) (*discord.Invite, error)

GuildVanityInvite returns the vanity invite for guilds that have that feature enabled. Only Code and Uses are filled. Code will be "" if a vanity url for the guild is not set.

Requires MANAGE_GUILD.

func (*Client) GuildWebhooks

func (c *Client) GuildWebhooks(guildID discord.GuildID) ([]discord.Webhook, error)

GuildWebhooks returns the webhooks of the guild with the given ID.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) GuildWidget

func (c *Client) GuildWidget(guildID discord.GuildID) (*discord.GuildWidget, error)

GuildWidget returns the widget for the guild.

func (*Client) GuildWidgetImage

func (c *Client) GuildWidgetImage(
	guildID discord.GuildID, img GuildWidgetImageStyle) (io.ReadCloser, error)

GuildWidgetImage returns a PNG image widget for the guild. Requires no permissions or authentication.

func (*Client) GuildWidgetImageURL

func (c *Client) GuildWidgetImageURL(guildID discord.GuildID, img GuildWidgetImageStyle) string

GuildWidgetImageURL returns a link to the PNG image widget for the guild.

Requires no permissions or authentication.

func (*Client) GuildWidgetSettings

func (c *Client) GuildWidgetSettings(
	guildID discord.GuildID) (*discord.GuildWidgetSettings, error)

GuildWidgetSettings returns the guild widget object.

Requires the MANAGE_GUILD permission.

func (*Client) GuildWithCount

func (c *Client) GuildWithCount(id discord.GuildID) (*discord.Guild, error)

GuildWithCount returns the guild object for the given id. This will also set the ApproximateMembers and ApproximatePresences fields of the guild struct.

func (*Client) Guilds

func (c *Client) Guilds(limit uint) ([]discord.Guild, error)

Guilds returns a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all guilds the user has joined.

As the underlying endpoint has a maximum of 100 guilds per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

When fetching the guilds, those with the smallest ID will be fetched first.

Also note that 100 is the maximum number of guilds a non-bot user can join. Therefore, pagination is not needed for integrations that need to get a list of the users' guilds.

Requires the guilds OAuth2 scope.

func (*Client) GuildsAfter

func (c *Client) GuildsAfter(after discord.GuildID, limit uint) ([]discord.Guild, error)

GuildsAfter returns a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all guilds with an id higher than after.

As the underlying endpoint has a maximum of 100 guilds per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

Requires the guilds OAuth2 scope.

func (*Client) GuildsBefore

func (c *Client) GuildsBefore(before discord.GuildID, limit uint) ([]discord.Guild, error)

GuildsBefore returns a list of partial guild objects the current user is a member of. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all guilds with an id smaller than before.

As the underlying endpoint has a maximum of 100 guilds per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

Requires the guilds OAuth2 scope.

func (*Client) InjectRequest

func (c *Client) InjectRequest(r httpdriver.Request) error

func (*Client) Integrations

func (c *Client) Integrations(guildID discord.GuildID) ([]discord.Integration, error)

Integrations returns a list of integration objects for the guild.

Requires the MANAGE_GUILD permission.

func (*Client) InteractionResponse

func (c *Client) InteractionResponse(
	appID discord.AppID, token string) (*discord.Message, error)

InteractionResponse returns the initial interaction response.

func (*Client) Invite

func (c *Client) Invite(code string) (*discord.Invite, error)

Invite returns an invite object for the given code.

ApproxMembers will not get filled.

func (*Client) InviteWithCounts

func (c *Client) InviteWithCounts(code string) (*discord.Invite, error)

InviteWithCounts returns an invite object for the given code and fills ApproxMembers.

func (*Client) JoinInvite

func (c *Client) JoinInvite(code string) (*JoinedInvite, error)

JoinInvite joins a guild using the given invite code. This endpoint is undocumented.

func (*Client) JoinThread

func (c *Client) JoinThread(threadID discord.ChannelID) error

JoinThread adds the current user to a thread. Also requires the thread is not archived.

Fires a Thread Members Update Gateway event.

func (*Client) JoinedPrivateArchivedThreads added in v3.2.0

func (c *Client) JoinedPrivateArchivedThreads(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

JoinedPrivateArchivedThreads returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined.

Threads are ordered by their ID, in descending order.

Requires the READ_MESSAGE_HISTORY permission

func (*Client) JoinedPrivateArchivedThreadsBefore deprecated

func (c *Client) JoinedPrivateArchivedThreadsBefore(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

JoinedPrivateArchivedThreadsBefore returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined.

Deprecated: Use JoinedPrivateArchivedThreads instead.

func (*Client) Kick

func (c *Client) Kick(
	guildID discord.GuildID, userID discord.UserID, reason AuditLogReason) error

Kick removes a member from a guild.

Requires KICK_MEMBERS permission.

Fires a Guild Member Remove Gateway event.

func (*Client) LeaveGuild

func (c *Client) LeaveGuild(id discord.GuildID) error

LeaveGuild leaves a guild.

func (*Client) LeaveThread

func (c *Client) LeaveThread(threadID discord.ChannelID) error

LeaveThread removes the current user from a thread. Also requires the thread is not archived.

Fires a Thread Members Update Gateway event.

func (*Client) ListScheduledEventUsers

func (c *Client) ListScheduledEventUsers(
	guildID discord.GuildID, eventID discord.EventID, limit option.NullableInt,
	withMember bool, before, after discord.UserID) ([]GuildScheduledEventUser, error)

ListScheduledEventUsers returns a list of users currently in a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users

func (*Client) ListScheduledEvents

func (c *Client) ListScheduledEvents(guildID discord.GuildID, withUserCount bool) ([]discord.GuildScheduledEvent, error)

ListScheduledEvents lists the scheduled events in a guild.

https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users

func (*Client) Login

func (c *Client) Login(email, password string) (*LoginResponse, error)

func (*Client) Me

func (c *Client) Me() (*discord.User, error)

Me returns the user object of the requester's account. For OAuth2, this requires the identify scope, which will return the object without an email, and optionally the email scope, which returns the object with an email.

func (*Client) Member

func (c *Client) Member(guildID discord.GuildID, userID discord.UserID) (*discord.Member, error)

Member returns a guild member object for the specified user.

func (*Client) Members

func (c *Client) Members(guildID discord.GuildID, limit uint) ([]discord.Member, error)

Members returns a list of members of the guild with the passed id. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all members in the guild.

As the underlying endpoint has a maximum of 1000 members per request, at maximum a total of limit/1000 rounded up requests will be made, although they may be less if no more members are available.

When fetching the members, those with the smallest ID will be fetched first.

func (*Client) MembersAfter

func (c *Client) MembersAfter(
	guildID discord.GuildID, after discord.UserID, limit uint) ([]discord.Member, error)

MembersAfter returns a list of members of the guild with the passed id. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all members with an id higher than after.

As the underlying endpoint has a maximum of 1000 members per request, at maximum a total of limit/1000 rounded up requests will be made, although they may be less, if no more members are available.

func (*Client) Message

func (c *Client) Message(
	channelID discord.ChannelID, messageID discord.MessageID) (*discord.Message, error)

Message returns a specific message in the channel.

If operating on a guild channel, this endpoint requires the READ_MESSAGE_HISTORY permission to be present on the current user.

func (*Client) Messages

func (c *Client) Messages(channelID discord.ChannelID, limit uint) ([]discord.Message, error)

Messages returns a slice filled with the most recent messages sent in the channel with the passed ID. The method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all messages in the channel.

As the underlying endpoint is capped at a maximum of 100 messages per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more messages are available.

When fetching the messages, those with the highest ID, will be fetched first. The returned slice will be sorted from latest to oldest.

func (*Client) MessagesAfter

func (c *Client) MessagesAfter(
	channelID discord.ChannelID, after discord.MessageID, limit uint) ([]discord.Message, error)

MessagesAfter returns a slice filled with the messages sent in the channel with the passed ID. The method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all messages in the channel with an id higher than after.

As the underlying endpoint has a maximum of 100 messages per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more messages are available.

The returned slice will be sorted from latest to oldest.

func (*Client) MessagesAround

func (c *Client) MessagesAround(
	channelID discord.ChannelID, around discord.MessageID, limit uint) ([]discord.Message, error)

MessagesAround returns messages around the ID, with a limit of 100.

func (*Client) MessagesBefore

func (c *Client) MessagesBefore(
	channelID discord.ChannelID, before discord.MessageID, limit uint) ([]discord.Message, error)

MessagesBefore returns a slice filled with the messages sent in the channel with the passed id. The method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all messages in the channel with an id smaller than before.

As the underlying endpoint has a maximum of 100 messages per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more messages are available.

The returned slice will be sorted from latest to oldest.

func (*Client) ModifyChannel

func (c *Client) ModifyChannel(channelID discord.ChannelID, data ModifyChannelData) error

ModifyChannel updates a channel's settings.

If modifying a guild channel, requires the MANAGE_CHANNELS permission for that guild. If modifying a thread, requires the MANAGE_THREADS permission. Furthermore, if modifying permission overwrites, the MANAGE_ROLES permission is required. Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel).

Fires a Channel Update event when modifying a guild channel, and a Thread Update event when modifying a thread.

func (*Client) ModifyCurrentMember

func (c *Client) ModifyCurrentMember(
	guildID discord.GuildID, nick string) error

ModifyCurrentMember modifies the nickname of the current user in a guild.

Fires a Guild Member Update Gateway event.

func (*Client) ModifyCurrentUser

func (c *Client) ModifyCurrentUser(data ModifyCurrentUserData) (*discord.User, error)

ModifyCurrentUser modifies the requester's user account settings.

func (*Client) ModifyEmoji

func (c *Client) ModifyEmoji(
	guildID discord.GuildID, emojiID discord.EmojiID, data ModifyEmojiData) error

ModifyEmoji changes an existing emoji. This requires MANAGE_EMOJIS. Name and roles are optional fields (though you'd want to change either though).

Fires a Guild Emojis Update Gateway event.

func (*Client) ModifyGuild

func (c *Client) ModifyGuild(id discord.GuildID, data ModifyGuildData) (*discord.Guild, error)

ModifyGuild modifies a guild's settings.

Requires the MANAGE_GUILD permission.

Fires a Guild Update Gateway event.

func (*Client) ModifyGuildWidget

func (c *Client) ModifyGuildWidget(
	guildID discord.GuildID, data ModifyGuildWidgetData) (*discord.GuildWidgetSettings, error)

ModifyGuildWidget modifies a guild widget object for the guild.

Requires the MANAGE_GUILD permission.

func (*Client) ModifyIntegration

func (c *Client) ModifyIntegration(
	guildID discord.GuildID,
	integrationID discord.IntegrationID, data ModifyIntegrationData) error

ModifyIntegration modifies the behavior and settings of an integration object for the guild.

Requires the MANAGE_GUILD permission. Fires a Guild Integrations Update Gateway event.

func (*Client) ModifyMember

func (c *Client) ModifyMember(
	guildID discord.GuildID, userID discord.UserID, data ModifyMemberData) error

ModifyMember modifies attributes of a guild member. If the channel_id is set to null, this will force the target user to be disconnected from voice.

Fires a Guild Member Update Gateway event.

func (*Client) ModifyRole

func (c *Client) ModifyRole(
	guildID discord.GuildID, roleID discord.RoleID, data ModifyRoleData) (*discord.Role, error)

ModifyRole modifies a guild role.

Requires the MANAGE_ROLES permission.

func (*Client) ModifyWebhook

func (c *Client) ModifyWebhook(
	webhookID discord.WebhookID, data ModifyWebhookData) (*discord.Webhook, error)

ModifyWebhook modifies a webhook.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) MoveChannels

func (c *Client) MoveChannels(guildID discord.GuildID, data MoveChannelsData) error

MoveChannels modifies the position of channels in the guild.

Requires MANAGE_CHANNELS.

Fires multiple Channel Update Gateway events.

func (*Client) MoveRoles

func (c *Client) MoveRoles(guildID discord.GuildID, data MoveRolesData) ([]discord.Role, error)

MoveRoles modifies the positions of a set of role objects for the guild.

Requires the MANAGE_ROLES permission.

Fires multiple Guild Role Update Gateway events.

func (*Client) Note

func (c *Client) Note(userID discord.UserID) (string, error)

Note gets the note for the given user. This endpoint is undocumented and might only work for user accounts.

func (*Client) OnResponse

func (c *Client) OnResponse(r httpdriver.Request, resp httpdriver.Response) error

func (*Client) PinMessage

func (c *Client) PinMessage(
	channelID discord.ChannelID, messageID discord.MessageID, reason AuditLogReason) error

PinMessage pins a message in a channel.

Requires the MANAGE_MESSAGES permission.

func (*Client) PinnedMessages

func (c *Client) PinnedMessages(channelID discord.ChannelID) ([]discord.Message, error)

PinnedMessages returns all pinned messages in the channel as an array of message objects.

func (*Client) PrivateArchivedThreads added in v3.2.0

func (c *Client) PrivateArchivedThreads(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

PrivateArchivedThreads returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD.

Threads are ordered by ArchiveTimestamp, in descending order.

Requires both the READ_MESSAGE_HISTORY and MANAGE_THREADS permissions.

func (*Client) PrivateArchivedThreadsBefore deprecated

func (c *Client) PrivateArchivedThreadsBefore(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

PrivateArchivedThreadsBefore returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD.

Deprecated: Use PrivateArchivedThreads instead.

func (*Client) PrivateChannels

func (c *Client) PrivateChannels() ([]discord.Channel, error)

PrivateChannels returns a list of DM channel objects. For bots, this is no longer a supported method of getting recent DMs, and will return an empty array.

func (*Client) Prune

func (c *Client) Prune(guildID discord.GuildID, data PruneData) (uint, error)

Prune begins a prune. Days must be 1 or more, default 7.

By default, prune will not remove users with roles. You can optionally include specific roles in your prune by providing the IncludedRoles parameter. Any inactive user that has a subset of the provided role(s) will be included in the prune and users with additional roles will not.

Requires KICK_MEMBERS.

Fires multiple Guild Member Remove Gateway events.

func (*Client) PruneCount

func (c *Client) PruneCount(guildID discord.GuildID, data PruneCountData) (uint, error)

PruneCount returns the number of members that would be removed in a prune operation. Days must be 1 or more, default 7.

By default, prune will not remove users with roles. You can optionally include specific roles in your prune by providing the IncludedRoles parameter. Any inactive user that has a subset of the provided role(s) will be counted in the prune and users with additional roles will not.

Requires KICK_MEMBERS.

func (*Client) PublicArchivedThreads added in v3.2.0

func (c *Client) PublicArchivedThreads(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

PublicArchivedThreads returns archived threads in the channel that are public.

When called on a GUILD_TEXT channel, returns threads of type GUILD_PUBLIC_THREAD. When called on a GUILD_NEWS channel returns threads of type GUILD_NEWS_THREAD.

Threads are ordered by ArchiveTimestamp, in descending order.

Requires the READ_MESSAGE_HISTORY permission.

func (*Client) PublicArchivedThreadsBefore deprecated

func (c *Client) PublicArchivedThreadsBefore(
	channelID discord.ChannelID,
	before discord.Timestamp, limit uint) (*ArchivedThreads, error)

PublicArchivedThreadsBefore returns archived threads in the channel that are public.

Deprecated: Use PublicArchivedThreads instead.

func (*Client) React

func (c *Client) React(
	channelID discord.ChannelID, messageID discord.MessageID, emoji discord.APIEmoji) error

React creates a reaction for the message.

This endpoint requires the READ_MESSAGE_HISTORY permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the 'ADD_REACTIONS' permission to be present on the current user.

func (*Client) Reactions

func (c *Client) Reactions(
	channelID discord.ChannelID,
	messageID discord.MessageID, emoji discord.APIEmoji, limit uint) ([]discord.User, error)

Reactions returns a list of users that reacted with the passed Emoji. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all users within the passed range.

As the underlying endpoint has a maximum of 100 users per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

When fetching the users, those with the smallest ID will be fetched first.

func (*Client) ReactionsAfter

func (c *Client) ReactionsAfter(
	channelID discord.ChannelID, messageID discord.MessageID,
	after discord.UserID, emoji discord.APIEmoji, limit uint) ([]discord.User, error)

ReactionsAfter returns a list of users that reacted with the passed Emoji. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all users with an id higher than after.

As the underlying endpoint has a maximum of 100 users per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

func (*Client) ReactionsBefore

func (c *Client) ReactionsBefore(
	channelID discord.ChannelID, messageID discord.MessageID,
	before discord.UserID, emoji discord.APIEmoji, limit uint) ([]discord.User, error)

ReactionsBefore returns a list of users that reacted with the passed Emoji. This method automatically paginates until it reaches the passed limit, or, if the limit is set to 0, has fetched all users with an id smaller than before.

As the underlying endpoint has a maximum of 100 users per request, at maximum a total of limit/100 rounded up requests will be made, although they may be less, if no more guilds are available.

func (*Client) RemoveRecipient

func (c *Client) RemoveRecipient(channelID discord.ChannelID, userID discord.UserID) error

RemoveRecipient removes a user from a group direct message.

func (*Client) RemoveRole

func (c *Client) RemoveRole(
	guildID discord.GuildID,
	userID discord.UserID, roleID discord.RoleID, reason AuditLogReason) error

RemoveRole removes a role from a guild member.

Requires the MANAGE_ROLES permission.

Fires a Guild Member Update Gateway event.

func (*Client) RemoveThreadMember

func (c *Client) RemoveThreadMember(threadID discord.ChannelID, userID discord.UserID) error

RemoveThreadMember removes another member from a thread. Requires the MANAGE_THREADS permission, or the creator of the thread if it is a discord.GuildPrivateThread. Also requires the thread is not archived.

Fires a Thread Members Update Gateway event.

func (*Client) RespondInteraction

func (c *Client) RespondInteraction(
	id discord.InteractionID, token string, resp InteractionResponse) error

RespondInteraction responds to an incoming interaction. It is also known as an "interaction callback".

func (*Client) Roles

func (c *Client) Roles(guildID discord.GuildID) ([]discord.Role, error)

Roles returns a list of role objects for the guild.

func (*Client) ScheduledEvent

func (c *Client) ScheduledEvent(guildID discord.GuildID, eventID discord.EventID, withUserCount bool) (*discord.GuildScheduledEvent, error)

ScheduledEvent retrieves the information on the scheduled event

https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event

func (*Client) Search

func (c *Client) Search(guildID discord.GuildID, data SearchData) (SearchResponse, error)

Search searches through a guild's messages. It only works for user accounts.

func (*Client) SendEmbedReply

func (c *Client) SendEmbedReply(
	channelID discord.ChannelID,
	referenceID discord.MessageID, embeds ...discord.Embed) (*discord.Message, error)

SendEmbedReply posts an Embed reply to a message ID in a guild text or DM channel.

If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.

Fires a Message Create Gateway event.

func (*Client) SendEmbeds

func (c *Client) SendEmbeds(
	channelID discord.ChannelID, e ...discord.Embed) (*discord.Message, error)

SendEmbeds sends embeds to a guild text or DM channel.

If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.

Fires a Message Create Gateway event.

func (*Client) SendMessage

func (c *Client) SendMessage(
	channelID discord.ChannelID,
	content string, embeds ...discord.Embed) (*discord.Message, error)

SendMessage posts a message to a guild text or DM channel.

If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.

Fires a Message Create Gateway event.

func (*Client) SendMessageComplex

func (c *Client) SendMessageComplex(
	channelID discord.ChannelID, data SendMessageData) (*discord.Message, error)

SendMessageComplex posts a message to a guild text or DM channel. If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user. If the tts field is set to true, the SEND_TTS_MESSAGES permission is required for the message to be spoken. Returns a message object. Fires a Message Create Gateway event.

The maximum request size when sending a message is 8MB.

This endpoint supports requests with Content-Types of both application/json and multipart/form-data. You must however use multipart/form-data when uploading files. Note that when sending multipart/form-data requests the embed field cannot be used, however you can pass a JSON encoded body as form value for payload_json, where additional request parameters such as embed can be set.

Note that when sending application/json you must send at least one of content or embed, and when sending multipart/form-data, you must send at least one of content, embed or file. For a file attachment, the Content-Disposition subpart header MUST contain a filename parameter.

func (*Client) SendMessageReply

func (c *Client) SendMessageReply(
	channelID discord.ChannelID, content string,
	referenceID discord.MessageID, embeds ...discord.Embed) (*discord.Message, error)

SendMessageReply posts a reply to a message ID in a guild text or DM channel.

If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.

Fires a Message Create Gateway event.

func (*Client) SendTextReply

func (c *Client) SendTextReply(
	channelID discord.ChannelID,
	content string, referenceID discord.MessageID) (*discord.Message, error)

SendTextReply posts a text-only reply to a message ID in a guild text or DM channel

If operating on a guild channel, this endpoint requires the SEND_MESSAGES permission to be present on the current user.

Fires a Message Create Gateway event.

func (*Client) SetNote

func (c *Client) SetNote(userID discord.UserID, note string) error

SetNote sets a note for the user. This endpoint is undocumented and might only work for user accounts.

func (*Client) SetRelationship

func (c *Client) SetRelationship(userID discord.UserID, t discord.RelationshipType) error

SetRelationship sets the relationship type between the current user and the given user.

func (*Client) StartThreadWithMessage

func (c *Client) StartThreadWithMessage(
	channelID discord.ChannelID,
	messageID discord.MessageID, data StartThreadData) (*discord.Channel, error)

StartThreadWithMessage creates a new thread from an existing message.

When called on a GUILD_TEXT channel, creates a GUILD_PUBLIC_THREAD. When called on a GUILD_NEWS channel, creates a GUILD_NEWS_THREAD. The id of the created thread will be the same as the id of the message, and as such a message can only have a single thread created from it.

Fires a Thread Create Gateway event.

func (*Client) StartThreadWithoutMessage

func (c *Client) StartThreadWithoutMessage(
	channelID discord.ChannelID, data StartThreadData) (*discord.Channel, error)

StartThreadWithoutMessage creates a new thread that is not connected to an existing message.

Fires a Thread Create Gateway event.

func (*Client) SyncIntegration

func (c *Client) SyncIntegration(
	guildID discord.GuildID, integrationID discord.IntegrationID) error

SyncIntegration syncs an integration.

Requires the MANAGE_GUILD permission.

func (*Client) TOTP

func (c *Client) TOTP(code, ticket string) (*LoginResponse, error)

func (*Client) ThreadMember added in v3.3.6

func (c *Client) ThreadMember(
	threadID discord.ChannelID, userID discord.UserID) (*discord.ThreadMember, error)

ThreadMember returns a thread member for the user ID if the user is a member of the thread.

func (*Client) ThreadMembers

func (c *Client) ThreadMembers(threadID discord.ChannelID) ([]discord.ThreadMember, error)

ThreadMembers list all members of the thread.

This endpoint is restricted according to whether the GUILD_MEMBERS Privileged Intent is enabled for your application.

func (*Client) Typing

func (c *Client) Typing(channelID discord.ChannelID) error

Typing posts a typing indicator to the channel. Undocumented, but the client usually clears the typing indicator after 8-10 seconds (or after a message).

func (*Client) Unban

func (c *Client) Unban(
	guildID discord.GuildID, userID discord.UserID, reason AuditLogReason) error

Unban removes the ban for a user.

Requires the BAN_MEMBERS permissions.

Fires a Guild Ban Remove Gateway event.

func (*Client) UnpinMessage

func (c *Client) UnpinMessage(
	channelID discord.ChannelID, messageID discord.MessageID, reason AuditLogReason) error

UnpinMessage deletes a pinned message in a channel.

Requires the MANAGE_MESSAGES permission.

func (*Client) Unreact

func (c *Client) Unreact(
	channelID discord.ChannelID, messageID discord.MessageID, emoji discord.APIEmoji) error

Unreact removes a reaction the current user has made for the message.

func (*Client) UpdateStageInstance

func (c *Client) UpdateStageInstance(
	channelID discord.ChannelID, data UpdateStageInstanceData) error

UpdateStageInstance updates fields of an existing Stage instance.

It requires the user to be a moderator of the Stage channel.

func (*Client) User

func (c *Client) User(userID discord.UserID) (*discord.User, error)

User returns a user object for a given user ID.

func (*Client) UserConnections

func (c *Client) UserConnections() ([]discord.Connection, error)

UserConnections returns a list of connection objects. Requires the connections OAuth2 scope.

func (*Client) VoiceRegionsGuild

func (c *Client) VoiceRegionsGuild(guildID discord.GuildID) ([]discord.VoiceRegion, error)

VoiceRegionsGuild is the same as /voice, but returns VIP ones as well if available.

func (*Client) Webhook

func (c *Client) Webhook(webhookID discord.WebhookID) (*discord.Webhook, error)

Webhook returns the webhook with the given id.

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

WithContext returns a shallow copy of Client with the given context. It's used for method timeouts and such. This method is thread-safe.

func (*Client) WithLocale

func (c *Client) WithLocale(language discord.Language) *Client

WithLocale creates a copy of Client with an explicitly stated language locale using the X-Discord-Locale HTTP header.

type CreateChannelData

type CreateChannelData struct {
	// Name is the channel name (2-100 characters).
	//
	// Channel Type: All
	Name string `json:"name"`
	// Type is the type of channel.
	//
	// Channel Type: All
	Type discord.ChannelType `json:"type,omitempty"`
	// Topic is the channel topic (0-1024 characters).
	//
	// Channel Types: Text, News
	Topic string `json:"topic,omitempty"`
	// Flags is a bitmask that contains if a thread is pinned for example
	Flags discord.ChannelFlags `json:"flags,omitempty"`
	// VoiceBitrate is the bitrate (in bits) of the voice channel.
	// 8000 to 96000 (128000 for VIP servers)
	//
	// Channel Types: Voice
	VoiceBitrate uint `json:"bitrate,omitempty"`
	// VoiceUserLimit is the user limit of the voice channel.
	// 0 refers to no limit, 1 to 99 refers to a user limit.
	//
	// Channel Types: Voice
	VoiceUserLimit uint `json:"user_limit,omitempty"`
	// UserRateLimit is the amount of seconds a user has to wait before sending
	// another message (0-21600).
	// Bots, as well as users with the permission manage_messages or
	// manage_channel, are unaffected.
	//
	// Channel Types: Text
	UserRateLimit discord.Seconds `json:"rate_limit_per_user,omitempty"`
	// Position is the sorting position of the channel.
	//
	// Channel Types: All
	Position option.Int `json:"position,omitempty"`
	// Overwrites are the channel's permission overwrites.
	//
	// Channel Types: All
	Overwrites []discord.Overwrite `json:"permission_overwrites,omitempty"`
	// CategoryID is the 	id of the parent category for a channel.
	//
	// Channel Types: Text, News, Store, Voice
	CategoryID discord.ChannelID `json:"parent_id,string,omitempty"`
	// NSFW specifies whether the channel is nsfw.
	//
	// Channel Types: Text, News, Store
	NSFW bool `json:"nsfw,omitempty"`
	// RTCRegionID is the channel voice region id. It will be determined
	// automatically set, if omitted.
	//
	// Channel Types: Voice
	RTCRegionID string `json:"rtc_region,omitempty"`
	// VideoQualityMode is the camera video quality mode of the voice channel.
	// This defaults to discord.AutoVideoQuality, if not set.
	//
	// ChannelTypes: Voice
	VoiceQualityMode discord.VideoQualityMode `json:"voice_quality_mode,omitempty"`

	AvailableTags        []discord.Tag          `json:"available_tags,omitempty"`
	DefaultReactionEmoji *discord.ForumReaction `json:"default_reaction_emoji,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/guild#create-guild-channel-json-params

type CreateCommandData

type CreateCommandData struct {
	ID                       discord.CommandID      `json:"id,omitempty"`
	Name                     string                 `json:"name"`
	NameLocalizations        discord.StringLocales  `json:"name_localizations,omitempty"`
	Description              string                 `json:"description"`
	DescriptionLocalizations discord.StringLocales  `json:"description_localizations,omitempty"`
	Options                  discord.CommandOptions `json:"options,omitempty"`
	DefaultMemberPermissions *discord.Permissions   `json:"default_member_permissions,string,omitempty"`
	NoDMPermission           bool                   `json:"-"`
	NoDefaultPermission      bool                   `json:"-"`
	Type                     discord.CommandType    `json:"type,omitempty"`
}

https://discord.com/developers/docs/interactions/application-commands#create-global-application-command https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands

func (CreateCommandData) MarshalJSON

func (c CreateCommandData) MarshalJSON() ([]byte, error)

func (*CreateCommandData) UnmarshalJSON

func (c *CreateCommandData) UnmarshalJSON(data []byte) error

type CreateEmojiData

type CreateEmojiData struct {
	// Name is the name of the emoji.
	Name string `json:"name"`
	// Image is the the 128x128 emoji image.
	Image Image `json:"image"`
	// Roles are the roles that can use the emoji.
	Roles *[]discord.RoleID `json:"roles,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params

type CreateGuildData

type CreateGuildData struct {
	// Name is the 	name of the guild (2-100 characters)
	Name string `json:"name"`
	// VoiceRegion is the voice region id.
	VoiceRegion string `json:"region,omitempty"`
	// Icon is the base64 128x128 image for the guild icon.
	Icon *Image `json:"image,omitempty"`

	// Verification is the 	verification level.
	Verification *discord.Verification `json:"verification_level,omitempty"`
	// Notification is the 	default message notification level.
	Notification *discord.Notification `json:"default_message_notifications,omitempty"`
	// ExplicitFilter is the explicit content filter level.
	ExplicitFilter *discord.ExplicitFilter `json:"explicit_content_filter,omitempty"`

	// Roles are the new guild roles.
	//
	// When using the roles parameter, the first member of the array is used to
	// change properties of the guild's @everyone role. If you are trying to
	// bootstrap a guild with additional roles, keep this in mind.
	//
	// When using the roles parameter, the required id field within each role
	// object is an integer placeholder, and will be replaced by the API upon
	// consumption. Its purpose is to allow you to overwrite a role's
	// permissions in a channel when also passing in channels with the channels
	// array.
	Roles []discord.Role `json:"roles,omitempty"`
	// Channels are the new guild's channels.
	// Assigning a channel to a channel category is not supported by this
	// endpoint, i.e. a channel can't have the parent_id field.
	//
	// When using the channels parameter, the position field is ignored,
	// and none of the default channels are created.
	//
	// When using the channels parameter, the id field within each channel
	// object may be set to an integer placeholder, and will be replaced by the
	// API upon consumption. Its purpose is to allow you to create
	// GUILD_CATEGORY channels by setting the parent_id field on any children
	// to the category's id field. Category channels must be listed before any
	// children.
	Channels []discord.Channel `json:"channels,omitempty"`

	// AFKChannelID is the id for the afk channel.
	AFKChannelID discord.ChannelID `json:"afk_channel_id,omitempty"`
	// AFKTimeout is the afk timeout in seconds.
	AFKTimeout discord.OptionalSeconds `json:"afk_timeout,omitempty"`

	// SystemChannelID is the id of the channel where guild notices such as
	// welcome messages and boost events are posted.
	SystemChannelID discord.ChannelID `json:"system_channel_id,omitempty"`
}

https://discord.com/developers/docs/resources/guild#create-guild-json-params

type CreateInviteData

type CreateInviteData struct {
	// MaxAge is the duration of invite in seconds before expiry, or 0 for
	// never.
	//
	// Default:	86400 (24 hours)
	MaxAge option.Uint `json:"max_age,omitempty"`
	// MaxUses is the max number of uses or 0 for unlimited.
	//
	// Default:	0
	MaxUses uint `json:"max_uses,omitempty"`
	// Temporary specifies whether this invite only grants temporary membership.
	//
	// Default:	false
	Temporary bool `json:"temporary,omitempty"`
	// Unique has the following behavior: if true, don't try to reuse a similar
	// invite (useful for creating many unique one time use invites).
	//
	// Default:	false
	Unique bool `json:"unique,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params

type CreateRoleData

type CreateRoleData struct {
	// Name is the 	name of the role.
	//
	// Default: "new role"
	Name string `json:"name,omitempty"`
	// Permissions is the bitwise value of the enabled/disabled permissions.
	//
	// Default: @everyone permissions in guild
	Permissions discord.Permissions `json:"permissions,string,omitempty"`
	// Color is the RGB color value of the role.
	//
	// Default: 0
	Color discord.Color `json:"color,omitempty"`
	// Hoist specifies whether the role should be displayed separately in the
	// sidebar.
	//
	// Default: false
	Hoist bool `json:"hoist,omitempty"`
	// Mentionable specifies whether the role should be mentionable.
	//
	// Default: false
	Mentionable bool `json:"mentionable,omitempty"`

	// Icon is the icon of the role. Requires the guild to have the ROLE_ICONS feature.
	//
	// Default: null
	Icon *Image `json:"icon,omitempty"`
	// UnicodeEmoji is the role's unicode emoji. Requires the guild to have the ROLE_ICONS feature.
	//
	// Default: null
	UnicodeEmoji string `json:"unicode_emoji,omitempty"`

	AddRoleData `json:"-"`
}

https://discord.com/developers/docs/resources/guild#create-guild-role-json-params

type CreateScheduledEventData

type CreateScheduledEventData struct {
	// ChannelID is the channel id of the scheduled event.
	ChannelID discord.ChannelID `json:"channel_id"`
	// EntityMetadata is the entity metadata of the scheduled event.
	EntityMetadata *discord.EntityMetadata `json:"entity_metadata"`
	// Name is the name of the scheduled event.
	Name string `json:"name"`
	// PrivacyLevel is the privacy level of the scheduled event.
	PrivacyLevel discord.ScheduledEventPrivacyLevel `json:"privacy_level"`
	// StartTime is when the scheduled event begins.
	StartTime discord.Timestamp `json:"scheduled_start_time"`
	// EndTime is when the scheduled event ends, if it does.
	EndTime *discord.Timestamp `json:"scheduled_end_time,omitempty"`
	// Description is the description of the schduled event.
	Description string `json:"description"`
	// EntityType is the entity type of the scheduled event.
	EntityType discord.EntityType `json:"entity_type"`
	// Image is the cover image of the scheduled event.
	Image Image `json:"image"`
}

CreateScheduledEventData is the structure for creating a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event-json-params

type CreateStageInstanceData

type CreateStageInstanceData struct {
	// ChannelID is the id of the Stage channel.
	ChannelID discord.ChannelID `json:"channel_id"`
	// Topic is the topic of the Stage instance (1-120 characters).
	Topic string `json:"topic"`
	// PrivacyLevel is the privacy level of the Stage instance.
	//
	// Defaults to discord.GuildOnlyStage.
	PrivacyLevel discord.PrivacyLevel `json:"privacy_level,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/stage-instance#create-stage-instance-json-params

type CreateWebhookData

type CreateWebhookData struct {
	// Name is the name of the webhook (1-80 characters).
	Name string `json:"name"`
	// Avatar is the image for the default webhook avatar.
	Avatar *Image `json:"avatar"`
}

https://discord.com/developers/docs/resources/webhook#create-webhook-json-params

type EditChannelPermissionData

type EditChannelPermissionData struct {
	// Type is either "role" or "member".
	Type discord.OverwriteType `json:"type"`
	// Allow is a permission bit set for granted permissions.
	Allow discord.Permissions `json:"allow,string"`
	// Deny is a permission bit set for denied permissions.
	Deny discord.Permissions `json:"deny,string"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/channel#edit-channel-permissions-json-params

type EditInteractionResponseData

type EditInteractionResponseData struct {
	// Content are the new message contents (up to 2000 characters).
	Content option.NullableString `json:"content,omitempty"`
	// Embeds contains embedded rich content.
	Embeds *[]discord.Embed `json:"embeds,omitempty"`
	// Components contains the new components to attach.
	Components *discord.ContainerComponents `json:"components,omitempty"`
	// AllowedMentions are the allowed mentions for the message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	// Attachments are the attached files to keep.
	Attachments *[]discord.Attachment `json:"attachments,omitempty"`

	// Files represents a list of files to upload. This will not be
	// JSON-encoded and will only be available through WriteMultipart.
	Files []sendpart.File `json:"-"`
}

func (EditInteractionResponseData) NeedsMultipart

func (data EditInteractionResponseData) NeedsMultipart() bool

NeedsMultipart returns true if the SendMessageData has files.

func (EditInteractionResponseData) WriteMultipart

func (data EditInteractionResponseData) WriteMultipart(body *multipart.Writer) error

type EditMessageData

type EditMessageData struct {
	// Content is the new message contents (up to 2000 characters).
	Content option.NullableString `json:"content,omitempty"`
	// Embeds contains embedded rich content.
	Embeds *[]discord.Embed `json:"embeds,omitempty"`
	// Components contains the new components to attach.
	Components *discord.ContainerComponents `json:"components,omitempty"`
	// AllowedMentions are the allowed mentions for a message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	// Attachments are the attached files to keep
	Attachments *[]discord.Attachment `json:"attachments,omitempty"`
	// Flags edits the flags of a message (only SUPPRESS_EMBEDS can currently
	// be set/unset)
	//
	// This field is nullable.
	Flags *discord.MessageFlags `json:"flags,omitempty"`

	Files []sendpart.File `json:"-"`
}

https://discord.com/developers/docs/resources/channel#edit-message

func (EditMessageData) NeedsMultipart

func (data EditMessageData) NeedsMultipart() bool

NeedsMultipart returns true if the SendMessageData has files.

func (EditMessageData) WriteMultipart

func (data EditMessageData) WriteMultipart(body *multipart.Writer) error

type EditScheduledEventData

type EditScheduledEventData struct {
	// ChannelID is the new channel id of the scheduled event.
	ChannelID discord.ChannelID `json:"channel_id,omitempty"`
	// EntityMetadata is the new entity metadata of the scheduled event.
	EntityMetadata *discord.EntityMetadata `json:"entity_metadata,omitempty"`
	// Name is the new name of the scheduled event.
	Name option.NullableString `json:"name,omitempty"`
	// PrivacyLevel is the new privacy level of the scheduled event.
	PrivacyLevel discord.ScheduledEventPrivacyLevel `json:"privacy_level,omitempty"`
	// StartTime is the new starting time for when the scheduled event begins.
	StartTime *discord.Timestamp `json:"scheduled_start_time,omitempty"`
	// EndTime is the new time of which the scheduled event ends
	EndTime *discord.Timestamp `json:"scheduled_end_time,omitempty"`
	// Description is the new description of the scheduled event.
	Description option.NullableString `json:"description,omitempty"`
	// EntityType is the new entity type of the scheduled event.
	EntityType discord.EntityType `json:"entity_type,omitempty"`
	// Status is the new event status of the scheduled event.
	Status discord.EventStatus `json:"status,omitempty"`
	// Image is the new image of the scheduled event.
	Image *Image `json:"image,omitempty"`
}

EditScheduledEventData is the structure for modifying a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event-json-params

type GuildScheduledEventUser

type GuildScheduledEventUser struct {
	// EventID is the id of the scheduled event.
	EventID discord.EventID `json:"guild_scheduled_event_id"`
	// User is the user object of the user.
	User discord.User `json:"user"`
	// Member is the member object of the user.
	Member *discord.Member `json:"member"`
}

GuildScheduledEventUser represents a user interested in a scheduled event.

https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object

type GuildWidgetImageStyle

type GuildWidgetImageStyle string

https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options

const (
	// GuildShield is a shield style widget with Discord icon and guild members
	// online count.
	//
	// Example: https://discordapp.com/api/guilds/81384788765712384/widget.png?style=shield
	GuildShield GuildWidgetImageStyle = "shield"
	// GuildBanner1 is a large image with guild icon, name and online count.
	// "POWERED BY DISCORD" as the footer of the widget.
	//
	// Example: https://discordapp.com/api/guilds/81384788765712384/widget.png?style=banner1
	GuildBanner1 GuildWidgetImageStyle = "banner1"
	// GuildBanner2 is a smaller widget style with guild icon, name and online
	// count. Split on the right with Discord logo.
	//
	// Example: https://discordapp.com/api/guilds/81384788765712384/widget.png?style=banner2
	GuildBanner2 GuildWidgetImageStyle = "banner2"
	// GuildBanner3 is a large image with guild icon, name and online count. In
	// the footer, Discord logo on the left and "Chat Now" on the right.
	//
	// Example: https://discordapp.com/api/guilds/81384788765712384/widget.png?style=banner3
	GuildBanner3 GuildWidgetImageStyle = "banner3"
	// GuildBanner4 is a large Discord logo at the top of the widget.
	// Guild icon, name and online count in the middle portion of the widget
	// and a "JOIN MY SERVER" button at the bottom.
	//
	// Example: https://discordapp.com/api/guilds/81384788765712384/widget.png?style=banner4
	GuildBanner4 GuildWidgetImageStyle = "banner4"
)

type Image

type Image struct {
	// ContentType is optional and will be automatically detected. However, it
	// should always return "image/jpeg," "image/png" or "image/gif".
	ContentType string
	// Just raw content of the file.
	Content []byte
}

Image wraps around the Data URI Scheme that Discord uses: https://discord.com/developers/docs/reference#image-data

func DecodeImage

func DecodeImage(data []byte) (*Image, error)

func (Image) Encode

func (i Image) Encode() ([]byte, error)

func (Image) MarshalJSON

func (i Image) MarshalJSON() ([]byte, error)

func (*Image) UnmarshalJSON

func (i *Image) UnmarshalJSON(v []byte) error

func (Image) Validate

func (i Image) Validate(maxSize int) error

type ImageTooLargeError

type ImageTooLargeError struct {
	Size, Max int
}

func (ImageTooLargeError) Error

func (err ImageTooLargeError) Error() string

type InteractionResponse

type InteractionResponse struct {
	Type InteractionResponseType  `json:"type"`
	Data *InteractionResponseData `json:"data,omitempty"`
}

func (InteractionResponse) NeedsMultipart

func (resp InteractionResponse) NeedsMultipart() bool

NeedsMultipart returns true if the InteractionResponse has files.

func (InteractionResponse) WriteMultipart

func (resp InteractionResponse) WriteMultipart(body *multipart.Writer) error

type InteractionResponseData

type InteractionResponseData struct {
	// Content are the message contents (up to 2000 characters).
	//
	// Required: one of content, file, embeds
	Content option.NullableString `json:"content,omitempty"`
	// TTS is true if this is a TTS message.
	TTS bool `json:"tts,omitempty"`
	// Embeds contains embedded rich content.
	//
	// Required: one of content, file, embeds
	Embeds *[]discord.Embed `json:"embeds,omitempty"`
	// Components is the list of components (such as buttons) to be attached to
	// the message.
	Components *discord.ContainerComponents `json:"components,omitempty"`
	// AllowedMentions are the allowed mentions for the message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	// Flags are the interaction application command callback data flags.
	// Only SuppressEmbeds and EphemeralMessage may be set.
	Flags discord.MessageFlags `json:"flags,omitempty"`

	// Files represents a list of files to upload. This will not be
	// JSON-encoded and will only be available through WriteMultipart.
	Files []sendpart.File `json:"-"`

	// Choices are the results to display on autocomplete interaction events.
	//
	// During all other events, this should not be provided.
	Choices AutocompleteChoices `json:"choices,omitempty"`

	// CustomID used with the modal
	CustomID option.NullableString `json:"custom_id,omitempty"`
	// Title is the heading of the modal window
	Title option.NullableString `json:"title,omitempty"`
}

InteractionResponseData is InteractionApplicationCommandCallbackData in the official documentation.

func (InteractionResponseData) NeedsMultipart

func (d InteractionResponseData) NeedsMultipart() bool

NeedsMultipart returns true if the InteractionResponseData has files.

func (InteractionResponseData) WriteMultipart

func (d InteractionResponseData) WriteMultipart(body *multipart.Writer) error

type InteractionResponseFlags deprecated

type InteractionResponseFlags = discord.MessageFlags

InteractionResponseFlags implements flags for an InteractionApplicationCommandCallbackData.

Deprecated: use discord.MessageFlags instead.

EphemeralMessage specifies whether the message is only visible to the user who invoked the Interaction.

Deprecated: use discord.EphemeralMessage instead.

type InteractionResponseType

type InteractionResponseType uint
const (
	PongInteraction InteractionResponseType = iota + 1

	MessageInteractionWithSource
	DeferredMessageInteractionWithSource
	DeferredMessageUpdate
	UpdateMessage
	AutocompleteResult
	ModalResponse
)

https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type

type JoinedInvite

type JoinedInvite struct {
	Code      string          `json:"code"`
	NewMember bool            `json:"new_member"`
	Guild     discord.Guild   `json:"guild"`
	Channel   discord.Channel `json:"channel"` // id, name, type only
}

JoinedInvite is returned after joining an invite.

type LoginResponse

type LoginResponse struct {
	MFA    bool   `json:"mfa"`
	SMS    bool   `json:"sms"`
	Ticket string `json:"ticket"`
	Token  string `json:"token"`
}

type ModifyChannelData

type ModifyChannelData struct {
	// Name is the 2-100 character channel name.
	//
	// Channel Types: All
	Name string `json:"name,omitempty"`
	// Type is the type of the channel.
	// Only conversion between text and news is supported and only in guilds
	// with the "NEWS" feature
	//
	// Channel Types: Text, News
	Type *discord.ChannelType `json:"type,omitempty"`
	// Position is the position of the channel in the left-hand listing.
	//
	// Channel Types: Text, News, Voice, Store, Category
	Position option.NullableInt `json:"position,omitempty"`
	// Topic is the 0-1024 character channel topic.
	//
	// Channel Types: Text, News
	Topic option.NullableString `json:"topic,omitempty"`
	// Flags is a bitmask that contains if a thread is pinned for example
	Flags *discord.ChannelFlags `json:"flags,omitempty"`
	// NSFW specifies whether the channel is nsfw.
	//
	// Channel Types: Text, News, Store
	NSFW option.NullableBool `json:"nsfw,omitempty"`
	// UserRateLimit is the amount of seconds a user has to wait before sending
	// another message (0-21600).
	// Bots, as well as users with the permission manage_messages or
	// manage_channel, are unaffected.
	//
	// Channel Types: Text, Thread
	UserRateLimit option.NullableUint `json:"rate_limit_per_user,omitempty"`
	// VoiceBitrate is the bitrate (in bits) of the voice channel.
	// 8000 to 96000 (128000 for VIP servers)
	//
	// Channel Types: Voice
	VoiceBitrate option.NullableUint `json:"bitrate,omitempty"`
	// VoiceUserLimit is the user limit of the voice channel.
	// 0 refers to no limit, 1 to 99 refers to a user limit.
	//
	// Channel Types: Voice
	VoiceUserLimit option.NullableUint `json:"user_limit,omitempty"`
	// RTCRegionID is the channel voice region id. It will be determined
	// automatically set, if omitted.
	//
	// Channel Types: Voice
	RTCRegionID option.NullableString `json:"rtc_region,omitempty"`
	// Overwrites are the channel or category-specific permissions.
	//
	// Channel Types: Text, News, Store, Voice, Category
	Overwrites *[]discord.Overwrite `json:"permission_overwrites,omitempty"`
	// CategoryID is the id of the new parent category for a channel.
	//
	// Channel Types: Text, News, Store, Voice
	CategoryID discord.ChannelID `json:"parent_id,string,omitempty"`

	// Icon is a base64 encoded icon.
	//
	// Channel Types: Group DM
	Icon string `json:"icon,omitempty"`

	// Archived specifies whether the thread is archived.
	Archived option.Bool `json:"archived,omitempty"`
	// AutoArchiveDuration is the duration in minutes to automatically archive
	// the thread after recent activity.
	//
	// Note that the three and seven day archive durations require the server
	// to be boosted.
	AutoArchiveDuration discord.ArchiveDuration `json:"auto_archive_duration,omitempty"`
	// Locked specifies whether the thread is locked. When a thread is locked,
	// only users with MANAGE_THREADS can unarchive it.
	Locked option.Bool `json:"locked,omitempty"`
	// Invitable specifies whether non-moderators can add other
	// non-moderators to a thread; only available on private threads
	Invitable option.Bool `json:"invitable,omitempty"`

	AvailableTags        *[]discord.Tag          `json:"available_tags,omitempty"`
	AppliedTags          *[]discord.TagID        `json:"applied_tags,omitempty"`
	DefaultReactionEmoji **discord.ForumReaction `json:"default_reaction_emoji,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/channel#modify-channel-json-params

type ModifyCurrentUserData

type ModifyCurrentUserData struct {
	// Username is the user's username, if changed may cause the user's
	// discriminator to be randomized.
	Username option.String `json:"username,omitempty"`
	// Avatar modifies the user's avatar.
	Avatar *Image `json:"image,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/user#modify-current-user-json-params

type ModifyEmojiData

type ModifyEmojiData struct {
	// Name is the name of the emoji.
	Name string `json:"name,omitempty"`
	// Roles are the roles that can use the emoji.
	Roles *[]discord.RoleID `json:"roles,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/emoji#modify-guild-emoji-json-params

type ModifyGuildData

type ModifyGuildData struct {
	// Name is the guild's name.
	Name string `json:"name,omitempty"`
	// Region is the guild's voice region id.
	Region option.NullableString `json:"region,omitempty"`

	// Verification is the verification level.
	//
	// This field is nullable.
	Verification *discord.Verification `json:"verification_level,omitempty"`
	// Notification is the default message notification level.
	//
	// This field is nullable.
	Notification *discord.Notification `json:"default_message_notifications,omitempty"`
	// ExplicitFilter is the explicit content filter level.
	//
	// This field is nullable.
	ExplicitFilter *discord.ExplicitFilter `json:"explicit_content_filter,omitempty"`

	// AFKChannelID is the id for the afk channel.
	//
	// This field is nullable.
	AFKChannelID discord.ChannelID `json:"afk_channel_id,string,omitempty"`
	// AFKTimeout is the afk timeout in seconds.
	AFKTimeout discord.OptionalSeconds `json:"afk_timeout,omitempty"`
	// Icon is the base64 1024x1024 png/jpeg/gif image for the guild icon
	// (can be animated gif when the server has the ANIMATED_ICON feature).
	Icon *Image `json:"icon,omitempty"`
	// Splash is the base64 16:9 png/jpeg image for the guild splash
	// (when the server has the INVITE_SPLASH feature).
	Splash *Image `json:"splash,omitempty"`
	// Banner is the base64 16:9 png/jpeg image for the guild banner (when the
	// server has BANNER feature).
	Banner *Image `json:"banner,omitempty"`

	// OwnerID is the user id to transfer guild ownership to (must be owner).
	OwnerID discord.UserID `json:"owner_id,omitempty"`

	// SystemChannelID is the id of the channel where guild notices such as
	// welcome messages and boost events are posted.
	//
	// This field is nullable.
	SystemChannelID discord.ChannelID `json:"system_channel_id,omitempty"`
	// RulesChannelID is the id of the channel where "PUBLIC" guilds display
	// rules and/or guidelines.
	//
	// This field is nullable.
	RulesChannelID discord.ChannelID `json:"rules_channel_id,omitempty"`
	// PublicUpdatesChannelID is the id of the channel where admins and
	// moderators of "PUBLIC" guilds receive notices from Discord.
	//
	// This field is nullable.
	PublicUpdatesChannelID discord.ChannelID `json:"public_updates_channel_id,omitempty"`

	// PreferredLocale is the preferred locale of a "PUBLIC" guild used in
	// server discovery and notices from Discord.
	//
	// This defaults to "en-US".
	PreferredLocale option.NullableString `json:"preferred_locale,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/guild#modify-guild-json-params

type ModifyGuildWidgetData

type ModifyGuildWidgetData struct {
	// Enabled specifies whether the widget is enabled.
	Enabled option.Bool `json:"enabled,omitempty"`
	// ChannelID is the widget channel ID.
	ChannelID discord.ChannelID `json:"channel_id,omitempty"`

	AuditLogReason `json:"-"`
}

ModifyGuildWidgetData is the structure to modify a guild widget object for the guild. All attributes may be passed in with JSON and modified.

https://discord.com/developers/docs/resources/guild#guild-widget-object

type ModifyIntegrationData

type ModifyIntegrationData struct {
	// ExpireBehavior is the behavior when an integration subscription lapses
	// (see the integration expire behaviors documentation).
	ExpireBehavior *discord.ExpireBehavior `json:"expire_behavior,omitempty"`
	// ExpireGracePeriod is the period (in days) where the integration will
	// ignore lapsed subscriptions.
	ExpireGracePeriod option.NullableInt `json:"expire_grace_period,omitempty"`
	// EnableEmoticons specifies whether emoticons should be synced for this
	// integration (twitch only currently).
	EnableEmoticons option.NullableBool `json:"enable_emoticons,omitempty"`
}

https://discord.com/developers/docs/resources/guild#modify-guild-integration-json-params

type ModifyMemberData

type ModifyMemberData struct {
	// Nick is the value to set users nickname to.
	//
	// Requires MANAGE_NICKNAMES.
	Nick option.String `json:"nick,omitempty"`
	// Roles is an array of role ids the member is assigned.
	//
	// Requires MANAGE_ROLES.
	Roles *[]discord.RoleID `json:"roles,omitempty"`
	// Mute specifies whether the user is muted in voice channels.
	//
	// Requires MUTE_MEMBERS.
	Mute option.Bool `json:"mute,omitempty"`
	// Deaf specifies whether the user is deafened in voice channels.
	//
	// Requires DEAFEN_MEMBERS.
	Deaf option.Bool `json:"deaf,omitempty"`

	// Voice channel is the id of channel to move user to (if they are
	// connected to voice).
	//
	// Requires MOVE_MEMBER
	VoiceChannel discord.ChannelID `json:"channel_id,omitempty"`

	// CommunicationDisabledUntil specifies when the user's timeout will expire.
	//
	// Requires MODERATE_MEMBERS
	CommunicationDisabledUntil *discord.Timestamp `json:"communication_disabled_until,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/guild#add-guild-member-json-params

type ModifyRoleData

type ModifyRoleData struct {
	// Name is the 	name of the role.
	Name option.NullableString `json:"name,omitempty"`
	// Permissions is the bitwise value of the enabled/disabled permissions.
	Permissions *discord.Permissions `json:"permissions,string,omitempty"`
	// Permissions is the bitwise value of the enabled/disabled permissions.
	//
	// This value is nullable.
	Color discord.Color `json:"color,omitempty"`
	// Hoist specifies whether the role should be displayed separately in the
	// sidebar.
	Hoist option.NullableBool `json:"hoist,omitempty"`
	// Mentionable specifies whether the role should be mentionable.
	Mentionable option.NullableBool `json:"mentionable,omitempty"`

	// Icon is the icon of the role. Requires the guild to have the ROLE_ICONS feature.
	// This value is nullable.
	// To reset the role's icon, set this to NullImage.
	Icon *Image `json:"icon,omitempty"`
	// UnicodeEmoji is the role's unicode emoji. Requires the guild to have the ROLE_ICONS feature.
	UnicodeEmoji option.NullableString `json:"unicode_emoji,omitempty"`

	AddRoleData `json:"-"`
}

https://discord.com/developers/docs/resources/guild#modify-guild-role-json-params

type ModifyWebhookData

type ModifyWebhookData struct {
	// Name is the default name of the webhook.
	Name option.String `json:"name,omitempty"`
	// Avatar is the image for the default webhook avatar.
	Avatar *Image `json:"avatar,omitempty"`
	// ChannelID is the new channel id this webhook should be moved to.
	ChannelID discord.ChannelID `json:"channel_id,omitempty"`
}

https://discord.com/developers/docs/resources/webhook#modify-webhook-json-params

type MoveChannelData

type MoveChannelData struct {
	// ID is the channel id.
	ID discord.ChannelID `json:"id"`
	// Position is the sorting position of the channel.
	Position option.Int `json:"position"`
	// LockPermissions syncs the permission overwrites with the new parent,
	// if moving to a new category.
	LockPermissions option.Bool `json:"lock_permissions"`
	// CategoryID is the new parent ID for the channel that is moved.
	CategoryID discord.ChannelID `json:"parent_id,string,omitempty"`
}

type MoveChannelsData

type MoveChannelsData struct {
	// Channels are the channels to be moved.
	Channels []MoveChannelData

	AuditLogReason
}

type MoveRoleData

type MoveRoleData struct {
	// ID is the id of the role.
	ID discord.RoleID `json:"id"`
	// Position is the sorting position of the role.
	Position option.NullableInt `json:"position,omitempty"`
}

https://discord.com/developers/docs/resources/guild#modify-guild-role-positions-json-params

type MoveRolesData

type MoveRolesData struct {
	Roles []MoveRoleData

	AuditLogReason
}

type PruneCountData

type PruneCountData struct {
	// Days is the number of days to count prune for (1 or more, default 7).
	Days uint `schema:"days"`
	// IncludedRoles are the role(s) to include.
	IncludedRoles []discord.RoleID `schema:"include_roles,omitempty"`
}

https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params

type PruneData

type PruneData struct {
	// Days is the number of days to prune (1 or more, default 7).
	Days uint `schema:"days"`
	// ReturnCount specifies whether 'pruned' is returned. Discouraged for
	// large guilds.
	ReturnCount bool `schema:"compute_prune_count"`
	// IncludedRoles are the role(s) to include.
	IncludedRoles []discord.RoleID `schema:"include_roles,omitempty"`

	AuditLogReason `schema:"-"`
}

https://discord.com/developers/docs/resources/guild#begin-guild-prune-query-string-params

type SearchData

type SearchData struct {
	Offset      uint              `schema:"offset,omitempty"`
	Content     string            `schema:"content,omitempty"`
	Has         string            `schema:"has,omitempty"`
	SortBy      string            `schema:"sort_by,omitempty"`
	SortOrder   string            `schema:"sort_order,omitempty"`
	ChannelID   discord.ChannelID `schema:"channel_id,omitempty"`
	AuthorID    discord.UserID    `schema:"author_id,omitempty"`
	Mentions    discord.UserID    `schema:"mentions,omitempty"`
	MaxID       discord.MessageID `schema:"max_id,omitempty"`
	MinID       discord.MessageID `schema:"min_id,omitempty"`
	IncludeNSFW bool              `schema:"include_nsfw,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	AnalyticsID  string              `json:"analytics_id"`
	Messages     [][]discord.Message `json:"messages"`
	TotalResults uint                `json:"total_results"`
}

type SendMessageData

type SendMessageData struct {
	// Content are the message contents (up to 2000 characters).
	Content string `json:"content,omitempty"`
	// Nonce is a nonce that can be used for optimistic message sending.
	Nonce string `json:"nonce,omitempty"`

	// TTS is true if this is a TTS message.
	TTS bool `json:"tts,omitempty"`
	// Embed is embedded rich content.
	Embeds []discord.Embed `json:"embeds,omitempty"`

	// Files is the list of file attachments to be uploaded. To reference a file
	// in an embed, use (sendpart.File).AttachmentURI().
	Files []sendpart.File `json:"-"`
	// Components is the list of components (such as buttons) to be attached to
	// the message.
	Components discord.ContainerComponents `json:"components,omitempty"`

	// AllowedMentions are the allowed mentions for a message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	// Reference allows you to reference another message to create a reply. The
	// referenced message must be from the same channel.
	//
	// Only MessageID is necessary. You may also include a channel_id and
	// guild_id in the reference. However, they are not necessary, but will be
	// validated if sent.
	Reference *discord.MessageReference `json:"message_reference,omitempty"`

	// Flags specifies the message flags to set (only `SuppressEmbeds` and `SuppressNotifications` can be set).
	Flags discord.MessageFlags `json:"flags"`
}

SendMessageData is the full structure to send a new message to Discord with.

func (SendMessageData) NeedsMultipart

func (data SendMessageData) NeedsMultipart() bool

NeedsMultipart returns true if the SendMessageData has files.

func (SendMessageData) WriteMultipart

func (data SendMessageData) WriteMultipart(body *multipart.Writer) error

type Session

type Session struct {
	Limiter *rate.Limiter

	Token     string
	UserAgent string
}

Session keeps a single session. This is typically wrapped around Client.

type SessionStartLimit

type SessionStartLimit struct {
	Total          int                  `json:"total"`
	Remaining      int                  `json:"remaining"`
	ResetAfter     discord.Milliseconds `json:"reset_after"`
	MaxConcurrency int                  `json:"max_concurrency"`
}

SessionStartLimit is the information on the current session start limit. It's used in BotData.

type StartThreadData

type StartThreadData struct {
	// Name is the 1-100 character channel name.
	Name string `json:"name"`
	// AutoArchiveDuration is the duration in minutes to automatically archive
	// the thread after recent activity.
	//
	// Note that the three and seven day archive durations require the server
	// to be boosted.
	AutoArchiveDuration discord.ArchiveDuration `json:"auto_archive_duration"`
	// Type is the type of thread to create.
	//
	// This field can only be used when starting a thread without a message
	Type discord.ChannelType `json:"type,omitempty"` // we can omit, since thread types start at 10
	// Invitable specifies whether non-moderators can add other
	// non-moderators to a thread; only available on private threads.
	//
	// This field can only be used when starting a thread without a message
	Invitable bool `json:"invitable,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/channel#start-thread-with-message-json-params and https://discord.com/developers/docs/resources/channel#start-thread-without-message-json-params

type UpdateStageInstanceData

type UpdateStageInstanceData struct {
	// Topic is the topic of the Stage instance (1-120 characters).
	Topic string `json:"topic,omitempty"`
	// PrivacyLevel is the privacy level of the Stage instance.
	PrivacyLevel discord.PrivacyLevel `json:"privacy_level,omitempty"`

	AuditLogReason `json:"-"`
}

https://discord.com/developers/docs/resources/stage-instance#update-stage-instance-json-params

Directories

Path Synopsis
Package webhook provides means to interact with webhooks directly and not through the bot API.
Package webhook provides means to interact with webhooks directly and not through the bot API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL