discord

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Overview

Package discord contains every Discord resources used throughout Harmony as well as some utility functions and methods to work with them.

Objects suffixed by "Settings" or "Parameters" are settings and parameters objects are sent by the client to Discord. They all use the `optional` package to handle optional fields properly. Convenience functions are provided to create settings and parameters, see "New*Settings" and "New*Parameters" functions. Most of other objects are sent from Discord to the client. Some of these objects contain fields that are pointers. When this is the case, it means this field is nullable, be sure to check whether it's set before accessing it.

Index

Constants

View Source
const (
	GuildFeatureInviteSplash         = "INVITE_SPLASH"
	GuildFeatureVIPRegions           = "VIP_REGIONS"
	GuildFeatureVanityURL            = "VANITY_URL"
	GuildFeatureVerified             = "VERIFIED"
	GuildFeaturePartenered           = "PARTNERED"
	GuildFeatureCommunity            = "COMMUNITY"
	GuildFeatureCommerce             = "COMMERCE"
	GuildFeatureNews                 = "NEWS"
	GuildFeatureDiscoverable         = "DISCOVERABLE"
	GuildFeatureFeaturable           = "FEATURABLE"
	GuildFeatureAnimatedIcon         = "ANIMATED_ICON"
	GuildFeatureBanner               = "BANNER"
	GuildFeatureWelcomeScreenEnabled = "WELCOME_SCREEN_ENABLED"
)
View Source
const (
	PermissionNone               = 0x00000000 // Allows nothing.
	PermissionCreateInvite       = 0x00000001 // Allows creation of instant invites.
	PermissionKickMembers        = 0x00000002 // Allows kicking members.
	PermissionBanMembers         = 0x00000004 // Allows banning members.
	PermissionAdministrator      = 0x00000008 // Allows *all permissions* and bypasses channel permission overwrites.
	PermissionManageChannels     = 0x00000010 // Allows management and editing of channels.
	PermissionManageGuild        = 0x00000020 // Allows management and editing of the guild.
	PermissionAddReactions       = 0x00000040 // Allows for the addition of reactions to messages.
	PermissionViewAuditLog       = 0x00000080 // Allows for viewing of audit logs.
	PermissionViewChannel        = 0x00000400 // Allows guild members to view a channel, which includes reading messages in text channels.
	PermissionSendMessages       = 0x00000800 // Allows for sending messages in a channel.
	PermissionSendTTSMessages    = 0x00001000 // Allows for sending of /tts messages.
	PermissionManageMessages     = 0x00002000 // Allows for deletion of other users messages.
	PermissionEmbedLinks         = 0x00004000 // Links sent by users with this permission will be auto-embedded.
	PermissionAttachFiles        = 0x00008000 // Allows for uploading images and files.
	PermissionReadMessageHistory = 0x00010000 // Allows for reading of message history.
	PermissionMentionEveryone    = 0x00020000 // Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel.
	PermissionUseExternalEmojis  = 0x00040000 // Allows the usage of custom emojis from other servers.
	PermissionConnect            = 0x00100000 // Allows for joining of a voice channel.
	PermissionSpeak              = 0x00200000 // Allows for speaking in a voice channel.
	PermissionMuteMembers        = 0x00400000 // Allows for muting members in a voice channel.
	PermissionDeafenMembers      = 0x00800000 // Allows for deafening of members in a voice channel.
	PermissionMoveMembers        = 0x01000000 // Allows for moving of members between voice channels.
	PermissionUseVAD             = 0x02000000 // Allows for using voice-activity-detection in a voice channel.
	PermissionPrioritySpeaker    = 0x00000100 // Allows for using priority speaker in a voice channel.
	PermissionChangeNickname     = 0x04000000 // Allows for modification of own nickname.
	PermissionManageNicknames    = 0x08000000 // Allows for modification of other users nicknames.
	PermissionManageRoles        = 0x10000000 // Allows management and editing of roles.
	PermissionManageWebhooks     = 0x20000000 // Allows management and editing of webhooks.
	PermissionManageEmojis       = 0x40000000 // Allows management and editing of emojis.
)

Set of permissions that can be assigned to Users and Roles.

Equivalent to all intents except privileged (GatewayIntentGuildMembers and GatewayIntentGuildPresences), OR'd.

Variables

View Source
var (
	// ErrGatewayNotConnected is returned when the client is not connected to the Gateway.
	ErrGatewayNotConnected = errors.New("gateway is not connected")
	// ErrGatewayAlreadyConnected is returned by Connect when a connection to the Gateway already exists.
	ErrGatewayAlreadyConnected = errors.New("already connected to the Gateway")
	// ErrInvalidMessageSend is returned by Send when no files are provided.
	ErrInvalidMessageSend = errors.New("no content, embed nor file provided")
	// ErrAlreadyConnectedToVoice is returned when trying to join a voice channel in
	// a guild where you are already have an active voice connection.
	ErrAlreadyConnectedToVoice = errors.New("already connected to a voice channel in this guild, consider using the SwitchVoiceChannel method")
	// ErrNotConnectedToVoice is returned when trying to switch to a different voice
	// channel in a guild where you are not yet connected to a voice channel.
	ErrNotConnectedToVoice = errors.New("not connected to a voice channel in this guild, use the JoinVoiceChannel method first")
	// ErrNotCurrentUser is returned for user endpoints used with an ID different than "@me".
	ErrNotCurrentUser = errors.New("endpoint only available for current user (@me)")
)

Functions

func CreationTimeOf

func CreationTimeOf(id string) (time.Time, error)

CreationTimeOf returns the creation time of the given Discord ID (userID, guildID, channelID). For more information, see : https://discord.com/developers/docs/reference#snowflakes.

func NewAPIError

func NewAPIError(resp *http.Response) error

NewAPIError is a helper function that extracts an API error from an HTTP response and returns it as a generic APIError or a ValidationError.

func PermissionsContains

func PermissionsContains(permissions, permission int) bool

PermissionsContains returns whether the given permission is set in permissions.

Types

type APIError

type APIError struct {
	HTTPCode int      `json:"http_code"`
	Code     int      `json:"code"`
	Message  string   `json:"message"`
	Misc     []string `json:"_misc"`
}

APIError is a generic error returned by the Discord HTTP API.

func (APIError) Error

func (e APIError) Error() string

Error implements the error interface.

type Activity

type Activity struct {
	Name string       `json:"name"`
	Type ActivityType `json:"type"`
	// Stream url, is validated when type is Streaming.
	URL string `json:"url"`
	// Time at which the activity was added to the user's session.
	CreatedAt int `json:"created_at"`
	// Unix timestamps for start and/or end of the game.
	Timestamps ActivityTimestamp `json:"timestamps"`
	// Application id for the game.
	ApplicationID string `json:"application_id"`
	// What the player is currently doing.
	Details string `json:"details"`
	// The user's current party status.
	State string `json:"state"`
	// The emoji used for a custom status.
	Emoji ActivityEmoji `json:"emoji"`
	// Information for the current party of the player.
	Party ActivityParty `json:"party"`
	// Images for the presence and their hover texts.
	Assets ActivityAssets `json:"assets"`
	// Secrets for Rich Presence joining and spectating.
	Secrets ActivitySecrets `json:"secrets"`
	// Whether or not the activity is an instanced game session.
	Instance bool `json:"instance"`
	// Activity flags ORd together, describes what the payload includes.
	Flags ActivityFlag `json:"flags"`
}

Activity represents a user activity (playing a game, streaming, etc.). Bots are only able to send Name, Type, and optionally URL.

type ActivityAssets

type ActivityAssets struct {
	LargeImage string `json:"large_image"`
	LargeText  string `json:"large_text"`
	SmallImage string `json:"small_image"`
	SmallText  string `json:"small_text"`
}

ActivityAssets contains images for the presence and their hover texts.

type ActivityEmoji

type ActivityEmoji struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Animated bool   `json:"animated"`
}

ActivityEmoji is the emoji set in a custom activity status.

type ActivityFlag

type ActivityFlag int

ActivityFlag describes an Activity.

const (
	ActivityFlagInstance    ActivityFlag = 1 << 0
	ActivityFlagJoin        ActivityFlag = 1 << 1
	ActivityFlagSpectate    ActivityFlag = 1 << 2
	ActivityFlagJoinRequest ActivityFlag = 1 << 3
	ActivityFlagSync        ActivityFlag = 1 << 4
	ActivityFlagPlay        ActivityFlag = 1 << 5
)

type ActivityParty

type ActivityParty struct {
	ID   string `json:"id"`
	Size []int  `json:"size"` // Array of two integers (current_size, max_size).
}

ActivityParty contains information for the current party of the player.

type ActivitySecrets

type ActivitySecrets struct {
	Join     string `json:"join"`
	Spectate string `json:"spectate"`
	Match    string `json:"match"`
}

ActivitySecrets are secrets than can be attached to an activity.

type ActivityTimestamp

type ActivityTimestamp struct {
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

ActivityTimestamp is the unix time (in milliseconds) of when the activity starts and ends.

type ActivityType

type ActivityType int

ActivityType describes what the user is doing.

const (
	// ActivityTypePlaying will display "Playing {name}".
	ActivityTypePlaying ActivityType = 0
	// ActivityTypeStreaming will display "Streaming {name}".
	ActivityTypeStreaming ActivityType = 1
	// ActivityTypeListening will display "Listening to {name}".
	ActivityTypeListening ActivityType = 2
	// ActivityTypeCustom will display "{emoji} {name}".
	ActivityTypeCustom ActivityType = 4
	// ActivityTypeCompeting will display "Competing in {name}".
	ActivityTypeCompeting ActivityType = 5
)

type Application

type Application struct {
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Icon                string   `json:"icon"`
	Description         string   `json:"description"`
	RPCOrigins          []string `json:"rpc_origins"`
	BotPublic           bool     `json:"bot_public"`
	BotRequireCodeGrant bool     `json:"bot_require_code_grant"`
	Owner               *User    `json:"owner"`
	Summary             string   `json:"summary"`
	VerifyKey           string   `json:"verify_key"`
	Team                Team     `json:"team"`
	GuildID             string   `json:"guild_id"`
	PrimarySKUID        string   `json:"primary_sku_id"`
	Slug                string   `json:"slug"`
	CoverImage          string   `json:"cover_image"`
	Flag                int      `json:"flag"`
}

Application represents a Discord developer application.

type Ban

type Ban struct {
	Reason string
	User   *User
}

Ban represents a Guild ban.

type BotStatus

type BotStatus struct {
	Since      int                 `json:"since"`
	Activities []BotStatusActivity `json:"activities,omitempty"`
	Status     Status              `json:"status,omitempty"`
	AFK        bool                `json:"afk"`
}

BotStatus is sent by the client to indicate a presence or status update.

type BotStatusActivity

type BotStatusActivity struct {
	Type ActivityType `json:"type"`
	Name string       `json:"name"`
	URL  string       `json:"url,omitempty"` // Used when Type is ActivityTypeStreaming.
}

BotStatusActivity is the subset of allowed values for bots from regular Activities.

type Channel

type Channel struct {
	ID                   string                `json:"id"`
	Type                 ChannelType           `json:"type"`
	GuildID              string                `json:"guild_id"`
	Position             int                   `json:"position"` // Sorting position of the channel.
	PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"`
	Name                 string                `json:"name"`
	Topic                string                `json:"topic"`
	NSFW                 bool                  `json:"nsfw"`
	ParentID             string                `json:"parent_id"` // ID of the parent category for a channel.

	// For text channels only.
	LastMessageID    string               `json:"last_message_id"`
	LastPinTimestamp Time                 `json:"last_pin_timestamp"`
	RateLimitPerUser ChannelUserRateLimit `json:"rate_limit_per_user"`

	// For voice channels only.
	Bitrate   int `json:"bitrate"`
	UserLimit int `json:"user_limit"`

	// For DMs only.
	Recipients    []User `json:"recipients"`
	Icon          string `json:"icon"`
	OwnerID       string `json:"owner_id"`
	ApplicationID string `json:"application_id"` // Application id of the group DM creator if it is bot-created.
}

Channel represents a guild or DM channel within Discord.

func (*Channel) Clone

func (c *Channel) Clone() *Channel

Clone returns a clone of this Channel.

type ChannelMention

type ChannelMention struct {
	ID      string      `json:"id"`
	GuildID string      `json:"guild_id"`
	Type    ChannelType `json:"type"`
	Name    string      `json:"name"`
}

ChannelMention represents a channel mention.

type ChannelSetting

type ChannelSetting func(*ChannelSettings)

ChannelSetting is a function that configures a channel.

func WithChannelBitrate

func WithChannelBitrate(bitrate int) ChannelSetting

WithChannelBitrate sets the bit rate of a channel (audio only). Must be a value between 8 and 96 for regular, non-premium channels and can go up to 256 for Tier 2 guild and 384 for Tier 3 guilds.

func WithChannelNSFW

func WithChannelNSFW(yes bool) ChannelSetting

WithChannelNSFW sets whether a channel is not safe for work.

func WithChannelName

func WithChannelName(name string) ChannelSetting

WithChannelName sets the name of a channel.

func WithChannelParent

func WithChannelParent(id string) ChannelSetting

WithChannelParent sets the parent ID channel of a channel.

func WithChannelPermissions

func WithChannelPermissions(perms []PermissionOverwrite) ChannelSetting

WithChannelPermissions sets the permission overwrites of a channel. Pass an empty array to remove all permission overwrites.

func WithChannelPosition

func WithChannelPosition(pos int) ChannelSetting

WithChannelPosition sets the position of a channel.

func WithChannelRateLimitPerUser

func WithChannelRateLimitPerUser(rateLimit ChannelUserRateLimit) ChannelSetting

WithChannelRateLimitPerUser sets the rate limit per user (text only).

func WithChannelTopic

func WithChannelTopic(topic string) ChannelSetting

WithChannelTopic sets the topic of a channel (text only).

func WithChannelType

func WithChannelType(t ChannelType) ChannelSetting

WithChannelType sets the name of a channel.

func WithChannelUserLimit

func WithChannelUserLimit(limit int) ChannelSetting

WithChannelUserLimit sets the user limit of a channel (audio only).

type ChannelSettings

type ChannelSettings struct {
	Name      *optional.String `json:"name,omitempty"` // 2-100 characters.
	Type      *optional.Int    `json:"type,omitempty"`
	Topic     *optional.String `json:"topic,omitempty"` // 0-1000 characters.
	Bitrate   *optional.Int    `json:"bitrate,omitempty"`
	UserLimit *optional.Int    `json:"user_limit,omitempty"`
	// RateLimitPerUser is the amount of seconds a user has to wait before sending
	// another message (0-120); bots, as well as users with the permission
	// 'manage_messages' or 'manage_channel', are unaffected.
	RateLimitPerUser *optional.Int `json:"rate_limit_per_user,omitempty"`
	// Sorting position of the channel.
	Position    *optional.Int         `json:"position,omitempty"`
	Permissions []PermissionOverwrite `json:"permission_overwrites,omitempty"`
	ParentID    *optional.String      `json:"parent_id,omitempty"`
	NSFW        *optional.Bool        `json:"nsfw,omitempty"`
}

ChannelSettings describes a channel creation or update.

func NewChannelSettings

func NewChannelSettings(opts ...ChannelSetting) *ChannelSettings

NewChannelSettings returns new ChannelSettings to create or modify a channel.

type ChannelType

type ChannelType int

ChannelType describes the type of a channel. Different fields are set or not depending on the channel's type.

const (
	ChannelTypeGuildText ChannelType = iota
	ChannelTypeDM
	ChannelTypeGuildVoice
	ChannelTypeGroupDM
	ChannelTypeGuildCategory
	ChannelTypeGuildNews
	ChannelTypeGuildStore
)

Supported channel types:

type ChannelUserRateLimit

type ChannelUserRateLimit int

ChannelUserRateLimit is the set of allowed values for Channel.RateLimitPerUser.

const (
	ChannelUserRateLimit5s  ChannelUserRateLimit = 5
	ChannelUserRateLimit10s ChannelUserRateLimit = 10
	ChannelUserRateLimit15s ChannelUserRateLimit = 15
	ChannelUserRateLimit30s ChannelUserRateLimit = 30
	ChannelUserRateLimit1m  ChannelUserRateLimit = 60
	ChannelUserRateLimit2m  ChannelUserRateLimit = 120
	ChannelUserRateLimit5m  ChannelUserRateLimit = 300
	ChannelUserRateLimit10m ChannelUserRateLimit = 600
	ChannelUserRateLimit15m ChannelUserRateLimit = 900
	ChannelUserRateLimit30m ChannelUserRateLimit = 1800
	ChannelUserRateLimit1h  ChannelUserRateLimit = 3600
	ChannelUserRateLimit2h  ChannelUserRateLimit = 7200
	ChannelUserRateLimit6h  ChannelUserRateLimit = 21600
)

Valid Channel User rate limits:

type ClientStatus

type ClientStatus struct {
	Desktop string `json:"desktop"`
	Mobile  string `json:"mobile"`
	Web     string `json:"web"`
}

ClientStatus is a platform-specific client status.

type Emoji

type Emoji struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	Roles         []string `json:"roles"`
	User          *User    `json:"user"` // The user that created this emoji.
	RequireColons bool     `json:"require_colons"`
	Managed       bool     `json:"managed"`
	Animated      bool     `json:"animated"`
	// Whether this emoji can be used, may be false due to loss of Server Boosts.
	Available bool `json:"available"`
}

Emoji represents a Discord emoji (both standard and custom).

func (*Emoji) Clone

func (e *Emoji) Clone() *Emoji

Clone returns a clone of this Emoji.

type File

type File struct {
	Name   string
	Reader io.ReadCloser
}

File represents a file that can be sent with Send and the WithFiles option.

func FileFromDisk

func FileFromDisk(filepath, name string) (*File, error)

FileFromDisk returns a File from a local, on disk file. If name is left empty, it will default to the name of the file on disk. Note that since Send is responsible for closing files opened by FileFromDisk, calling this function and *not* calling Send after can lead to resource leaks.

func FileFromReadCloser

func FileFromReadCloser(r io.ReadCloser, name string) *File

FileFromReadCloser returns a File given a ReadCloser and a name. If the name ends with a valid extension recognized by Discord's client applications, the file will be displayed inline in the channel instead of asking users to manually download it.

func FileFromURL

func FileFromURL(url, name string) (*File, error)

FileFromURL returns a File from a remote HTTP resource. If the name is left empty, it will default to the name of the file specified in the URL. Note that since Send is responsible for closing files opened by FileFromURL, calling this function and *not* calling Send after can lead to resource leaks.

type GatewayIntent

type GatewayIntent int

GatewayIntent specifies which events the Gateway should send to a client.

const (
	GatewayIntentGuild                  GatewayIntent = 1 << 0
	GatewayIntentGuildMembers           GatewayIntent = 1 << 1
	GatewayIntentGuildBans              GatewayIntent = 1 << 2
	GatewayIntentGuildEmojis            GatewayIntent = 1 << 3
	GatewayIntentGuildIntegrations      GatewayIntent = 1 << 4
	GatewayIntentGuildWebhooks          GatewayIntent = 1 << 5
	GatewayIntentGuildInvites           GatewayIntent = 1 << 6
	GatewayIntentGuildVoiceStates       GatewayIntent = 1 << 7
	GatewayIntentGuildPresences         GatewayIntent = 1 << 8
	GatewayIntentGuildMessages          GatewayIntent = 1 << 9
	GatewayIntentGuildMessageReactions  GatewayIntent = 1 << 10
	GatewayIntentGuildMessageTyping     GatewayIntent = 1 << 11
	GatewayIntentDirectMessages         GatewayIntent = 1 << 12
	GatewayIntentDirectMessageReactions GatewayIntent = 1 << 13
	GatewayIntentDirectMessageTyping    GatewayIntent = 1 << 14
)

List of gateway intents a client can subscribe to.

func (GatewayIntent) String

func (i GatewayIntent) String() string

String implements fmt.Stringer.

type Guild

type Guild struct {
	ID                          string                        `json:"id"`
	Name                        string                        `json:"name"`
	Icon                        string                        `json:"icon"`
	Splash                      string                        `json:"splash"`
	DiscoverySplash             string                        `json:"discovery_splash"`
	Description                 string                        `json:"description"`
	Banner                      string                        `json:"banner"`
	OwnerID                     string                        `json:"owner_id"`
	Region                      string                        `json:"region"`
	AFKChannelID                string                        `json:"afk_channel_id"`
	AFKTimeout                  GuildAFKTimeout               `json:"afk_timeout"`
	VerificationLevel           GuildVerificationLevel        `json:"verification_level"`
	DefaultMessageNotifications GuildDefaultNotificationLevel `json:"default_message_notifications"`
	ExplicitContentFilter       GuildExplicitContentFilter    `json:"explicit_content_filter"`
	Roles                       []Role                        `json:"roles"`
	Emojis                      []Emoji                       `json:"emojis"`
	Features                    []string                      `json:"features"`
	MFALevel                    MFALevel                      `json:"mfa_level"`
	ApplicationID               string                        `json:"application_id"`
	PreferredLocale             string                        `json:"preferred_locale"`
	WidgetEnabled               bool                          `json:"widget_enabled"`
	WidgetChannelID             string                        `json:"widget_channel_id"`
	SystemChannelID             string                        `json:"system_channel_id"`
	SystemChannelFlags          SystemChannelFlag             `json:"system_channel_flags"`
	RulesChannelID              string                        `json:"rules_channel_id"`
	PublicUpdatesChannelID      string                        `json:"public_updates_channel_id"`
	VanityURLCode               string                        `json:"vanity_url_code"`
	PremiumTier                 PremiumTier                   `json:"premium_tier"`
	PremiumSubscriptionCount    int                           `json:"premium_subscription_count"`
	MaxMembers                  int                           `json:"max_members"`
	MaxVideoChannelUsers        int                           `json:"max_video_channel_users"`

	// Following fields are only sent using the Get Guild method and are relative to the current user.
	Owner       bool `json:"owner"`
	Permissions int  `json:"permissions,string"`

	// Following fields are only sent within the GUILD_CREATE event.
	JoinedAt    Time          `json:"joined_at"`
	Large       bool          `json:"large"`
	Unavailable bool          `json:"unavailable"`
	MemberCount int           `json:"member_count"`
	VoiceStates []voice.State `json:"voice_states"`
	Members     []GuildMember `json:"members"`
	Channels    []Channel     `json:"channels"`
	Presences   []Presence    `json:"presences"`
}

Guild in Discord represents an isolated collection of users and channels, and are often referred to as "servers" in the UI.

func (*Guild) Clone

func (g *Guild) Clone() *Guild

Clone returns a clone of this Guild.

type GuildAFKTimeout

type GuildAFKTimeout int

GuildAFKTimeout is the set of allowed values for AFK timeouts.

const (
	GuildAFKTimeout1m  GuildAFKTimeout = 60
	GuildAFKTimeout5m  GuildAFKTimeout = 300
	GuildAFKTimeout15m GuildAFKTimeout = 900
	GuildAFKTimeout30m GuildAFKTimeout = 1800
	GuildAFKTimeout1h  GuildAFKTimeout = 3600
)

Valid Guild AFK timeouts:

type GuildDefaultNotificationLevel

type GuildDefaultNotificationLevel int

GuildDefaultNotificationLevel determines whether members who have not explicitly set their notification settings receive a notification for every message sent in this server or not.

const (
	// GuildDefaultNotificationLevelAll means a notification
	// will be sent for all messages.
	GuildDefaultNotificationLevelAll GuildDefaultNotificationLevel = iota
	// GuildDefaultNotificationLevelMentionOnly means a
	// notification will be sent for mentions only.
	GuildDefaultNotificationLevelMentionOnly
)

type GuildExplicitContentFilter

type GuildExplicitContentFilter int

GuildExplicitContentFilter determines how the explicit content filter should behave for a server.

const (
	// GuildExplicitContentFilterDisabled disables the filter.
	GuildExplicitContentFilterDisabled GuildExplicitContentFilter = iota
	// GuildExplicitContentFilterWithoutRole filters messages from
	// members without a role.
	GuildExplicitContentFilterWithoutRole
	// GuildExplicitContentFilterAll filters messages from all members.
	GuildExplicitContentFilterAll
)

type GuildFeature

type GuildFeature string

GuildFeature is a feature that enhances a guild.

type GuildIntegration

type GuildIntegration struct {
	ID                string                      `json:"id"`
	Name              string                      `json:"name"`
	Type              string                      `json:"type"`
	Enabled           bool                        `json:"enabled"`
	Syncing           bool                        `json:"syncing"`
	RoleID            string                      `json:"role_id"`
	EnableEmoticons   bool                        `json:"enable_emoticons"`
	ExpireBehavior    int                         `json:"expire_behavior"`
	ExpireGracePeriod int                         `json:"expire_grace_period"`
	User              User                        `json:"user"`
	Account           GuildIntegrationAccount     `json:"account"`
	SyncedAt          Time                        `json:"synced_at"`
	SubscriberCount   int                         `json:"subscriber_count"`
	Revoked           bool                        `json:"revoked"`
	Application       GuildIntegrationApplication `json:"application"`
}

type GuildIntegrationAccount

type GuildIntegrationAccount struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type GuildIntegrationApplication

type GuildIntegrationApplication struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Icon        string `json:"icon"`
	Description string `json:"description"`
	Summary     string `json:"summary"`
	Bot         User   `json:"bot"`
}

type GuildIntegrationSetting

type GuildIntegrationSetting func(*GuildIntegrationSettings)

GuildIntegrationSetting is a function that configures a guild integration.

func WithGuildIntegrationEnableEmoticons

func WithGuildIntegrationEnableEmoticons(yes bool) GuildIntegrationSetting

WithGuildIntegrationEnableEmoticons sets whether emoticons should be synced for this integration (twitch only currently).

func WithGuildIntegrationExpireBehavior

func WithGuildIntegrationExpireBehavior(v int) GuildIntegrationSetting

WithGuildIntegrationExpireBehavior sets the behavior when an integration subscription lapses.

func WithGuildIntegrationExpireGracePeriod

func WithGuildIntegrationExpireGracePeriod(v int) GuildIntegrationSetting

WithGuildIntegrationExpireGracePeriod sets the period (in seconds) where the integration will ignore lapsed subscriptions.

type GuildIntegrationSettings

type GuildIntegrationSettings struct {
	ExpireBehavior    *optional.Int  `json:"expire_behavior,omitempty"`
	ExpireGracePeriod *optional.Int  `json:"expire_grace_period,omitempty"`
	EnableEmoticons   *optional.Bool `json:"enable_emoticons,omitempty"`
}

GuildIntegrationSettings describes a guild integration's settings.

func NewGuildIntegrationSettings

func NewGuildIntegrationSettings(opts ...GuildIntegrationSetting) *GuildIntegrationSettings

NewGuildIntegrationSettings returns new GuildIntegrationSettings to modify a a guild integration.

type GuildMember

type GuildMember struct {
	User         *User    `json:"user"`
	Nick         string   `json:"nick"`
	Roles        []string `json:"roles"` // Role IDs.
	JoinedAt     Time     `json:"joined_at"`
	PremiumSince Time     `json:"premium_since"`
	Deaf         bool     `json:"deaf"`
	Mute         bool     `json:"mute"`
}

GuildMember represents a User in a Guild. The field User won't be set in objects attached to MESSAGE_CREATE and MESSAGE_UPDATE gateway events.

func (*GuildMember) Clone

func (m *GuildMember) Clone() *GuildMember

Clone returns a clone of this GuildMember.

func (*GuildMember) HasRole

func (m *GuildMember) HasRole(id string) bool

HasRole returns whether this member has the given role. Note that this method does not try to fetch this member latest roles, it instead looks in the roles it already had when this member object was created.

func (*GuildMember) PermissionsIn

func (m *GuildMember) PermissionsIn(g *Guild, ch *Channel) (permissions int)

PermissionsIn returns the permissions of the Guild member in the given Guild and channel.

type GuildMemberSetting

type GuildMemberSetting func(*GuildMemberSettings)

GuildMemberSetting is a function that configures a guild member.

func WithGuildMemberChannelID

func WithGuildMemberChannelID(id string) GuildMemberSetting

WithGuildMemberChannelID sets the channel id of a guild member (if connected to voice).

func WithGuildMemberDeaf

func WithGuildMemberDeaf(yes bool) GuildMemberSetting

WithGuildMemberDeaf sets whether a guild member is deafen.

func WithGuildMemberMute

func WithGuildMemberMute(yes bool) GuildMemberSetting

WithGuildMemberMute sets whether a guild member is muted.

func WithGuildMemberNick

func WithGuildMemberNick(name string) GuildMemberSetting

WithGuildMemberNick sets the name of a guild member.

func WithGuildMemberRoles

func WithGuildMemberRoles(roleIDs []string) GuildMemberSetting

WithGuildMemberRoles sets the roles of a guild member.

type GuildMemberSettings

type GuildMemberSettings struct {
	Nick  *optional.String      `json:"nick,omitempty"`
	Roles *optional.StringSlice `json:"roles,omitempty"`
	Mute  *optional.Bool        `json:"mute,omitempty"`
	Deaf  *optional.Bool        `json:"deaf,omitempty"`
	// ID of channel to move user to (if they are connected to voice).
	ChannelID *optional.String `json:"channel_id,omitempty"`
}

GuildMemberSettings are the settings of a guild member, all fields are optional and only those explicitly set will be modified.

func NewGuildMemberSettings

func NewGuildMemberSettings(opts ...GuildMemberSetting) *GuildMemberSettings

NewGuildMemberSettings returns new GuildMemberSetting to modify a a guild member.

type GuildSetting

type GuildSetting func(*GuildSettings)

GuildSetting is a function that configures a guild.

func WithGuildAFKChannel

func WithGuildAFKChannel(id string) GuildSetting

WithGuildAFKChannel sets the AFK channel ID of a guild. An empty id will disable the AFK channel.

func WithGuildAFKTimeout

func WithGuildAFKTimeout(t GuildAFKTimeout) GuildSetting

WithGuildAFKTimeout sets the AFK timeout of a guild.

func WithGuildDefaultMessageNotifications

func WithGuildDefaultMessageNotifications(lvl GuildDefaultNotificationLevel) GuildSetting

WithGuildDefaultMessageNotifications sets the default notification level of a guild.

func WithGuildExplicitContentFilter

func WithGuildExplicitContentFilter(lvl GuildExplicitContentFilter) GuildSetting

WithGuildExplicitContentFilter sets the explicit content filter of a guild.

func WithGuildIcon

func WithGuildIcon(icon string) GuildSetting

WithGuildIcon sets the Guild icon which is a base64 encoded 128x128 jpeg image.

func WithGuildName

func WithGuildName(name string) GuildSetting

WithGuildName sets the name of a guild.

func WithGuildOwner

func WithGuildOwner(id string) GuildSetting

WithGuildOwner sets the owner ID of a guild (must be the guild owner to for this to have effect).

func WithGuildRegion

func WithGuildRegion(region string) GuildSetting

WithGuildRegion sets the region of a guild.

func WithGuildSplash

func WithGuildSplash(splash string) GuildSetting

WithGuildSplash sets the Guild splash (VIP only) which is a base64 encoded 128x128 image.

func WithGuildSystemChannel

func WithGuildSystemChannel(id string) GuildSetting

WithGuildSystemChannel sets the id of the channel to which system messages are sent.

func WithGuildVerificationLevel

func WithGuildVerificationLevel(lvl GuildVerificationLevel) GuildSetting

WithGuildVerificationLevel sets the verification level of a guild.

type GuildSettings

type GuildSettings struct {
	Name                        *optional.String `json:"name,omitempty"`
	Region                      *optional.String `json:"region,omitempty"`
	VerificationLevel           *optional.Int    `json:"verification_level,omitempty"`
	DefaultMessageNotifications *optional.Int    `json:"default_message_notifications,omitempty"`
	ExplicitContentFilter       *optional.Int    `json:"explicit_content_filter,omitempty"`
	AFKChannelID                *optional.String `json:"afk_channel_id,omitempty"`
	AFKTimeout                  *optional.Int    `json:"afk_timeout,omitempty"`
	Icon                        *optional.String `json:"icon,omitempty"`
	OwnerID                     *optional.String `json:"owner_id,omitempty"`
	Splash                      *optional.String `json:"splash,omitempty"`
	SystemChannelID             *optional.String `json:"system_channel_id,omitempty"`
}

GuildSettings are the settings of a guild, all fields are optional and only those explicitly set will be modified.

func NewGuildSettings

func NewGuildSettings(opts ...GuildSetting) *GuildSettings

NewGuildSettings returns new GuildSettings to modify a a guild.

type GuildVerificationLevel

type GuildVerificationLevel int

GuildVerificationLevel is the level of verification that applies on a guild. Members must meet criteria before they can send messages or initiate direct message conversations with other guild members. This does not apply for members that have a role assigned to them.

const (
	// GuildVerificationLevelNone means there is no verification.
	GuildVerificationLevelNone GuildVerificationLevel = iota
	// GuildVerificationLevelLow means a member must have
	// a verified email on their account.
	GuildVerificationLevelLow
	// GuildVerificationLevelMedium means a member must be
	// registered on Discord for longer than 5 minutes.
	GuildVerificationLevelMedium
	// GuildVerificationLevelHigh means a member must be
	// in this server for longer than 10 minutes.
	GuildVerificationLevelHigh
	// GuildVerificationLevelVeryHigh means a member must have
	// a verified phone number.
	GuildVerificationLevelVeryHigh
)

type GuildWidget

type GuildWidget struct {
	Enabled   bool   `json:"enabled"`
	ChannelID string `json:"channel_id"`
}

type Invite

type Invite struct {
	Code                     string  `json:"code"`
	Guild                    Guild   `json:"guild"` // Nil if this invite is for a group DM channel.
	Channel                  Channel `json:"channel"`
	ApproximatePresenceCount int     `json:"approximate_presence_count"`
	ApproximateMemberCount   int     `json:"approximate_member_count"`

	InviteMetadata
}

Invite represents a code that when used, adds a user to a guild or group DM channel.

type InviteMetadata

type InviteMetadata struct {
	Inviter   User `json:"inviter"`
	Uses      int  `json:"uses"`
	MaxUses   int  `json:"max_uses"`
	MaxAge    int  `json:"max_age"`
	Temporary bool `json:"temporary"`
	CreatedAt Time `json:"created_at"`
	Revoked   bool `json:"revoked"`
}

InviteMetadata contains additional information about an Invite.

type InviteSetting

type InviteSetting func(*InviteSettings)

InviteSetting is a function that configures an invite.

func WithInviteMaxAge

func WithInviteMaxAge(age time.Duration) InviteSetting

WithInviteMaxAge sets the delay before an invitation expires.

func WithInviteMaxUses

func WithInviteMaxUses(uses int) InviteSetting

WithInviteMaxUses sets the maximum number of uses of an invitation.

func WithInviteTemporary

func WithInviteTemporary(yes bool) InviteSetting

WithInviteTemporary sets whether this invite only grants a temporary membership.

func WithInviteUnique

func WithInviteUnique(yes bool) InviteSetting

WithInviteUnique determines if we should try to reuse a similar existing invite or not (enable this to create many single-use invites).

type InviteSettings

type InviteSettings struct {
	MaxAge    *optional.Int  `json:"max_age,omitempty"`
	MaxUses   *optional.Int  `json:"max_uses,omitempty"`
	Temporary *optional.Bool `json:"temporary,omitempty"`
	Unique    *optional.Bool `json:"unique,omitempty"`
}

InviteSettings describes how to create a channel invite. All fields are optional.

func NewInviteSettings

func NewInviteSettings(opts ...InviteSetting) *InviteSettings

NewInviteSettings returns new InviteSettings to create an invite.

type MFALevel

type MFALevel int

MFALevel is the Multi Factor Authentication level of a guild.

const (
	MFALevelNone     MFALevel = 0
	MFALevelElevated MFALevel = 1
)

type Message

type Message struct {
	ID        string `json:"id"`
	ChannelID string `json:"channel_id"`
	GuildID   string `json:"guild_id"`
	// Author of this message. Can be a user or a webhook.
	// Check the WebhookID field to know.
	Author User `json:"author"`
	// Guild member info of the author that sent the message.
	// Only set for MESSAGE_CREATE and MESSAGE_UPDATE Gateway
	// events.
	Member          GuildMember `json:"member"`
	Content         string      `json:"content"`
	Timestamp       Time        `json:"timestamp"`
	EditedTimestamp Time        `json:"edited_timestamp"`
	TTS             bool        `json:"tts"`
	// MentionEveryone is set to true if '@everyone' or '@here'
	// is set in the message's content.
	MentionEveryone bool `json:"mention_everyone"`
	// Mentions contains an array of users that where mentioned
	// in the message's content.
	Mentions []User `json:"mentions"`
	// MentionRoles contains an array of IDs of te roles that
	// were mentioned in the message's content.
	MentionRoles []string `json:"mention_roles"`
	// Not all channel mentions in a message will appear in mention_channels.
	// Only textual channels that are visible to everyone in a public guild
	// will ever be included. Only cross-posted messages (via Channel Following)
	// currently include mention_channels at all. If no mentions in the message
	// meet these requirements, this field will not be sent.
	MentionChannels []ChannelMention    `json:"mention_channels"`
	Attachments     []MessageAttachment `json:"attachments"` // Any attached files.
	Embeds          []MessageEmbed      `json:"embeds"`      // Any embedded content.
	Reactions       []MessageReaction   `json:"reactions"`
	Nonce           string              `json:"nonce"` // Used for validating a message was sent.
	Pinned          bool                `json:"pinned"`
	WebhookID       string              `json:"webhook_id"`
	Type            MessageType         `json:"type"`

	// Sent with Rich Presence-related chat embeds.
	Activity          MessageActivity    `json:"activity"`
	Application       MessageApplication `json:"application"`
	MessageReference  MessageReference   `json:"message_reference"`
	Flags             MessageFlag        `json:"flags"`
	Stickers          []MessageSticker   `json:"stickers"`
	ReferencedMessage *Message           `json:"referenced_message"`
}

Message represents a message sent in a channel within Discord. The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.

type MessageActivity

type MessageActivity struct {
	Type    MessageActivityType
	PartyID string
}

type MessageActivityType

type MessageActivityType int
const (
	MessageActivityTypeJoin MessageActivityType = iota
	MessageActivityTypeSpectate
	MessageActivityTypeListen
	MessageActivityTypeJoinRequest
)

type MessageApplication

type MessageApplication struct {
	ID          string
	CoverImage  string
	Description string
	Icon        string
	Name        string
}

type MessageAttachment

type MessageAttachment struct {
	ID       string `json:"id"`
	Filename string `json:"filename"`
	Size     int    `json:"size"`
	URL      string `json:"url"`
	ProxyURL string `json:"proxy_url"`
	Height   int    `json:"height"`
	Width    int    `json:"width"`
}

MessageAttachment is a file attached to a message.

type MessageEmbed

type MessageEmbed struct {
	Title       string                 `json:"title,omitempty"`
	Type        MessageEmbedType       `json:"type,omitempty"` // Type of embed (always MessageEmbedTypeRich for webhook embeds).
	Description string                 `json:"description,omitempty"`
	URL         string                 `json:"url,omitempty"`
	Timestamp   Time                   `json:"timestamp,omitempty"`
	Color       int                    `json:"color,omitempty"`
	Footer      *MessageEmbedFooter    `json:"footer,omitempty"`
	Image       *MessageEmbedImage     `json:"image,omitempty"`
	Thumbnail   *MessageEmbedThumbnail `json:"thumbnail,omitempty"`
	Video       *MessageEmbedVideo     `json:"video,omitempty"`
	Provider    *MessageEmbedProvider  `json:"provider,omitempty"`
	Author      *MessageEmbedAuthor    `json:"author,omitempty"`
	Fields      []MessageEmbedField    `json:"fields,omitempty"`
}

MessageEmbed describes some rich content for a Discord message.

type MessageEmbedAuthor

type MessageEmbedAuthor struct {
	Name         string `json:"name,omitempty"`
	URL          string `json:"url,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

MessageEmbedAuthor is the embedded author in a Discord message.

type MessageEmbedField

type MessageEmbedField struct {
	Name   string `json:"name,omitempty"`
	Value  string `json:"value,omitempty"`
	Inline bool   `json:"inline,omitempty"`
}

MessageEmbedField is an embedded field in a Discord message.

type MessageEmbedFooter

type MessageEmbedFooter struct {
	Text         string `json:"text,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

MessageEmbedFooter is a embedded footer in a Discord message.

type MessageEmbedImage

type MessageEmbedImage struct {
	URL      string `json:"url,omitempty"`       // Source url of image (only supports http(s) and attachments).
	ProxyURL string `json:"proxy_url,omitempty"` // A proxied url of the image.
	Height   int    `json:"height,omitempty"`
	Width    int    `json:"width,omitempty"`
}

MessageEmbedImage is an embedded image in a Discord Message.

type MessageEmbedProvider

type MessageEmbedProvider struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

type MessageEmbedThumbnail

type MessageEmbedThumbnail struct {
	URL      string `json:"url,omitempty"`
	ProxyURL string `json:"proxy_url,omitempty"`
	Height   int    `json:"height,omitempty"`
	Width    int    `json:"width,omitempty"`
}

MessageEmbedThumbnail is an embedded thumbnail in a Discord Message.

type MessageEmbedType

type MessageEmbedType string

MessageEmbedType defines the type of an embed message.

const (
	MessageEmbedTypeRich    MessageEmbedType = "rich"
	MessageEmbedTypeImage   MessageEmbedType = "image"
	MessageEmbedTypeVideo   MessageEmbedType = "video"
	MessageEmbedTypeGIFV    MessageEmbedType = "gifv"
	MessageEmbedTypeArticle MessageEmbedType = "article"
	MessageEmbedTypeLink    MessageEmbedType = "link"
)

type MessageEmbedVideo

type MessageEmbedVideo struct {
	URL    string `json:"url,omitempty"`
	Height int    `json:"height,omitempty"`
	Width  int    `json:"width,omitempty"`
}

MessageEmbedVideo is an embedded video in a Discord Message.

type MessageFlag

type MessageFlag int

MessageFlag describes extra features a message can have.

const (
	// This message has been published to subscribed channels (via Channel Following).
	MessageFlagCrossposted MessageFlag = 1 << 0
	// This message originated from a message in another channel (via Channel Following).
	MessageFlagIsCrosspost MessageFlag = 1 << 1
	// Do not include any embeds when serializing this message.
	MessageFlagSuppressEmbeds MessageFlag = 1 << 2
)

type MessageReaction

type MessageReaction struct {
	Count int   `json:"count"`
	Me    bool  `json:"me"`
	Emoji Emoji `json:"emoji"`
}

MessageReaction is a reaction on a Discord message.

type MessageReference

type MessageReference struct {
	MessageID string `json:"message_id"`
	ChannelID string `json:"channel_id"`
	GuildID   string `json:"guild_id"`
}

MessageReference is a reference to an original message.

type MessageSticker

type MessageSticker struct {
	ID           string        `json:"id"`
	PackID       string        `json:"pack_id"`
	Name         string        `json:"name"`
	Description  string        `json:"description"`
	Tags         string        `json:"tags"`
	Asset        string        `json:"asset"`
	PreviewAsset string        `json:"preview_asset"`
	FormatType   StickerFormat `json:"format_type"`
}

type MessageType

type MessageType int

MessageType describes the type of a message. Different fields are set or not depending on the message's type.

const (
	MessageTypeDefault                           MessageType = 0
	MessageTypeRecipientAdd                      MessageType = 1
	MessageTypeRecipientRemove                   MessageType = 2
	MessageTypeCall                              MessageType = 3
	MessageTypeChannelNameChange                 MessageType = 4
	MessageTypeChannelIconChange                 MessageType = 5
	MessageTypeChannelPinnedMessage              MessageType = 6
	MessageTypeGuildMemberJoin                   MessageType = 7
	MessageTypeUserPremiumGuildSubscription      MessageType = 8
	MessageTypeUserPremiumGuildSubscriptionTier1 MessageType = 9
	MessageTypeUserPremiumGuildSubscriptionTier2 MessageType = 10
	MessageTypeUserPremiumGuildSubscriptionTier3 MessageType = 11
	MessageTypeChannelFollowAdd                  MessageType = 12
	MessageTypeGuildDiscoveryDisqualified        MessageType = 14
	MessageTypeGuildDiscoveryRequalified         MessageType = 15
	MessageTypeReply                             MessageType = 19
	MessageTypeCommand                           MessageType = 20
)

Supported message types:

type PartialApplication

type PartialApplication struct {
	ID    string `json:"id"`
	Flags int    `json:"flags"`
}

PartialApplication is a partial application that is part of a Ready event.

type PartialGuild

type PartialGuild struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Icon        string `json:"icon"`
	Owner       bool   `json:"owner"`
	Permissions int    `json:"permissions,string"`
}

PartialGuild is a subset of the Guild object, returned by the Discord API when fetching current user's guilds.

type PermissionOverwrite

type PermissionOverwrite struct {
	Type  int    `json:"type"` // Either 0 for "role" or 1 for "member".
	ID    string `json:"id"`   // ID of the role or member, depending on Type.
	Allow int    `json:"allow,string"`
	Deny  int    `json:"deny,string"`
}

PermissionOverwrite describes a specific permission that overwrites server-wide permissions.

func (*PermissionOverwrite) Clone

Clone returns a clone of this PermissionOverwrite.

type PremiumTier

type PremiumTier int

PremiumTier is the tier of a boosted server.

const (
	PremiumTierNone PremiumTier = 0
	PremiumTier1    PremiumTier = 1
	PremiumTier2    PremiumTier = 2
	PremiumTier3    PremiumTier = 3
)

type PremiumType

type PremiumType int

PremiumType denotes the level of premium a user has.

const (
	PremiumTypeNone         PremiumType = 0
	PremiumTypeNitroClassic PremiumType = 1
	PremiumTypeNitro        PremiumType = 2
)

type Presence

type Presence struct {
	User         *User        `json:"user"`
	GuildID      string       `json:"guild_id"`
	Status       Status       `json:"status"`
	Activities   []Activity   `json:"activities"`
	ClientStatus ClientStatus `json:"client_status"`
}

Presence is a user's current state on a guild. This event is sent when a user's presence is updated for a guild.

func (*Presence) Clone

func (p *Presence) Clone() *Presence

Clone returns a clone of this Presence.

type Role

type Role struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Color       int    `json:"color"`    // Integer representation of hexadecimal color code.
	Hoist       bool   `json:"hoist"`    // Whether this role is pinned in the user listing.
	Position    int    `json:"position"` // Integer	position of this role.
	Permissions int    `json:"permissions,string"`
	Managed     bool   `json:"managed"` // Whether this role is managed by an integration.
	Mentionable bool   `json:"mentionable"`
}

Role represents a set of permissions attached to a group of users. Roles have unique names, colors, and can be "pinned" to the side bar, causing their members to be listed separately. Roles are unique per guild, and can have separate permission profiles for the global context (guild) and channel context.

func (*Role) Clone

func (r *Role) Clone() *Role

Clone returns a clone of this Role.

type RoleSetting

type RoleSetting func(*RoleSettings)

RoleSetting is a function that configures a guild role.

func WithRoleColor

func WithRoleColor(hexCode int) RoleSetting

WithRoleColor sets the color of guild a role. It accepts hexadecimal value.

func WithRoleHoist

func WithRoleHoist(yes bool) RoleSetting

WithRoleHoist sets whether this guild role is hoisted.

func WithRoleMentionable

func WithRoleMentionable(yes bool) RoleSetting

WithRoleMentionable sets whether this guild role is mentionable by others.

func WithRoleName

func WithRoleName(name string) RoleSetting

WithRoleName sets the name of guild a role.

func WithRolePermissions

func WithRolePermissions(perm int) RoleSetting

WithRolePermissions sets the permissions of guild a role.

type RoleSettings

type RoleSettings struct {
	Name        *optional.String `json:"name,omitempty"`
	Permissions *optional.String `json:"permissions,omitempty"`
	Color       *optional.Int    `json:"color,omitempty"`
	Hoist       *optional.Bool   `json:"hoist,omitempty"`
	Mentionable *optional.Bool   `json:"mentionable,omitempty"`
}

RoleSettings describes how to modify a guild role, all fields are optional and only those explicitly set will be modified.

func NewRoleSettings

func NewRoleSettings(opts ...RoleSetting) *RoleSettings

NewRoleSettings returns new RoleSettings to modify a a guild role.

type Status

type Status string

Status is the current presence status of a user.

const (
	StatusOnline    Status = "online"
	StatusIdle      Status = "idle"
	StatusDND       Status = "dnd"
	StatusInvisible Status = "invisible"
	StatusOffline   Status = "offline"
)

Valid presence status:

type StickerFormat

type StickerFormat int

StickerFormat is the format of a MessageSticker.

const (
	StickerFormatPNG    StickerFormat = 1
	StickerFormatAPNG   StickerFormat = 2
	StickerFormatLOTTIE StickerFormat = 3
)

type SystemChannelFlag

type SystemChannelFlag int

SystemChannelFlag are flags that customize the behavior of the system channel.

const (
	SystemChannelFlagSupressJoinNotifications    SystemChannelFlag = 1 << 0
	SystemChannelFlagSupressPremiumSubscriptions SystemChannelFlag = 1 << 1
)

type Team

type Team struct {
	ID          string       `json:"id"`
	Members     []TeamMember `json:"members"`
	OwnerUserID string       `json:"owner_member_id"`
	Icon        string       `json:"icon"`
}

Team represents a Discord developer team.

type TeamMember

type TeamMember struct {
	TeamID          string   `json:"team_id"`
	User            User     `json:"user"`
	MembershipState int      `json:"membership_state"`
	Permissions     []string `json:"permissions"`
}

TeamMember is a member part of a Discord developer team.

type Time

type Time struct {
	time.Time
}

Time wraps the standard time.Time structure and handles zero-value JSON marshaling properly.

func TimeFromStd

func TimeFromStd(t time.Time) Time

TimeFromStd converts a time.Time to a Time.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Time) Std

func (t Time) Std() time.Time

Std returns the standard time.Time value this Time represents.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type UnavailableGuild

type UnavailableGuild struct {
	ID          string `json:"id"`
	Unavailable *bool  `json:"unavailable"` // If not set, the connected user was removed from this Guild.
}

UnavailableGuild is a Guild that is not available, either because there is a guild outage or because the connected user was removed from this guild.

func (*UnavailableGuild) Clone

func (g *UnavailableGuild) Clone() *UnavailableGuild

Clone returns a clone of this UnavailableGuild.

type User

type User struct {
	ID            string      `json:"id"`
	Username      string      `json:"username"`
	Discriminator string      `json:"discriminator"`
	Avatar        string      `json:"avatar"`
	Locale        string      `json:"locale"`
	Email         string      `json:"email"`
	Verified      bool        `json:"verified"`
	MFAEnabled    bool        `json:"mfa_enabled"`
	Bot           bool        `json:"bot"`
	System        bool        `json:"system"`
	PremiumType   PremiumType `json:"premium_type"`
	Flags         UserFlag    `json:"flags"`
	PublicFlags   UserFlag    `json:"public_flags"`
}

User in Discord is generally considered the base entity. Users can spawn across the entire platform, be members of guilds, participate in text and voice chat, and much more. Users are separated by a distinction of "bot" vs "normal." Although they are similar, bot users are automated users that are "owned" by another user. Unlike normal users, bot users do not have a limitation on the number of Guilds they can be a part of.

func (*User) AvatarURL

func (u *User) AvatarURL() string

AvatarURL returns the user's avatar URL.

func (*User) Clone

func (u *User) Clone() *User

Clone returns a clone of this User.

type UserConnection

type UserConnection struct {
	ID           string             `json:"id"`
	Name         string             `json:"name"`
	Type         string             `json:"type"`
	Revoked      bool               `json:"revoked"`
	Integrations []GuildIntegration `json:"integrations"` // Partial server integrations.
	Verified     bool               `json:"verified"`
	FriendSync   bool               `json:"friend_sync"`
	ShowActivity bool               `json:"show_activity"`
	Visibility   Visibility         `json:"visibility"`
}

UserConnection that the user has attached.

type UserFlag

type UserFlag int

UserFlag are specific attributes a User can have.

const (
	UserFlagNone                      UserFlag = 0
	UserFlagDiscordEmployee           UserFlag = 1 << 0
	UserFlagPartneredServerOwner      UserFlag = 1 << 1
	UserFlagHypeSquadEvents           UserFlag = 1 << 2
	UserFlagBugHunterLevel1           UserFlag = 1 << 3
	UserFlagHouseBravery              UserFlag = 1 << 6
	UserFlagHouseBrilliance           UserFlag = 1 << 7
	UserFlagHouseBalance              UserFlag = 1 << 8
	UserFlagEarlySupporter            UserFlag = 1 << 9
	UserFlagTeamUser                  UserFlag = 1 << 10
	UserFlagSystem                    UserFlag = 1 << 12
	UserFlagBugHunterLevel2           UserFlag = 1 << 14
	UserFlagVerifiedBot               UserFlag = 1 << 16
	UserFlagEarlyVerifiedBotDeveloper UserFlag = 1 << 17
)

type ValidationError

type ValidationError struct {
	HTTPCode int
	Errors   map[string]json.RawMessage `json:"errors"`
}

ValidationError is a validation error returned by the Discord HTTP API when it receives invalid parameters.

func (ValidationError) Error

func (e ValidationError) Error() string

Error implements the error interface.

type Visibility

type Visibility int
const (
	VisibilityNone     Visibility = 0
	VisibilityEveryone Visibility = 1
)

type VoiceRegion

type VoiceRegion struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Whether this is a vip-only server.
	VIP bool `json:"vip"`
	// Whether this is a single server that is closest to the current user's client.
	Optimal bool `json:"optimal"`
	// Whether this is a deprecated voice region (avoid switching to these.
	Deprecated bool `json:"deprecated"`
	// Whether this is a custom voice region (used for events/etc).
	Custom bool `json:"custom"`
}

VoiceRegion represents a voice region a guild can use or is using for its voice channels.

type Webhook

type Webhook struct {
	ID        string `json:"id"`
	GuildID   string `json:"guild_id"`
	ChannelID string `json:"channel_id"`
	User      *User  `json:"user"`
	Name      string `json:"name"`
	Avatar    string `json:"avatar"`
	Token     string `json:"token"`
}

Webhook is a low-effort way to post messages to channels in Discord. It do not require a bot user or authentication to use.

type WebhookParameter

type WebhookParameter func(*WebhookParameters)

WebhookParameter is a function that sets webhook parameters.

func WithWebhookAvatarURL

func WithWebhookAvatarURL(content string) WebhookParameter

WithWebhookAvatarURL sets the content of a webhook.

func WithWebhookContent

func WithWebhookContent(content string) WebhookParameter

WithWebhookContent sets the content of a webhook.

func WithWebhookEmbeds

func WithWebhookEmbeds(embeds []MessageEmbed) WebhookParameter

WithWebhookEmbeds sets the content of a webhook.

func WithWebhookFiles

func WithWebhookFiles(files []File) WebhookParameter

WithWebhookFiles sets the content of a webhook.

func WithWebhookTTS

func WithWebhookTTS(yes bool) WebhookParameter

WithWebhookTTS sets the content of a webhook.

func WithWebhookUsername

func WithWebhookUsername(content string) WebhookParameter

WithWebhookUsername sets the content of a webhook.

type WebhookParameters

type WebhookParameters struct {
	Content   *optional.String `json:"content,omitempty"`
	Username  *optional.String `json:"username,omitempty"`
	AvatarURL *optional.String `json:"avatar_url,omitempty"`
	TTS       *optional.Bool   `json:"tts,omitempty"`
	Embeds    []MessageEmbed   `json:"embeds,omitempty"`
	Files     []File           `json:"-"`
}

WebhookParameters are the parameters available when executing a webhook with ExecWebhook.

func NewWebhookParameters

func NewWebhookParameters(opts ...WebhookParameter) *WebhookParameters

NewWebhookParameters returns new WebhookParameters to modify a a webhook.

func (*WebhookParameters) Bytes

func (p *WebhookParameters) Bytes() ([]byte, error)

Bytes implements the rest.MultipartPayload interface so WebhookParameters can be used as a payload with the rest.MultipartFromFiles function.

type WebhookSetting

type WebhookSetting func(*WebhookSettings)

WebhookSetting is a function that configures a webhook.

func WithWebhookAvatar

func WithWebhookAvatar(name string) WebhookSetting

WithWebhookAvatar sets the avatar of a webhook.

func WithWebhookChannel

func WithWebhookChannel(id string) WebhookSetting

WithWebhookChannel sets the channel ID of a webhook.

func WithWebhookName

func WithWebhookName(name string) WebhookSetting

WithWebhookName sets the name of a webhook.

type WebhookSettings

type WebhookSettings struct {
	Name *optional.String `json:"name,omitempty"`
	// Avatar is a data URI scheme that support JPG, GIF, and PNG formats, see
	// https://discord.com/developers/docs/resources/user#avatar-data
	// for more information.
	Avatar    *optional.String `json:"avatar,omitempty"`
	ChannelID *optional.String `json:"channel_id,omitempty"`
}

WebhookSettings describes a webhook's settings.

func NewWebhookSettings

func NewWebhookSettings(opts ...WebhookSetting) *WebhookSettings

NewWebhookSettings returns new WebhookSettings to modify a a webhook.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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