api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: Apache-2.0 Imports: 16 Imported by: 13

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 (
	BaseEndpoint = "https://discordapp.com/api"
	APIVersion   = "6"

	Endpoint           = BaseEndpoint + "/v" + APIVersion + "/"
	EndpointGateway    = Endpoint + "gateway"
	EndpointGatewayBot = EndpointGateway + "/bot"
)
View Source
const AttachmentSpoilerPrefix = "SPOILER_"
View Source
const EndpointChannels = Endpoint + "channels/"
View Source
const EndpointGuilds = Endpoint + "guilds/"
View Source
const EndpointInvites = Endpoint + "invites/"
View Source
const EndpointMe = EndpointUsers + "@me"
View Source
const EndpointUsers = Endpoint + "users/"
View Source
const EndpointWebhooks = Endpoint + "webhooks/"

Variables

View Source
var (
	ErrEmojiTooLarge = errors.New("Emoji is larger than 256k")
)
View Source
var ErrInvalidImageCT = errors.New("Unknown image content-type")
View Source
var ErrInvalidImageData = errors.New("Invalid image data")
View Source
var ErrNoImage = errors.New("null image")
View Source
var UserAgent = "DiscordBot (https://github.com/diamondburned/arikawa, v0.0.1)"

Functions

func FormatEmojiAPI

func FormatEmojiAPI(id discord.Snowflake, name string) string

Types

type AnyMemberData

type AnyMemberData struct {
	Nick string `json:"nick,omitempty"`
	Mute bool   `json:"mute,omitempty"`
	Deaf bool   `json:"deaf,omitempty"`

	Roles []discord.Snowflake `json:"roles,omitempty"`

	// Only for ModifyMember, requires MOVE_MEMBER
	VoiceChannel discord.Snowflake `json:"channel_id,omitempty"`
}

AnyMemberData, all fields are optional.

type AnyRoleData

type AnyRoleData struct {
	Name  string        `json:"name,omitempty"`  // "new role"
	Color discord.Color `json:"color,omitempty"` // 0
	Hoist bool          `json:"hoist,omitempty"` // false (show role separately)

	Mentionable bool                `json:"mentionable,omitempty"` // false
	Permissions discord.Permissions `json:"permissions,omitempty"` // @everyone
}

type Client

type Client struct {
	httputil.Client
	Limiter *rate.Limiter

	Token string
}

func NewClient

func NewClient(token string) *Client

func (*Client) AddMember

func (c *Client) AddMember(
	guildID, userID discord.Snowflake, token string,
	data AnyMemberData) (*discord.Member, error)

AddMember requires access(Token).

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

func (*Client) AttachIntegration

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

AttachIntegration requires MANAGE_GUILD.

func (*Client) Ban

func (c *Client) Ban(
	guildID, userID discord.Snowflake, days uint, reason string) error

Ban requires the BAN_MEMBERS permission. Days is the days back for Discord to delete the user's message, maximum 7 days.

func (*Client) Bans

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

func (*Client) ChangeOwnNickname

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

ChangeOwnNickname only replies with the nickname back, so we're not even going to bother.

func (*Client) Channel

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

func (*Client) ChannelInvites

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

ChannelInvites is only for guild channels. GuildInvites is for guilds.

func (*Client) Channels

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

func (*Client) CreateChannel

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

func (*Client) CreateEmoji

func (c *Client) CreateEmoji(
	guildID discord.Snowflake, name string, image Image,
	roles []discord.Snowflake) (*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). Roles slice is optional.

func (*Client) CreateGuild

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

func (*Client) CreateInvite

func (c *Client) CreateInvite(
	channelID discord.Snowflake, maxAge discord.Seconds,
	maxUses uint, temp, unique bool) (*discord.Invite, error)

CreateInvite is only for guild channels. This endpoint requires CREATE_INSTANT_INVITE.

MaxAge is the duration before expiry, 0 for never. MaxUses is the maximum number of uses, 0 for unlimited. Temporary is whether this invite grants temporary membership. Unique, if true, tries not to reuse a similar invite, useful for creating unique one time use invites.

func (*Client) CreatePrivateChannel

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

func (*Client) CreateRole

func (c *Client) CreateRole(
	guildID discord.Snowflake, data AnyRoleData) (*discord.Role, error)

func (*Client) CreateWebhook

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

CreateWebhook creates a new webhook; avatar hash is optional. Requires MANAGE_WEBHOOKS.

func (*Client) DeleteAllReactions

func (c *Client) DeleteAllReactions(
	chID, msgID discord.Snowflake, emoji EmojiAPI) error

DeleteAllReactions equires MANAGE_MESSAGE.

func (*Client) DeleteChannel

func (c *Client) DeleteChannel(channelID discord.Snowflake) error

func (*Client) DeleteChannelPermission

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

func (*Client) DeleteEmoji

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

DeleteEmoji requires MANAGE_EMOJIS.

func (*Client) DeleteGuild

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

func (*Client) DeleteInvite

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

DeleteInvite requires either MANAGE_CHANNELS on the target channel, or MANAGE_GUILD to remove any invite in the guild.

func (*Client) DeleteMessage

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

DeleteMessage deletes a message. Requires MANAGE_MESSAGES if the message is not made by yourself.

func (*Client) DeleteMessages

func (c *Client) DeleteMessages(
	channelID discord.Snowflake, messageIDs []discord.Snowflake) error

DeleteMessages only works for bots. It can't delete messages older than 2 weeks, and will fail if tried. This endpoint requires MANAGE_MESSAGES.

func (*Client) DeleteOwnReaction

func (c *Client) DeleteOwnReaction(
	chID, msgID discord.Snowflake, emoji EmojiAPI) error

func (*Client) DeleteReaction

func (c *Client) DeleteReaction(
	chID, msgID, userID discord.Snowflake, emoji EmojiAPI) error

DeleteReaction requires MANAGE_MESSAGES if not @me.

func (*Client) DeleteRole

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

func (*Client) DeleteWebhook

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

func (*Client) DeleteWebhookWithToken

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

func (*Client) EditChannelPermission

func (c *Client) EditChannelPermission(
	channelID discord.Snowflake, overwrite discord.Overwrite) error

func (*Client) EditMessage

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

func (*Client) Emoji

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

func (*Client) Emojis

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

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)

func (*Client) Guild

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

func (*Client) GuildEmbed

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

func (*Client) GuildImage

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

func (*Client) GuildImageURL

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

func (*Client) GuildInvites

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

GuildInvites is for guilds.

func (*Client) GuildVanityURL

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

GuildVanityURL returns *Invite, but only Code and Uses are filled. Requires MANAGE_GUILD.

func (*Client) Guilds

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

Guilds returns all guilds, automatically paginating. Be careful, as this method may abuse the API by requesting thousands or millions of guilds. For lower-level access, usee GuildsRange. Guilds returned have some fields filled only (ID, Name, Icon, Owner, Permissions).

func (*Client) GuildsAfter

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

GuildsAfter fetches guilds. Check GuildsRange.

func (*Client) GuildsBefore

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

GuildsBefore fetches guilds. Check GuildsRange.

func (*Client) GuildsRange

func (c *Client) GuildsRange(
	before, after discord.Snowflake, limit uint) ([]discord.Guild, error)

GuildsRange fetches guilds. The limit is 1-100.

func (*Client) Integrations

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

Integrations requires MANAGE_GUILD.

func (*Client) Invite

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

func (*Client) Kick

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

Kick requires KICK_MEMBERS.

func (*Client) LeaveGuild

func (c *Client) LeaveGuild(guildID discord.Snowflake) error

func (*Client) Me

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

func (*Client) Member

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

func (*Client) Members

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

Members returns members until it reaches max. This function automatically paginates, meaning the normal 1000 limit is handled internally. Max can be 0, in which the function will try and fetch everything.

func (*Client) MembersAfter

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

MembersAfter returns a list of all guild members, from 1-1000 for limits. The default limit is 1 and the maximum limit is 1000.

func (*Client) Message

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

func (*Client) Messages

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

Messages gets all mesesages, automatically paginating. Use with care, as this could get as many as hundred thousands of messages, making a lot of queries.

func (*Client) MessagesAfter

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

MessagesAfter returns messages after the ID, with a limit of 1-100.

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 1-100.

func (*Client) MessagesBefore

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

MessagesBefore returns messages before the ID, with a limit of 1-100.

func (*Client) ModifyChannel

func (c *Client) ModifyChannel(data ModifyChannelData) error

func (*Client) ModifyEmoji

func (c *Client) ModifyEmoji(
	guildID, emojiID discord.Snowflake, name string,
	roles []discord.Snowflake) error

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

func (*Client) ModifyGuild

func (c *Client) ModifyGuild(
	guildID discord.Snowflake, data ModifyGuildData) (*discord.Guild, error)

func (*Client) ModifyGuildEmbed

func (c *Client) ModifyGuildEmbed(
	guildID discord.Snowflake,
	data discord.GuildEmbed) (*discord.GuildEmbed, error)

ModifyGuildEmbed should be used with care: if you still want the embed enabled, you need to set the Enabled boolean, even if it's already enabled. If you don't, JSON will default it to false.

func (*Client) ModifyIntegration

func (c *Client) ModifyIntegration(
	guildID, integrationID discord.Snowflake,
	expireBehavior, expireGracePeriod int, emoticons bool) error

ModifyIntegration requires MANAGE_GUILD.

func (*Client) ModifyMe

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

func (*Client) ModifyMember

func (c *Client) ModifyMember(
	guildID, userID discord.Snowflake, data AnyMemberData) error

func (*Client) ModifyRole

func (c *Client) ModifyRole(
	guildID, roleID discord.Snowflake,
	data AnyRoleData) (*discord.Role, error)

func (*Client) ModifyWebhook

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

func (*Client) ModifyWebhookWithToken

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

func (*Client) MoveChannel

func (c *Client) MoveChannel(
	guildID, channelID discord.Snowflake, position int) error

func (*Client) MoveRole

func (c *Client) MoveRole(
	guildID, roleID discord.Snowflake, position int) ([]discord.Role, error)

func (*Client) PinMessage

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

PinMessage pins a message, which requires MANAGE_MESSAGES/

func (*Client) PinnedMessages

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

func (*Client) PrivateChannels

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

func (*Client) Prune

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

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

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. Requires KICK_MEMBERS. Days must be 1 or more, default 7.

func (*Client) React

func (c *Client) React(
	channelID, messageID discord.Snowflake, emoji EmojiAPI) error

React adds a reaction to the message. This requires READ_MESSAGE_HISTORY (and additionally ADD_REACTIONS) to react.

func (*Client) Reactions

func (c *Client) Reactions(
	channelID, messageID discord.Snowflake,
	max uint, emoji EmojiAPI) ([]discord.User, error)

Reactions returns all reactions. It will paginate automatically.

func (*Client) ReactionsAfter

func (c *Client) ReactionsAfter(
	channelID, messageID, after discord.Snowflake,
	limit uint, emoji EmojiAPI) ([]discord.User, error)

Refer to ReactionsRange.

func (*Client) ReactionsBefore

func (c *Client) ReactionsBefore(
	channelID, messageID, before discord.Snowflake,
	limit uint, emoji EmojiAPI) ([]discord.User, error)

Refer to ReactionsRange.

func (*Client) ReactionsRange

func (c *Client) ReactionsRange(
	channelID, messageID, before, after discord.Snowflake,
	limit uint, emoji EmojiAPI) ([]discord.User, error)

ReactionsRange get users before and after IDs. Before, after, and limit are optional. A maximum limit of only 100 reactions could be returned.

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

func (*Client) Roles

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

func (*Client) SendMessage

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

func (*Client) SendMessageComplex

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

func (*Client) SyncIntegration

func (c *Client) SyncIntegration(
	guildID, integrationID discord.Snowflake) 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 also requires BAN_MEMBERS.

func (*Client) UnpinMessage

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

UnpinMessage also requires MANAGE_MESSAGES.

func (*Client) User

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

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)

func (*Client) WebhookWithToken

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

func (*Client) Webhooks

func (c *Client) Webhooks(
	guildID discord.Snowflake) ([]discord.Webhook, error)

Webhooks requires MANAGE_WEBHOOKS.

type CreateChannelData

type CreateChannelData struct {
	Name  string `json:"name"` // 2-100
	Topic string `json:"topic,omitempty"`

	Type discord.ChannelType `json:"type,omitempty"`

	VoiceBitrate   uint `json:"bitrate,omitempty"`
	VoiceUserLimit uint `json:"user_limit,omitempty"`

	UserRateLimit discord.Seconds `json:"rate_limit_per_user,omitempty"`

	NSFW     bool `json:"nsfw"`
	Position int  `json:"position,omitempty"`

	Permissions []discord.Overwrite `json:"permission_overwrites,omitempty"`
	CategoryID  discord.Snowflake   `json:"parent_id,string,omitempty"`
}

type CreateGuildData

type CreateGuildData struct {
	Name string `json:"name"`
	Icon Image  `json:"image,omitempty"`

	// package dc is just package discord
	Verification   d.Verification   `json:"verification_level"`
	Notification   d.Notification   `json:"default_message_notifications"`
	ExplicitFilter d.ExplicitFilter `json:"explicit_content_filter"`

	// [0] (First entry) is ALWAYS @everyone.
	Roles []discord.Role `json:"roles,omitempty"`

	// Voice only
	VoiceRegion string `json:"region,omitempty"`

	// Partial, id field is ignored. Usually only Name and Type are changed.
	Channels []discord.Channel `json:"channels,omitempty"`
}

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

type EmojiAPI

type EmojiAPI = string

EmojiAPI is a special format that the API wants.

type ErrImageTooLarge

type ErrImageTooLarge struct {
	Size, Max int
}

func (ErrImageTooLarge) Error

func (err ErrImageTooLarge) Error() string

type ExecuteWebhookData

type ExecuteWebhookData struct {
	SendMessageData

	Username  string      `json:"username,omitempty"`
	AvatarURL discord.URL `json:"avatar_url,omitempty"`
}

func (*ExecuteWebhookData) WriteMultipart

func (data *ExecuteWebhookData) WriteMultipart(
	c json.Driver, body *multipart.Writer) error

type GuildImageType

type GuildImageType string
const (
	GuildShield  GuildImageType = "shield"
	GuildBanner1 GuildImageType = "banner1"
	GuildBanner2 GuildImageType = "banner2"
	GuildBanner3 GuildImageType = "banner3"
	GuildBanner4 GuildImageType = "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

	// Utility fields, not used for encoding
	MaxSize int // bytes
}

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() error

type MetaInvite

type MetaInvite struct {
	Inviter discord.User `json:"user"`
	Uses    uint         `json:"uses"`
	MaxUses uint         `json:"max_uses"`

	MaxAge discord.Seconds `json:"max_age"`

	Temporary bool              `json:"temporary"`
	CreatedAt discord.Timestamp `json:"created_at"`
}

Still unsure what this is

type ModifyChannelData

type ModifyChannelData struct {
	ChannelID discord.Snowflake `json:"id,string,omitempty"`

	// All types
	Name        string              `json:"name,omitempty"`
	Position    json.OptionInt      `json:"position,omitempty"`
	Permissions []discord.Overwrite `json:"permission_overwrites,omitempty"`

	// Text only
	Topic json.OptionString `json:"topic,omitempty"`
	NSFW  json.OptionBool   `json:"nsfw,omitempty"`

	// 0-21600, refer to Channel.UserRateLimit
	UserRateLimit discord.Seconds `json:"rate_limit_per_user,omitempty"`

	// Voice only
	// 8000 - 96000 (or 128000 for Nitro)
	VoiceBitrate json.OptionUint `json:"bitrate,omitempty"`
	// 0 no limit, 1-99
	VoiceUserLimit json.OptionUint `json:"user_limit,omitempty"`

	// Text OR Voice
	CategoryID discord.Snowflake `json:"parent_id,string,omitempty"`
}

type ModifyGuildData

type ModifyGuildData struct {
	Name   string `json:"name,omitempty"`
	Region string `json:"region,omitempty"`
	Icon   Image  `json:"image,omitempty"`

	// package d is just package discord
	Verification   *d.Verification   `json:"verification_level,omitempty"`
	Notification   *d.Notification   `json:"default_message_notifications,omitempty"`
	ExplicitFilter *d.ExplicitFilter `json:"explicit_content_filter,omitempty"`

	AFKChannelID *d.Snowflake `json:"afk_channel_id,string,omitempty"`
	AFKTimeout   *d.Seconds   `json:"afk_timeout,omitempty"`

	OwnerID d.Snowflake `json:"owner_id,string,omitempty"`

	Splash Image `json:"splash,omitempty"`
	Banner Image `json:"banner,omitempty"`

	SystemChannelID d.Snowflake `json:"system_channel_id,string,omitempty"`
}

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

type ModifySelfData

type ModifySelfData struct {
	Username string `json:"username,omitempty"`
	Avatar   Image  `json:"image,omitempty"`
}

type ModifyWebhookData

type ModifyWebhookData struct {
	Name      string            `json:"name,omitempty"`
	Avatar    discord.Hash      `json:"avatar,omitempty"` // TODO: clear avatar how?
	ChannelID discord.Snowflake `json:"channel_id,omitempty"`
}

type SendMessageData

type SendMessageData struct {
	Content string `json:"content,omitempty"`
	Nonce   string `json:"nonce,omitempty"`
	TTS     bool   `json:"tts"`

	Embed *discord.Embed `json:"embed,omitempty"`

	Files []SendMessageFile `json:"-"`
}

func (*SendMessageData) WriteMultipart

func (data *SendMessageData) WriteMultipart(
	c json.Driver, body *multipart.Writer) error

type SendMessageFile

type SendMessageFile struct {
	Name   string
	Reader io.Reader
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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