api

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: ISC Imports: 17 Imported by: 0

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_"

Variables

View Source
var (
	BaseEndpoint = "https://discord.com"
	APIVersion   = "6"
	APIPath      = "/api/v" + APIVersion

	Endpoint           = BaseEndpoint + APIPath + "/"
	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 EndpointChannels = Endpoint + "channels/"
View Source
var EndpointGuilds = Endpoint + "guilds/"
View Source
var EndpointInvites = Endpoint + "invites/"
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 has both an empty Content and no Embed(s).

View Source
var ErrInvalidImageCT = errors.New("unknown image content-type")
View Source
var ErrInvalidImageData = errors.New("invalid image data")
View Source
var UserAgent = "DiscordBot (https://github.com/diamondburned/arikawa, v0.0.1)"

Functions

This section is empty.

Types

type Ack

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

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

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.Snowflake `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 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"
)

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.Snowflake `json:"roles,omitempty"`
	// Users is an array of user_ids to mention (Max size of 100).
	Users []discord.Snowflake `json:"users,omitempty"`
}

AllowedMentions is a whitelist of mentions for a message. https://discordapp.com/developers/docs/resources/channel#allowed-mentions-object

Whitelists

Roles and Users are slices that act as whitelists 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 whitelist slices, Roles and Users.

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.Snowflake `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.Snowflake `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 BanData

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

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

type Client

type Client struct {
	*httputil.Client
	Session
}

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, messageID discord.Snowflake, 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) AddMember

func (c *Client) AddMember(
	guildID, userID discord.Snowflake, 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, userID discord.Snowflake, 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, userID, roleID discord.Snowflake) error

Adds a role to a guild member.

Requires the MANAGE_ROLES permission.

func (*Client) AttachIntegration

func (c *Client) AttachIntegration(guildID,
	integrationID discord.Snowflake, 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.Snowflake, 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, userID discord.Snowflake, data BanData) error

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

Requires the BAN_MEMBERS permission.

func (*Client) Bans

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

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

Requires the BAN_MEMBERS permission.

func (*Client) ChangeOwnNickname

func (c *Client) ChangeOwnNickname(
	guildID discord.Snowflake, nick string) error

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

Fires a Guild Member Update Gateway event.

func (*Client) Channel

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

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

func (*Client) ChannelInvites

func (c *Client) ChannelInvites(channelID discord.Snowflake) ([]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.Snowflake) ([]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.Snowflake) ([]discord.Channel, error)

Channels returns a list of guild channel objects.

func (*Client) CreateChannel

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

CreateChannel creates a new channel object for the guild.

Requires the MANAGE_CHANNELS permission. Fires a Channel Create Gateway event.

func (*Client) CreateEmoji

func (c *Client) CreateEmoji(
	guildID discord.Snowflake, 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) CreateInvite

func (c *Client) CreateInvite(
	channelID discord.Snowflake, 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.Snowflake) (*discord.Channel, error)

CreatePrivateChannel creates a new DM channel with a user.

func (*Client) CreateRole

func (c *Client) CreateRole(
	guildID discord.Snowflake, 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) CreateWebhook

func (c *Client) CreateWebhook(
	channelID discord.Snowflake,
	name string, avatar discord.Hash) (*discord.Webhook, error)

CreateWebhook creates a new webhook.

Webhooks cannot be named "clyde".

Requires the MANAGE_WEBHOOKS permission.

func (*Client) DeleteAllReactions

func (c *Client) DeleteAllReactions(channelID, messageID discord.Snowflake) 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.Snowflake) 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, overwriteID discord.Snowflake) 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) DeleteEmoji

func (c *Client) DeleteEmoji(guildID, emojiID discord.Snowflake) error

Delete the given emoji.

Requires the MANAGE_EMOJIS permission. Fires a Guild Emojis Update Gateway event.

func (*Client) DeleteGuild

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

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

Fires a Guild Delete Gateway event.

func (*Client) DeleteInvite

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

DeleteInvite 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) DeleteMessage

func (c *Client) DeleteMessage(channelID, messageID discord.Snowflake) 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.Snowflake, messageIDs []discord.Snowflake) 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.

Fires a Message Delete Bulk Gateway event.

func (*Client) DeleteReactions

func (c *Client) DeleteReactions(
	channelId, messageID discord.Snowflake, emoji Emoji) 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) DeleteRole

func (c *Client) DeleteRole(guildID, roleID discord.Snowflake) error

DeleteRole deletes a guild role.

Requires the MANAGE_ROLES permission.

func (*Client) DeleteUserReaction

func (c *Client) DeleteUserReaction(
	channelID, messageID, userID discord.Snowflake, emoji Emoji) error

DeleteReaction 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.Snowflake) error

DeleteWebhook deletes a webhook permanently.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) DeleteWebhookWithToken

func (c *Client) DeleteWebhookWithToken(webhookID discord.Snowflake, token string) error

DeleteWebhookWithToken is the same as above, except this call does not require authentication.

func (*Client) EditChannelPermission

func (c *Client) EditChannelPermission(
	channelID discord.Snowflake, overwrite discord.Overwrite) 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) EditEmbed

func (c *Client) EditEmbed(
	channelID, messageID discord.Snowflake, embed discord.Embed) (*discord.Message, error)

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

func (*Client) EditMessage

func (c *Client) EditMessage(
	channelID, messageID discord.Snowflake, content string,
	embed *discord.Embed, suppressEmbeds bool) (*discord.Message, error)

EditMessage edits a previously sent message. For more documentation, refer to EditMessageComplex.

func (*Client) EditMessageComplex

func (c *Client) EditMessageComplex(
	channelID, messageID discord.Snowflake, 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) EditText

func (c *Client) EditText(
	channelID, messageID discord.Snowflake, 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, emojiID discord.Snowflake) (*discord.Emoji, error)

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

func (*Client) Emojis

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

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

func (*Client) ExecuteWebhook

func (c *Client) ExecuteWebhook(
	webhookID discord.Snowflake,
	token string,
	wait bool,
	data ExecuteWebhookData) (*discord.Message, error)

ExecuteWebhook sends a message to the webhook. If wait is bool, Discord will wait for the message to be delivered and will return the message body. This also means the returned message will only be there if wait is true.

func (*Client) GetBan

func (c *Client) GetBan(guildID, userID discord.Snowflake) (*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.Snowflake) (*discord.Guild, error)

Guild returns the guild object for the given id. ApproximateMembers and ApproximatePresences will not be set.

func (*Client) GuildImage

func (c *Client) GuildImage(guildID discord.Snowflake, img GuildImageStyle) (io.ReadCloser, error)

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

func (*Client) GuildImageURL

func (c *Client) GuildImageURL(guildID discord.Snowflake, img GuildImageStyle) string

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

Requires no permissions or authentication.

func (*Client) GuildInvites

func (c *Client) GuildInvites(guildID discord.Snowflake) ([]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.Snowflake) (*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) GuildVanityURL

func (c *Client) GuildVanityURL(guildID discord.Snowflake) (*discord.Invite, error)

GuildVanityURL returns *Invite for guilds that have that feature enabled, but 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.Snowflake) ([]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.Snowflake) (*discord.GuildWidget, error)

GuildWidget returns the guild widget object.

Requires the MANAGE_GUILD permission.

func (*Client) GuildWithCount

func (c *Client) GuildWithCount(id discord.Snowflake) (*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 within the passed range.

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.Snowflake, 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 within the passed range.

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.Snowflake, 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 within the passed range.

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) Integrations

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

Integrations returns a list of integration objects for the guild.

Requires the MANAGE_GUILD permission.

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)

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

func (*Client) Kick

func (c *Client) Kick(guildID, userID discord.Snowflake) 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.Snowflake) error

LeaveGuild leaves a guild.

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, userID discord.Snowflake) (*discord.Member, error)

Member returns a guild member object for the specified user..

func (*Client) Members

func (c *Client) Members(guildID discord.Snowflake, 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 within the passed range.

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, after discord.Snowflake, 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 within the passed range.

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, messageID discord.Snowflake) (*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.Snowflake, limit uint) ([]discord.Message, error)

Messages returns a list of messages sent in the channel 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 guilds within the passed ange.

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.

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

func (*Client) MessagesAfter

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

MessagesAfter returns a list messages sent in the channel 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 guilds within the passed range.

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.

func (*Client) MessagesAround

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

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

func (*Client) MessagesBefore

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

MessagesBefore returns a list messages sent in the channel 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 guilds within the passed range.

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.

func (*Client) ModifyChannel

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

ModifyChannel updates a channel's settings.

Requires the MANAGE_CHANNELS permission for the guild.

func (*Client) ModifyEmoji

func (c *Client) ModifyEmoji(guildID, emojiID discord.Snowflake, 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.Snowflake, 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.Snowflake, data ModifyGuildWidgetData) (*discord.GuildWidget, error)

ModifyGuildWidget modifies a guild widget object for the guild.

Requires the MANAGE_GUILD permission.

func (*Client) ModifyIntegration

func (c *Client) ModifyIntegration(
	guildID, integrationID discord.Snowflake, 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) ModifyMe

func (c *Client) ModifyMe(data ModifySelfData) (*discord.User, error)

ModifyMe modifies the requester's user account settings.

func (*Client) ModifyMember

func (c *Client) ModifyMember(guildID, userID discord.Snowflake, 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, roleID discord.Snowflake,
	data ModifyRoleData) (*discord.Role, error)

ModifyRole modifies a guild role.

Requires the MANAGE_ROLES permission.

func (*Client) ModifyWebhook

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

ModifyWebhook modifies a webhook.

Requires the MANAGE_WEBHOOKS permission.

func (*Client) ModifyWebhookWithToken

func (c *Client) ModifyWebhookWithToken(
	webhookID discord.Snowflake, data ModifyWebhookData, token string) (*discord.Webhook, error)

ModifyWebhookWithToken is the same as above, except this call does not require authentication, does not accept a channel_id parameter in the body, and does not return a user in the webhook object.

func (*Client) MoveChannel

func (c *Client) MoveChannel(guildID discord.Snowflake, datum []MoveChannelData) error

MoveChannel modifies the position of channels in the guild.

Requires MANAGE_CHANNELS.

func (*Client) MoveRole

func (c *Client) MoveRole(guildID discord.Snowflake, data []MoveRoleData) ([]discord.Role, error)

MoveRole 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) PinMessage

func (c *Client) PinMessage(channelID, messageID discord.Snowflake) error

PinMessage pins a message in a channel.

Requires the MANAGE_MESSAGES permission.

func (*Client) PinnedMessages

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

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

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.Snowflake, days uint) error

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

Requires KICK_MEMBERS.

func (*Client) PruneCount

func (c *Client) PruneCount(guildID discord.Snowflake, days uint) (uint, error)

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

Requires KICK_MEMBERS.

func (*Client) PruneWithCount

func (c *Client) PruneWithCount(guildID discord.Snowflake, days uint) (uint, error)

PruneWithCounts returns the number of members that is removed. Days must be 1 or more, default 7.

Requires KICK_MEMBERS.

func (*Client) React

func (c *Client) React(channelID, messageID discord.Snowflake, emoji Emoji) 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, messageID discord.Snowflake, limit uint, emoji Emoji) ([]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, messageID, after discord.Snowflake, limit uint, emoji Emoji,
) ([]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 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.

func (*Client) ReactionsBefore

func (c *Client) ReactionsBefore(
	channelID, messageID, before discord.Snowflake,
	limit uint, emoji Emoji) ([]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 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.

func (*Client) RemoveRecipient

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

RemoveRecipient removes a user from a group direct message.

func (*Client) RemoveRole

func (c *Client) RemoveRole(guildID, userID, roleID discord.Snowflake) error

RemoveRole removes a role from a guild member.

Requires the MANAGE_ROLES permission. Fires a Guild Member Update Gateway event.

func (*Client) Roles

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

Roles returns a list of role objects for the guild.

func (*Client) SendEmbed

func (c *Client) SendEmbed(
	channelID discord.Snowflake, e discord.Embed) (*discord.Message, error)

SendEmbed posts an Embed 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.Snowflake, content string, embed *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.Snowflake, 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) SendText

func (c *Client) SendText(channelID discord.Snowflake, content string) (*discord.Message, error)

SendText posts a only-text 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) SyncIntegration

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

Sync an integration. Requires the MANAGE_GUILD permission.

func (*Client) TOTP

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

func (*Client) Typing

func (c *Client) Typing(channelID discord.Snowflake) 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, userID discord.Snowflake) 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, messageID discord.Snowflake) error

UnpinMessage deletes a pinned message in a channel.

Requires the MANAGE_MESSAGES permission.

func (*Client) Unreact

func (c *Client) Unreact(chID, msgID discord.Snowflake, emoji Emoji) error

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

func (*Client) User

func (c *Client) User(userID discord.Snowflake) (*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.Snowflake) ([]discord.VoiceRegion, error)

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

func (*Client) Webhook

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

Webhook returns the webhook with the given id.

func (*Client) WebhookWithToken

func (c *Client) WebhookWithToken(
	webhookID discord.Snowflake, token string) (*discord.Webhook, error)

WebhookWithToken is the same as above, except this call does not require authentication and returns no user in the webhook object.

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.

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"`
	// 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"`
	// Permissions are the channel's permission overwrites.
	//
	// Channel Types: All
	Permissions []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.Snowflake `json:"parent_id,string,omitempty"`
	// NSFW specifies whether the channel is nsfw.
	//
	// Channel Types: Text, News, Store.
	NSFW bool `json:"nsfw,omitempty"`
}

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

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 for which this emoji will be whitelisted.
	Roles *[]discord.Snowflake `json:"roles,omitempty"`
}

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.Snowflake `json:"afk_channel_id,omitempty"`
	// AFKTimeout is the afk timeout in seconds.
	AFKTimeout option.Seconds `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.Snowflake `json:"system_channel_id,omitempty"`
}

https://discordapp.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"`
}

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,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"`
}

https://discord.com/developers/docs/resources/guild#create-guild-role-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 EditMessageData

type EditMessageData struct {
	// Content is the new message contents (up to 2000 characters).
	Content option.NullableString `json:"content,omitempty"`
	// Embed contains embedded rich content.
	Embed *discord.Embed `json:"embed,omitempty"`
	// AllowedMentions are the allowed mentions for a message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,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"`
}

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

type Emoji

type Emoji = string

Emoji is the API format of a regular Emoji, both Unicode or custom. This could usually be formatted by calling (discord.Emoji).APIString().

func NewCustomEmoji

func NewCustomEmoji(id discord.Snowflake, name string) Emoji

NewCustomEmoji creates a new Emoji using a custom guild emoji as base. Unicode emojis should be directly passed to the function using Emoji.

type ErrImageTooLarge

type ErrImageTooLarge struct {
	Size, Max int
}

func (ErrImageTooLarge) Error

func (err ErrImageTooLarge) Error() string

type ExecuteWebhookData

type ExecuteWebhookData struct {
	// Content are the message contents (up to 2000 characters).
	//
	// Required: one of content, file, embeds
	Content string `json:"content,omitempty"`

	// Username overrides the default username of the webhook
	Username string `json:"username,omitempty"`
	// AvatarURL overrides the default avatar of the webhook.
	AvatarURL discord.URL `json:"avatar_url,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"`

	Files []SendMessageFile `json:"-"`

	// AllowedMentions are the allowed mentions for the message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
}

func (*ExecuteWebhookData) WriteMultipart

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

type GuildImageStyle

type GuildImageStyle 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 GuildImageStyle = "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 GuildImageStyle = "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 GuildImageStyle = "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 GuildImageStyle = "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 GuildImageStyle = "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://discordapp.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 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"`
	// Postion is the position of the channel in the left-hand listing
	//
	// Channel Types: All
	Position option.NullableInt `json:"position,omitempty"`
	// Topic is the 0-1024 character channel topic.
	//
	// Channel Types: Text, News
	Topic option.NullableString `json:"topic,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
	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"`
	// Permissions are the channel or category-specific permissions.
	//
	// Channel Types: All
	Permissions *[]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.Snowflake `json:"parent_id,string,omitempty"`
}

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

type ModifyEmojiData

type ModifyEmojiData struct {
	// Name is the name of the emoji.
	Name string `json:"name,omitempty"`
	// Roles are the roles to which this emoji will be whitelisted.
	Roles *[]discord.Snowflake `json:"roles,omitempty"`
}

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.Snowflake `json:"afk_channel_id,string,omitempty"`
	// AFKTimeout is the afk timeout in seconds.
	AFKTimeout option.Seconds `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.Snowflake `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.Snowflake `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.Snowflake `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.Snowflake `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"`
}

https://discordapp.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.Snowflake `json:"channel_id,omitempty"`
}

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

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.Snowflake `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.Snowflake `json:"channel_id,omitempty"`
}

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,omitempty"`
	// Permissions is the bitwise value of the enabled/disabled permissions.
	Color option.NullableColor `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"`
}

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

type ModifySelfData

type ModifySelfData 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"`
}

https://discord.com/developers/docs/resources/user#modify-current-user-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.Snowflake `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.Snowflake `json:"id"`
	// Position is the sorting position of the channel
	Position option.Int `json:"position"`
}

type MoveRoleData

type MoveRoleData struct {
	// ID is the id of the role.
	ID discord.Snowflake `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 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.
	Embed *discord.Embed `json:"embed,omitempty"`

	Files []SendMessageFile `json:"-"`

	// AllowedMentions are the allowed mentions for a message.
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
}

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

func (*SendMessageData) WriteMultipart

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

type SendMessageFile

type SendMessageFile struct {
	Name   string
	Reader io.Reader
}

SendMessageFile represents a file to be uploaded to Discord.

type Session

type Session struct {
	Limiter *rate.Limiter

	Token     string
	UserAgent string
}

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

func (*Session) InjectRequest

func (s *Session) InjectRequest(r httpdriver.Request) error

func (*Session) OnResponse

func (s *Session) OnResponse(r httpdriver.Request, resp httpdriver.Response) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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