discord

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: ISC Imports: 13 Imported by: 308

Documentation

Overview

Package discord provides common structures that the whole repository uses. It does not (and should not) contain API-specific structures, or WS-specific structures.

Index

Examples

Constants

View Source
const (
	RoleCommandPermission = iota + 1
	UserCommandPermission
)

https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permission-type

View Source
const (
	MemberFlagsDidRejoin = 1 << iota
	MemberFlagsCompletedOnboarding
	MemberFlagsBypassesVerification
	MemberFlagsStartedOnboarding
)
View Source
const (
	StickerFormatPNG    = 1
	StickerFormatAPNG   = 2
	StickerFormatLottie = 3
)

https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types

View Source
const DefaultMaxPresences = 25000

Guild.MaxPresences is this value when it's 0. This happens because the Discord API sends JSON null, if the MaxPresences reach DefaultMaxPresences, which in turn will be serialized into 0.

View Source
const Epoch = 1420070400000 * time.Millisecond

Epoch is the Discord epoch constant in time.Duration (nanoseconds) since Unix epoch.

View Source
const GuildNews = GuildAnnouncement

GuildNews aliases to GuildAnnouncement.

Deprecated: use GuildAnnouncement instead.

View Source
const GuildNewsThread = GuildAnnouncementThread

GuildNewsThread aliases to GuildAnnouncementThread.

Deprecated: use GuildAnnouncementThread instead.

View Source
const NullAppID = AppID(NullSnowflake)

NullAppID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullAttachmentID = AttachmentID(NullSnowflake)

NullAttachmentID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullAuditLogEntryID = AuditLogEntryID(NullSnowflake)

NullAuditLogEntryID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullAutoModerationRuleID = AutoModerationRuleID(NullSnowflake)

NullAutoModerationRuleID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullChannelID = ChannelID(NullSnowflake)

NullChannelID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullCommandID = CommandID(NullSnowflake)

NullCommandID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullEmojiID = EmojiID(NullSnowflake)

NullEmojiID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullEntityID = EntityID(NullSnowflake)

NullEntityID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullEventID = EventID(NullSnowflake)

NullEventID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullGuildID = GuildID(NullSnowflake)

NullGuildID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullIntegrationID = IntegrationID(NullSnowflake)

NullIntegrationID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullInteractionID = InteractionID(NullSnowflake)

NullInteractionID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullMessageID = MessageID(NullSnowflake)

NullMessageID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullRoleID = RoleID(NullSnowflake)

NullRoleID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullSecond = -1

NullSecond is used in cases where null should be used instead of a number or omitted. This is similar to NullSnowflake.

View Source
const NullSnowflake = ^Snowflake(0)

NullSnowflake gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullStageID = StageID(NullSnowflake)

NullStageID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullStickerID = StickerID(NullSnowflake)

NullStickerID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullStickerPackID = StickerPackID(NullSnowflake)

NullStickerPackID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullTagID = TagID(NullSnowflake)

NullTagID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullTeamID = TeamID(NullSnowflake)

NullTeamID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullUserID = UserID(NullSnowflake)

NullUserID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const NullWebhookID = WebhookID(NullSnowflake)

NullWebhookID gets encoded into a null. This is used for optional and nullable snowflake fields.

View Source
const TimestampFormat = time.RFC3339 // same as ISO8601

Variables

View Source
var ZeroOptionalSeconds = NewOptionalSeconds(0)

ZeroOptionalSeconds are 0 OptionalSeconds.

Functions

func DurationSinceEpoch

func DurationSinceEpoch(t time.Time) time.Duration

DurationSinceEpoch returns the duration from the Discord epoch to current.

func HasFlag

func HasFlag(flag, has uint64) bool

HasFlag is returns true if has is in the flag. In other words, it checks if has is OR'ed into flag. This function could be used for different constants such as Permission.

func SortRolesByPosition added in v3.3.5

func SortRolesByPosition(roles []Role)

SortRolesByPosition sorts the roles by their position. Roles with a higher position will be first in the slice, similar to how Discord sorts roles in the client.

Types

type APIEmoji

type APIEmoji string

APIEmoji represents an emoji identifier string formatted to be used with the API. It is formatted using Emoji's APIString method as well as the NewCustomEmoji function. If the emoji is a stock Unicode emoji, then this string contains it. Otherwise, it is formatted like "emoji_name:123123123", where "123123123" is the emoji ID.

func NewAPIEmoji

func NewAPIEmoji(id EmojiID, name string) APIEmoji

NewAPIEmoji creates a new APIEmoji string from the given emoji ID and name.

func NewCustomEmoji deprecated

func NewCustomEmoji(id EmojiID, name string) APIEmoji

NewCustomEmoji creates a new Emoji using a custom guild emoji as base. Unicode emojis should be directly converted.

Deprecated: Use NewAPIEmoji, it does the same exact thing.

func (APIEmoji) PathString

func (e APIEmoji) PathString() string

PathString returns the APIEmoji as a path-encoded string.

type ActionRowComponent

type ActionRowComponent []InteractiveComponent

ActionRow is a row of components at the bottom of a message. Its type, InteractiveComponent, ensures that only non-ActionRow components are allowed on it.

func (*ActionRowComponent) Find added in v3.1.0

func (a *ActionRowComponent) Find(customID ComponentID) Component

Find finds any component with the given custom ID.

func (*ActionRowComponent) MarshalJSON

func (a *ActionRowComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the action row in the format Discord expects.

func (*ActionRowComponent) Type

Type implements the Component interface.

func (*ActionRowComponent) UnmarshalJSON

func (a *ActionRowComponent) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON into the components. It does type-checking and will only accept interactive components.

type Activity

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

	Type ActivityType `json:"type"`

	Instance bool          `json:"instance,omitempty"`
	Flags    ActivityFlags `json:"flags,omitempty"`

	CreatedAt  UnixTimestamp       `json:"created_at,omitempty"`
	Timestamps *ActivityTimestamps `json:"timestamps,omitempty"`

	AppID   AppID  `json:"application_id,omitempty"`
	Details string `json:"details,omitempty"`
	State   string `json:"state,omitempty"` // party status
	Emoji   *Emoji `json:"emoji,omitempty"`

	Party   *ActivityParty   `json:"party,omitempty"`
	Assets  *ActivityAssets  `json:"assets,omitempty"`
	Secrets *ActivitySecrets `json:"secrets,omitempty"`

	// Undocumented fields
	SyncID    string `json:"sync_id,omitempty"`
	SessionID string `json:"session_id,omitempty"`
}

type ActivityAssets

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

type ActivityFlags

type ActivityFlags uint32
const (
	InstanceActivity ActivityFlags = 1 << iota
	JoinActivity
	SpectateActivity
	JoinRequestActivity
	SyncActivity
	PlayActivity
)

type ActivityParty

type ActivityParty struct {
	ID   string `json:"id,omitempty"`
	Size [2]int `json:"size,omitempty"` // [ current, max ]
}

type ActivitySecrets

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

type ActivityTimestamps

type ActivityTimestamps struct {
	Start UnixMsTimestamp `json:"start,omitempty"`
	End   UnixMsTimestamp `json:"end,omitempty"`
}

type ActivityType

type ActivityType uint8
const (
	GameActivity      ActivityType = iota // Playing $name
	StreamingActivity                     // Streaming $details
	ListeningActivity                     // Listening to $name
	WatchingActivity                      // Watching $name
	CustomActivity                        // $emoji $state
	CompetingActivity                     // Competing in $name
)

type AppID

type AppID Snowflake

AppID is the snowflake type for a AppID.

func (AppID) Increment

func (s AppID) Increment() uint16

func (AppID) IsNull

func (s AppID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (AppID) IsValid

func (s AppID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (AppID) MarshalJSON

func (s AppID) MarshalJSON() ([]byte, error)

func (AppID) PID

func (s AppID) PID() uint8

func (AppID) String

func (s AppID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (AppID) Time

func (s AppID) Time() time.Time

func (*AppID) UnmarshalJSON

func (s *AppID) UnmarshalJSON(v []byte) error

func (AppID) Worker

func (s AppID) Worker() uint8

type Application

type Application struct {
	// ID is the ID of the app.
	ID AppID `json:"id"`
	// Name is the name of the app.
	Name string `json:"name"`
	// Icon is the icon hash of the app.
	Icon *Hash `json:"icon"`
	// Description is the description of the app.
	Description string `json:"description"`
	// RPCOrigins is the RPC origin urls, if RPC is enabled.
	RPCOrigins []string `json:"rpc_origins"`
	// BotPublic is whether users besides the app owner can join the app's bot
	// to guilds.
	BotPublic bool `json:"bot_public"`
	// BotRequiredCodeGrant is whether the app's bot will only join upon
	// completion of the full oauth2 code grant flow.
	BotRequireCodeGrant bool `json:"bot_require_code_grant"`
	// TermsOfServiceURL is the url of the app's terms of service.
	TermsOfServiceURL string `json:"terms_of_service_url"`
	// PrivacyPolicyURL is the url of the app's privacy policy.
	PrivacyPolicyURL string `json:"privacy_policy_url"`
	// Owner is a partial user object containing info on the owner of the
	// application.
	Owner *User `json:"owner"`
	// VerifyKey is the hex encoded key for verification in interactions and
	// the GameSDK's GetTicket.
	VerifyKey string `json:"verify_key"`
	// Team is the team that the application belongs to, if it belongs to one.
	Team *Team `json:"team"`
	// CoverImage the application's default rich presence invite cover image
	// hash.
	CoverImage *Hash `json:"cover_image"`
	// Flags is the application's public flags.
	Flags ApplicationFlags `json:"flags"`

	// Summary is the summary field for the store page of the game's primary
	// SKU.
	Summary string `json:"summary"`
	// GuildID is the guild to which the game has been linked.
	GuildID GuildID `json:"guild_ID"`
	// PrimarySKUID is the ID of the "Game SKU" that is created, if it exists.
	PrimarySKUID Snowflake `json:"primary_sku_id"`
	// Slug is the URL slug that links to the game's store page.
	Slug string `json:"slug"`
	// Tags is a slice of strings containing up to 5 tags describing the content and functionality of the application
	Tags []string `json:"tags,omitempty"`
	// InstallParams is the settings for the application's default in-app authorization link, if enabled.
	InstallParams InstallParams `json:"install_params,omitempty"`
	// CustomInstallURL is the application's default custom authorization link, if enabled.
	CustomInstallURL string `json:"custom_install_url,omitempty"`
	// RoleConnectionsVerificationURL is the application's role connection verification entry point, which when configured will render the app as a verification method in the guild role verification configuration.
	RoleConnectionsVerificationURL string `json:"role_connections_verification_url,omitempty"`
}

type ApplicationFlags

type ApplicationFlags uint32
const (
	AppFlagGatewayPresence ApplicationFlags = 1 << (iota + 12)
	AppFlagGatewayPresenceLimited
	AppFlagGatewayGuildMembers
	AppFlagGatewayGuildMembersLimited
	AppFlagVerificationPendingGuildLimit
	AppFlagEmbedded
)
const AppFlagAutoModerationRuleCreateBadge ApplicationFlags = 1 << 6

type ArchiveDuration

type ArchiveDuration int

ArchiveDuration is the duration after which a thread without activity will be archived.

The duration's unit is minutes.

const (
	OneHourArchive ArchiveDuration = 60
	OneDayArchive  ArchiveDuration = 24 * OneHourArchive
	// ThreeDaysArchive archives a thread after three days.
	//
	// This duration is only available to nitro boosted guilds. The Features
	// field of a Guild will indicate whether this is the case.
	ThreeDaysArchive ArchiveDuration = 3 * OneDayArchive
	// SevenDaysArchive archives a thread after seven days.
	//
	// This duration is only available to nitro boosted guilds. The Features
	// field of a Guild will indicate whether this is the case.
	SevenDaysArchive ArchiveDuration = 7 * OneDayArchive
)

func (ArchiveDuration) Duration

func (m ArchiveDuration) Duration() time.Duration

func (ArchiveDuration) String

func (m ArchiveDuration) String() string

type Attachment

type Attachment struct {
	// ID is the attachment id.
	ID AttachmentID `json:"id"`
	// Filename is the name of file attached.
	Filename string `json:"filename"`
	// Description is the attachment's description. It is a maximum of 1024
	// characters long.
	Description string `json:"description,omitempty"`
	// ContentType is the media type of file.
	ContentType string `json:"content_type,omitempty"`
	// Size is the size of file in bytes.
	Size uint64 `json:"size"`

	// URL is the source url of file.
	URL URL `json:"url"`
	// Proxy is the a proxied url of file.
	Proxy URL `json:"proxy_url"`

	// Height is the height of the file, if it is an image.
	Height uint `json:"height,omitempty"`
	// Width is the width of the file, if it is an image.
	Width uint `json:"width,omitempty"`
	// Ephemeral is whether this attachment is ephemeral. Ephemeral attachments
	// will automatically be removed after a set period of time. Ephemeral
	// attachments on messages are guaranteed to be available as long as
	// the message itself exists.
	Ephemeral bool `json:"ephemeral,omitempty"`
}

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

type AttachmentID

type AttachmentID Snowflake

AttachmentID is the snowflake type for a AttachmentID.

func (AttachmentID) Increment

func (s AttachmentID) Increment() uint16

func (AttachmentID) IsNull

func (s AttachmentID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (AttachmentID) IsValid

func (s AttachmentID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (AttachmentID) MarshalJSON

func (s AttachmentID) MarshalJSON() ([]byte, error)

func (AttachmentID) PID

func (s AttachmentID) PID() uint8

func (AttachmentID) String

func (s AttachmentID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (AttachmentID) Time

func (s AttachmentID) Time() time.Time

func (*AttachmentID) UnmarshalJSON

func (s *AttachmentID) UnmarshalJSON(v []byte) error

func (AttachmentID) Worker

func (s AttachmentID) Worker() uint8

type AttachmentOption

type AttachmentOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

AttachmentOption is a subcommand option that fits into a CommandOptionValue.

func (*AttachmentOption) MarshalJSON

func (a *AttachmentOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals AttachmentOption to JSON with the "type" field.

func (*AttachmentOption) Name

func (n *AttachmentOption) Name() string

Name implements CommandOption.

func (*AttachmentOption) Type

Type implements CommandOptionValue.

type AuditEntryInfo

type AuditEntryInfo struct {
	// ApplicationID is the ID of the application whose permissions were targeted.
	//
	// Events: APPLICATION_COMMAND_PERMISSION_UPDATE
	ApplicationID AppID `json:"application_id"`
	// AutoModerationRuleName is the name of the Auto Moderation rule that was triggered.
	//
	// Events: AUTO_MODERATION_BLOCK_MESSAGE, AUTO_MODERATION_FLAG_TO_CHANNEL, AUTO_MODERATION_USER_COMMUNICATION_DISABLED
	AutoModerationRuleName string `json:"auto_moderation_rule_name"`
	// AutoModerationRuleTriggerType is the trigger type of the Auto Moderation rule that was triggered.
	//
	// Events: AUTO_MODERATION_BLOCK_MESSAGE, AUTO_MODERATION_FLAG_TO_CHANNEL, AUTO_MODERATION_USER_COMMUNICATION_DISABLED
	AutoModerationRuleTriggerType string `json:"auto_moderation_rule_trigger_type"`
	// DeleteMemberDays is the number of days after which inactive members were
	// kicked.
	//
	// Events: MEMBER_PRUNE
	DeleteMemberDays string `json:"delete_member_days,omitempty"`
	// MembersRemoved is the number of members removed by the prune.
	//
	// Events: MEMBER_PRUNE
	MembersRemoved string `json:"members_removed,omitempty"`
	// ChannelID is the id of the channel in which the entities were targeted.
	//
	// Events: MEMBER_MOVE, MESSAGE_PIN, MESSAGE_UNPIN, MESSAGE_DELETE
	ChannelID ChannelID `json:"channel_id,omitempty"`
	// MessagesID is the id of the message that was targeted.
	//
	// Events: MESSAGE_PIN, MESSAGE_UNPIN
	MessageID MessageID `json:"message_id,omitempty"`
	// Count is the number of entities that were targeted.
	//
	// Events: MESSAGE_DELETE, MESSAGE_BULK_DELETE, MEMBER_DISCONNECT,
	// MEMBER_MOVE
	Count string `json:"count,omitempty"`
	// ID is the id of the overwritten entity.
	//
	// Events: CHANNEL_OVERWRITE_CREATE, CHANNEL_OVERWRITE_UPDATE,
	// CHANNEL_OVERWRITE_DELETE
	ID Snowflake `json:"id,omitempty"`
	// Type is the type of overwritten entity.
	//
	// Events: CHANNEL_OVERWRITE_CREATE, CHANNEL_OVERWRITE_UPDATE,
	// CHANNEL_OVERWRITE_DELETE
	Type OverwriteType `json:"type,string,omitempty"`
	// RoleName is the name of the role if type is "role".
	//
	// Events: CHANNEL_OVERWRITE_CREATE, CHANNEL_OVERWRITE_UPDATE,
	// CHANNEL_OVERWRITE_DELETE
	RoleName string `json:"role_name,omitempty"`
	// IntegrationType is the type of the integration which performed the action.
	//
	// Events: MEMBER_KICK, MEMBER_ROLE_UPDATE
	IntegrationType string `json:"integration_type"`
}

https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info

type AuditLog

type AuditLog struct {
	// Webhooks is the list of webhooks found in the audit log.
	Webhooks []Webhook `json:"webhooks"`
	// Users is the list of users found in the audit log.
	Users []User `json:"users"`
	// Entries is the list of audit log entries.
	Entries []AuditLogEntry `json:"audit_log_entries"`
	// Integrations is a list ist of partial integration objects (only ID,
	// Name, Type, and Account).
	Integrations []Integration `json:"integrations"`
}

https://discord.com/developers/docs/resources/audit-log#audit-log-object

type AuditLogChange

type AuditLogChange struct {
	// Key is the name of audit log change key.
	Key AuditLogChangeKey `json:"key"`
	// NewValue is the new value of the key.
	NewValue json.Raw `json:"new_value,omitempty"`
	// OldValue is the old value of the key.
	OldValue json.Raw `json:"old_value,omitempty"`
}

AuditLogChange is a single key type to changed value audit log entry. The type can be found in the key's comment. Values can be nil.

What

I'm glad to see the same reaction that I had on you. In short, in this struct, the Key dictates what type NewValue and OldValue will have. They will always be the same type, but I will leave that as JSON for the user.

Usage

The usage of this is pretty simple, as AuditLogChange already has a convenient method to use. Here's an example on how to do "owner_id":

if change.Key != discord.AuditGuildOwnerID {
    return errors.New("not owner ID")
}

// We know these are UserIDs because the comment said so for AuditGuildOwnerID.
var oldOwnerID, newOwnerID discord.UserID
if err := change.UnmarshalValues(&oldOwnerID, &newOwnerID); err != nil {
    return err
}

log.Println("Transferred ownership from user", oldOwnerID, "to", newOwnerID)

func (AuditLogChange) UnmarshalValues

func (a AuditLogChange) UnmarshalValues(old, new interface{}) error

UnmarshalValues unmarshals the values of the AuditLogChange into the passed interfaces.

type AuditLogChangeKey

type AuditLogChangeKey string
const (
	// AuditGuildName gets sent if the guild's name was changed.
	//
	// Type: string
	AuditGuildName AuditLogChangeKey = "name"
	// AuditGuildIconHash gets sent if the guild's icon was changed.
	//
	// Type: Hash
	AuditGuildIconHash AuditLogChangeKey = "icon_hash"
	// AuditGuildSplashHash gets sent if the guild's invite splash page artwork
	// was changed.
	//
	// Type: Hash
	AuditGuildSplashHash AuditLogChangeKey = "splash_hash"
	// AuditGuildOwnerID gets sent if the guild's owner changed.
	//
	// Type: UserID
	AuditGuildOwnerID AuditLogChangeKey = "owner_id"
	// AuditGuildRegion gets sent if the guild's region changed.
	//
	// Type: string
	AuditGuildRegion AuditLogChangeKey = "region"
	// AuditGuildAFKChannelID gets sent if the guild's afk channel changed.
	//
	// Type: ChannelID
	AuditGuildAFKChannelID AuditLogChangeKey = "afk_channel_id"
	// AuditGuildAFKTimeout gets sent if the guild's afk timeout duration
	// changed.
	//
	// Type: Seconds
	AuditGuildAFKTimeout AuditLogChangeKey = "afk_timeout"
	// AuditGuildMFA gets sent if the two-factor auth requirement changed.
	//
	// Type: MFALevel
	AuditGuildMFA AuditLogChangeKey = "mfa_level"
	// AuditGuildVerification gets sent if the guild's required verification
	// level changed
	//
	// Type: Verification
	AuditGuildVerification AuditLogChangeKey = "verification_level"
	// AuditGuildExplicitFilter gets sent if there was a change in whose
	// messages are scanned and deleted for explicit content in the server.
	//
	// Type: ExplicitFilter
	AuditGuildExplicitFilter AuditLogChangeKey = "explicit_content_filter"
	// AuditGuildNotification gets sent if the default message notification
	// level changed.
	//
	// Type: Notification
	AuditGuildNotification AuditLogChangeKey = "default_message_notifications"
	// AuditGuildVanityURLCode gets sent if the guild invite vanity URL
	// changed.
	//
	// Type: string
	AuditGuildVanityURLCode AuditLogChangeKey = "vanity_url_code"
	// AuditGuildRoleAdd gets sent if a new role was added.
	//
	// Type: []Role{ID, Name}
	AuditGuildRoleAdd AuditLogChangeKey = "$add"
	// AuditGuildRoleRemove gets sent if a role was removed.
	//
	// Type: []Role{ID, Name}
	AuditGuildRoleRemove AuditLogChangeKey = "$remove"
	// AuditGuildPruneDeleteDays gets sent if there was a change in number of
	// days after which inactive and role-unassigned members are kicked.
	//
	// Type: int
	AuditGuildPruneDeleteDays AuditLogChangeKey = "prune_delete_days"
	// AuditGuildWidgetEnabled gets sent if the guild's widget was
	// enabled/disabled.
	//
	// Type: bool
	AuditGuildWidgetEnabled AuditLogChangeKey = "widget_enabled"
	// AuditGuildWidgetChannelID gets sent if the channel ID of the guild
	// widget changed.
	//
	// Type: ChannelID
	AuditGuildWidgetChannelID AuditLogChangeKey = "widget_channel_id"
	// AuditGuildSystemChannelID gets sent if the ID of the guild's system
	// channel changed.
	//
	// Type: ChannelID
	AuditGuildSystemChannelID AuditLogChangeKey = "system_channel_id"
)

https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key

const (
	// AuditChannelPosition gets sent if a text or voice channel position was
	// changed.
	//
	// Type: int
	AuditChannelPosition AuditLogChangeKey = "position"
	// AuditChannelTopic gets sent if the text channel topic changed.
	//
	// Type: string
	AuditChannelTopic AuditLogChangeKey = "topic"
	// AuditChannelBitrate gets sent if the voice channel bitrate changed.
	//
	// Type: uint
	AuditChannelBitrate AuditLogChangeKey = "bitrate"
	// AuditChannelPermissionOverwrites gets sent if the permissions on a
	// channel changed.
	//
	// Type: []Overwrite
	AuditChannelPermissionOverwrites AuditLogChangeKey = "permission_overwrites"
	// AuditChannelNSFW gets sent if the channel NSFW restriction changed.
	//
	// Type: bool
	AuditChannelNSFW AuditLogChangeKey = "nsfw"
	// AuditChannelApplicationID contains the application ID of the added or
	// removed webhook or bot.
	//
	// Type: AppID
	AuditChannelApplicationID AuditLogChangeKey = "application_id"
	// AuditChannelRateLimitPerUser gets sent if the amount of seconds a user
	// has to wait before sending another message changed.
	//
	// Type: Seconds
	AuditChannelRateLimitPerUser AuditLogChangeKey = "rate_limit_per_user"
)
const (
	// AuditRolePermissions gets sent if the permissions for a role changed.
	//
	// Type: Permissions
	AuditRolePermissions AuditLogChangeKey = "permissions"
	// AuditRoleColor gets sent if the role color changed.
	//
	// Type: Color
	AuditRoleColor AuditLogChangeKey = "color"
	// AuditRoleHoist gets sent if the role is now displayed/no longer
	// displayed separate from online users.
	//
	// Type: bool
	AuditRoleHoist AuditLogChangeKey = "hoist"
	// AuditRoleMentionable gets sent if a role is now
	// mentionable/unmentionable.
	//
	// Type: bool
	AuditRoleMentionable AuditLogChangeKey = "mentionable"
	// AuditRoleAllow gets sent if a permission on a text or voice channel was
	// allowed for a role.
	//
	// Type: Permissions
	AuditRoleAllow AuditLogChangeKey = "allow"
	// AuditRoleDeny gets sent if a permission on a text or voice channel was
	// denied for a role.
	//
	// Type: Permissions
	AuditRoleDeny AuditLogChangeKey = "deny"
)
const (
	// AuditInviteCode gets sent if an invite code changed.
	//
	// Type: string
	AuditInviteCode AuditLogChangeKey = "code"
	// AuditInviteChannelID gets sent if the channel for an invite code
	// changed.
	//
	// Type: ChannelID
	AuditInviteChannelID AuditLogChangeKey = "channel_id"
	// AuditInviteInviterID specifies the person who created invite code
	// changed.
	//
	// Type: UserID
	AuditInviteInviterID AuditLogChangeKey = "inviter_id"
	// AuditInviteMaxUses specifies the change to max number of times invite
	// code can be used.
	//
	// Type: int
	AuditInviteMaxUses AuditLogChangeKey = "max_uses"
	// AuditInviteUses specifies the number of times invite code used changed.
	//
	// Type: int
	AuditInviteUses AuditLogChangeKey = "uses"
	// AuditInviteMaxAge specifies the how long invite code lasts
	// changed.
	//
	// Type: Seconds
	AuditInviteMaxAge AuditLogChangeKey = "max_age"
	// AuditInviteTemporary specifies if an invite code is temporary/never
	// expires.
	//
	// Type: bool
	AuditInviteTemporary AuditLogChangeKey = "temporary"
)
const (
	// AuditUserDeaf specifies if the user was server deafened/undeafened.
	//
	// Type: bool
	AuditUserDeaf AuditLogChangeKey = "deaf"
	// AuditUserMute specifies if the user was server muted/unmuted.
	//
	// Type: bool
	AuditUserMute AuditLogChangeKey = "mute"
	// AuditUserNick specifies the new nickname of the user.
	//
	// Type: string
	AuditUserNick AuditLogChangeKey = "nick"
	// AuditUserAvatar specifies the hash of the new user avatar.
	//
	// Type: Hash
	AuditUserAvatarHash AuditLogChangeKey = "avatar_hash"
)
const (
	// AuditAnyID specifies the ID of the changed entity - sometimes used in
	// conjunction with other keys.
	//
	// Type: Snowflake
	AuditAnyID AuditLogChangeKey = "id"
	// AuditAnyType is the type of the entity created.
	// Type ChannelType or string
	AuditAnyType AuditLogChangeKey = "type"
)
const (
	// AuditIntegrationEnableEmoticons gets sent if the integration emoticons
	// were enabled/disabled.
	//
	// Type: bool
	AuditIntegrationEnableEmoticons AuditLogChangeKey = "enable_emoticons"
	// AuditIntegrationExpireBehavior gets sent if the integration expiring
	// subscriber behavior changed.
	//
	// Type: ExpireBehavior
	AuditIntegrationExpireBehavior AuditLogChangeKey = "expire_behavior"
	// AuditIntegrationExpireGracePeriod gets sent if the integration expire
	// grace period changed.
	//
	// Type: int
	AuditIntegrationExpireGracePeriod AuditLogChangeKey = "expire_grace_period"
)

type AuditLogEntry

type AuditLogEntry struct {
	// ID is the id of the entry.
	ID AuditLogEntryID `json:"id"`
	// TargetID is the id of the affected entity (webhook, user, role, etc.).
	TargetID Snowflake `json:"target_id"`
	// Changes are the changes made to the TargetID.
	Changes []AuditLogChange `json:"changes,omitempty"`
	// UserID is the id of the user who made the changes.
	UserID UserID `json:"user_id"`

	// ActionType is the type of action that occurred.
	ActionType AuditLogEvent `json:"action_type"`

	// Options contains additional info for certain action types.
	Options AuditEntryInfo `json:"options,omitempty"`
	// Reason is the reason for the change (0-512 characters).
	Reason string `json:"reason,omitempty"`
}

AuditLogEntry is a single entry in the audit log.

https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object

func (AuditLogEntry) CreatedAt

func (e AuditLogEntry) CreatedAt() time.Time

CreatedAt returns a time object representing when the audit log entry was created.

type AuditLogEntryID

type AuditLogEntryID Snowflake

AuditLogEntryID is the snowflake type for a AuditLogEntryID.

func (AuditLogEntryID) Increment

func (s AuditLogEntryID) Increment() uint16

func (AuditLogEntryID) IsNull

func (s AuditLogEntryID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (AuditLogEntryID) IsValid

func (s AuditLogEntryID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (AuditLogEntryID) MarshalJSON

func (s AuditLogEntryID) MarshalJSON() ([]byte, error)

func (AuditLogEntryID) PID

func (s AuditLogEntryID) PID() uint8

func (AuditLogEntryID) String

func (s AuditLogEntryID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (AuditLogEntryID) Time

func (s AuditLogEntryID) Time() time.Time

func (*AuditLogEntryID) UnmarshalJSON

func (s *AuditLogEntryID) UnmarshalJSON(v []byte) error

func (AuditLogEntryID) Worker

func (s AuditLogEntryID) Worker() uint8

type AuditLogEvent

type AuditLogEvent uint8

AuditLogEvent is the type of audit log action that occurred.

const (
	GuildUpdate            AuditLogEvent = 1
	ChannelCreate          AuditLogEvent = 10
	ChannelUpdate          AuditLogEvent = 11
	ChannelDelete          AuditLogEvent = 12
	ChannelOverwriteCreate AuditLogEvent = 13
	ChannelOverwriteUpdate AuditLogEvent = 14
	ChannelOverwriteDelete AuditLogEvent = 15
	MemberKick             AuditLogEvent = 20
	MemberPrune            AuditLogEvent = 21
	MemberBanAdd           AuditLogEvent = 22
	MemberBanRemove        AuditLogEvent = 23
	MemberUpdate           AuditLogEvent = 24
	MemberRoleUpdate       AuditLogEvent = 25
	MemberMove             AuditLogEvent = 26
	MemberDisconnect       AuditLogEvent = 27
	BotAdd                 AuditLogEvent = 28
	RoleCreate             AuditLogEvent = 30
	RoleUpdate             AuditLogEvent = 31
	RoleDelete             AuditLogEvent = 32
	InviteCreate           AuditLogEvent = 40
	InviteUpdate           AuditLogEvent = 41
	InviteDelete           AuditLogEvent = 42
	WebhookCreate          AuditLogEvent = 50
	WebhookUpdate          AuditLogEvent = 51
	WebhookDelete          AuditLogEvent = 52
	EmojiCreate            AuditLogEvent = 60
	EmojiUpdate            AuditLogEvent = 61
	EmojiDelete            AuditLogEvent = 62
	MessageDelete          AuditLogEvent = 72
	MessageBulkDelete      AuditLogEvent = 73
	MessagePin             AuditLogEvent = 74
	MessageUnpin           AuditLogEvent = 75
	IntegrationCreate      AuditLogEvent = 80
	IntegrationUpdate      AuditLogEvent = 81
	IntegrationDelete      AuditLogEvent = 82
)

https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events

type AutoModerationAction added in v3.4.0

type AutoModerationAction struct {
	// the type of action
	Type AutoModerationActionType `json:"type"`
	// additional metadata needed during execution for this specific action type
	Metadata AutoModerationActionMetadata `json:"metadata,omitempty"`
}

type AutoModerationActionMetadata added in v3.4.0

type AutoModerationActionMetadata struct {
	// channel to which user content should be logged
	ChannelID ChannelID `json:"channel_id"`
	// timeout duration in seconds
	// maximum of 2419200 seconds (4 weeks)
	DurationSeconds int `json:"duration_seconds"`
	// additional explanation that will be shown to members whenever their message is blocked
	// maximum of 150 characters
	CustomMessage string `json:"custom_message,omitempty"`
}

type AutoModerationActionType added in v3.4.0

type AutoModerationActionType uint32
const (
	AutoModerationBlockMessage AutoModerationActionType = 1 + iota
	AutoModerationSendAlertMessage
	AutoModerationTimeout
	AutoModerationBlockMemberInteraction
)

type AutoModerationEventType added in v3.4.0

type AutoModerationEventType uint32
const (
	AutoModerationMessageSend AutoModerationEventType = 1 + iota
	AutoModerationMemberUpdate
)

type AutoModerationKeywordPresetType added in v3.4.0

type AutoModerationKeywordPresetType uint32
const (
	AutoModeratorProfanity AutoModerationKeywordPresetType = 1 + iota
	AutoModeratorSexualContent
	AutoModeratorSlurs
)

type AutoModerationRule added in v3.4.0

type AutoModerationRule struct {
	// the id of this rule
	ID AutoModerationRuleID `json:"id"`
	// the id of the guild which this rule belongs to
	GuildID GuildID `json:"guild_id"`
	// the rule name
	Name string `json:"name"`
	// the user which first created this rule
	CreatorID UserID `json:"creator_id,omitempty"`
	// the rule event type
	EventType AutoModerationEventType `json:"event_type"`
	// the rule trigger type
	TriggerType AutoModerationTriggerType
	// the rule trigger metadata
	TriggerMetadata AutoModerationTriggerMetadata `json:"trigger_metadata,omitempty"`
	// the actions which will execute when the rule is triggered
	Actions []AutoModerationAction `json:"actions"`
	// whether the rule is enabled
	Enabled bool `json:"enabled,omitempty"`
	// the role ids that should not be affected by the rule (Maximum of 20)
	ExemptRoles []RoleID `json:"exempt_roles,omitempty"`
	// the channel ids that should not be affected by the rule (Maximum of 50)
	ExemptChannels []ChannelID `json:"exempt_channels,omitempty"`
}

type AutoModerationRuleID added in v3.4.0

type AutoModerationRuleID Snowflake

AutoModerationRuleID is the snowflake type for a AutoModerationRuleID.

func (AutoModerationRuleID) Increment added in v3.4.0

func (s AutoModerationRuleID) Increment() uint16

func (AutoModerationRuleID) IsNull added in v3.4.0

func (s AutoModerationRuleID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (AutoModerationRuleID) IsValid added in v3.4.0

func (s AutoModerationRuleID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (AutoModerationRuleID) MarshalJSON added in v3.4.0

func (s AutoModerationRuleID) MarshalJSON() ([]byte, error)

func (AutoModerationRuleID) PID added in v3.4.0

func (s AutoModerationRuleID) PID() uint8

func (AutoModerationRuleID) String added in v3.4.0

func (s AutoModerationRuleID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (AutoModerationRuleID) Time added in v3.4.0

func (s AutoModerationRuleID) Time() time.Time

func (*AutoModerationRuleID) UnmarshalJSON added in v3.4.0

func (s *AutoModerationRuleID) UnmarshalJSON(v []byte) error

func (AutoModerationRuleID) Worker added in v3.4.0

func (s AutoModerationRuleID) Worker() uint8

type AutoModerationTriggerMetadata added in v3.4.0

type AutoModerationTriggerMetadata struct {
	// substrings which will be searched for in content (Maximum of 1000)
	KeywordFilter []string `json:"keyword_filter"`
	// regular expression patterns which will be matched against content (Maximum of 10)
	RegexPatterns []string `json:"regex_patterns"`
	// the internally pre-defined wordsets which will be searched for in content
	Presets []AutoModerationKeywordPresetType `json:"presets"`
	// substrings which should not trigger the rule (Maximum of 100 or 1000)
	AllowList []string `json:"allow_list"`
	// total number of unique role and user mentions allowed per message (Maximum of 50)
	MentionTotalLimit int `json:"mention_total_limit"`
	// whether to automatically detect mention raids
	MentionRaidProtectionEnabled bool `json:"mention_raid_protection_enabled"`
}

type AutoModerationTriggerType added in v3.4.0

type AutoModerationTriggerType uint32
const (
	AutoModerationKeyword AutoModerationTriggerType = 1 + iota
	AutoModerationSpam
	AutoModerationKeywordPreset
	AutoModerationMentionSpam
	AutoModerationMemberProfile
)

type AutocompleteInteraction

type AutocompleteInteraction struct {
	CommandID CommandID `json:"id"`

	// Name of command autocomplete is triggered for.
	Name        string              `json:"name"`
	CommandType CommandType         `json:"type"`
	Version     string              `json:"version"`
	Options     AutocompleteOptions `json:"options"`
}

AutocompleteInteraction is an autocompletion Interaction response.

func (*AutocompleteInteraction) InteractionType

func (*AutocompleteInteraction) InteractionType() InteractionDataType

Type implements ComponentInteraction.

type AutocompleteOption

type AutocompleteOption struct {
	Type    CommandOptionType   `json:"type"`
	Name    string              `json:"name"`
	Value   json.Raw            `json:"value,omitempty"`
	Focused bool                `json:"focused,omitempty"`
	Options AutocompleteOptions `json:"options,omitempty"`
}

AutocompleteOption is an autocompletion option in an AutocompleteInteraction.

func (AutocompleteOption) BoolValue

func (o AutocompleteOption) BoolValue() (bool, error)

BoolValue reads the option's value as a bool.

func (AutocompleteOption) FloatValue

func (o AutocompleteOption) FloatValue() (float64, error)

FloatValue reads the option's value as a float64.

func (AutocompleteOption) IntValue

func (o AutocompleteOption) IntValue() (int64, error)

IntValue reads the option's value as an int.

func (AutocompleteOption) SnowflakeValue

func (o AutocompleteOption) SnowflakeValue() (Snowflake, error)

SnowflakeValue reads the option's value as a snowflake.

func (AutocompleteOption) String

func (o AutocompleteOption) String() string

String will return the value if the option's value is a valid string. Otherwise, it will return the raw JSON value of the other type.

type AutocompleteOptions

type AutocompleteOptions []AutocompleteOption

AutocompleteOptions is a list of autocompletion options. Use `Find` to get your named autocompletion option.

func (AutocompleteOptions) Find

Find returns the named autocomplete option.

func (AutocompleteOptions) Focused added in v3.2.0

Focused returns the option that the user is currently focused on.

func (AutocompleteOptions) Unmarshal added in v3.2.0

func (o AutocompleteOptions) Unmarshal(v interface{}) error

Unmarshal behaves similarly to CommandInteractionOptions.Unmarshal. It supports the same types. Refer to its documentation for more.

type Ban

type Ban struct {
	// Reason is the reason for the ban.
	Reason string `json:"reason,omitempty"`
	// User is the banned user.
	User User `json:"user"`
}

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

type BooleanOption

type BooleanOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

BooleanOption is a subcommand option that fits into a CommandOptionValue.

func NewBooleanOption

func NewBooleanOption(name, description string, required bool) *BooleanOption

NewBooleanOption creates a new boolean option.

func (*BooleanOption) MarshalJSON

func (b *BooleanOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals BooleanOption to JSON with the "type" field.

func (*BooleanOption) Name

func (b *BooleanOption) Name() string

Name implements CommandOption.

func (*BooleanOption) Type

func (b *BooleanOption) Type() CommandOptionType

Type implements CommandOptionValue.

type ButtonComponent

type ButtonComponent struct {
	// Style is one of the button styles.
	Style ButtonComponentStyle `json:"style"`
	// CustomID attached to InteractionCreate event when clicked.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Label is the text that appears on the button. It can have maximum 100
	// characters.
	Label string `json:"label,omitempty"`
	// Emoji should have Name, ID and Animated filled.
	Emoji *ComponentEmoji `json:"emoji,omitempty"`
	// Disabled determines whether the button is disabled.
	Disabled bool `json:"disabled,omitempty"`
}

Button is a clickable button that may be added to an interaction response.

func TextButtonComponent

func TextButtonComponent(style ButtonComponentStyle, label string) ButtonComponent

TextButtonComponent creates a new button with the given label used for the label and the custom ID.

func (*ButtonComponent) ID

func (b *ButtonComponent) ID() ComponentID

ID implements the Component interface.

func (*ButtonComponent) MarshalJSON

func (b *ButtonComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the button in the format Discord expects.

func (*ButtonComponent) Type

func (b *ButtonComponent) Type() ComponentType

Type implements the Component interface.

func (*ButtonComponent) UnmarshalJSON

func (b *ButtonComponent) UnmarshalJSON(j []byte) error

UnmarshalJSON unmarshals a component JSON into the button. It does NOT do type-checking; use ParseComponent for that.

type ButtonComponentStyle

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

ButtonComponentStyle is the style to display a button in. Use one of the ButtonStyle constructor functions.

func DangerButtonStyle

func DangerButtonStyle() ButtonComponentStyle

DangerButtonStyle is a style for a red button.

func LinkButtonStyle

func LinkButtonStyle(url URL) ButtonComponentStyle

LinkButtonStyle is a button style that navigates to a URL.

func PrimaryButtonStyle

func PrimaryButtonStyle() ButtonComponentStyle

PrimaryButtonStyle is a style for a blurple button.

func SecondaryButtonStyle

func SecondaryButtonStyle() ButtonComponentStyle

SecondaryButtonStyle is a style for a grey button.

func SuccessButtonStyle

func SuccessButtonStyle() ButtonComponentStyle

SuccessButtonStyle is a style for a green button.

type ButtonInteraction

type ButtonInteraction struct {
	CustomID ComponentID `json:"custom_id"`
}

ButtonInteraction is a button component's response. It is the custom ID of the button within the component tree.

func (*ButtonInteraction) ID

ID implements ComponentInteraction.

func (*ButtonInteraction) InteractionType

func (b *ButtonInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*ButtonInteraction) Type

func (b *ButtonInteraction) Type() ComponentType

Type implements ComponentInteraction.

type Channel

type Channel struct {
	// ID is the id of this channel.
	ID ChannelID `json:"id"`
	// GuildID is the id of the guild.
	//
	// This field may be missing for some channel objects received over gateway
	// guild dispatches.
	GuildID GuildID `json:"guild_id,omitempty"`

	// Type is the type of channel.
	Type ChannelType `json:"type,omitempty"`
	// NSFW specifies whether the channel is nsfw.
	NSFW bool `json:"nsfw,omitempty"`

	// Position is the sorting position of the channel.
	Position int `json:"position,omitempty"`
	// Overwrites are the explicit permission overrides for members
	// and roles.
	Overwrites []Overwrite `json:"permission_overwrites,omitempty"`

	// Name is the name of the channel (2-100 characters).
	Name string `json:"name,omitempty"`
	// Topic is the channel topic (0-1024 characters).
	Topic string `json:"topic,omitempty"`

	// LastMessageID is the id of the last message sent in this channel (may
	// not point to an existing or valid message).
	LastMessageID MessageID `json:"last_message_id,omitempty"`

	// VoiceBitrate is the bitrate (in bits) of the voice channel.
	VoiceBitrate uint `json:"bitrate,omitempty"`
	// VoiceUserLimit is the user limit of the voice channel.
	VoiceUserLimit uint `json:"user_limit,omitempty"`

	// Flags is a bitmask that contains if a thread is pinned, for example.
	Flags ChannelFlags `json:"flags,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.
	UserRateLimit Seconds `json:"rate_limit_per_user,omitempty"`

	// DMRecipients are the recipients of the DM.
	DMRecipients []User `json:"recipients,omitempty"`
	// Icon is the icon hash.
	Icon Hash `json:"icon,omitempty"`

	// OwnerID is the id of the DM or thread creator.
	OwnerID UserID `json:"owner_id,omitempty"`
	// AppID is the application id of the group DM creator if it is
	// bot-created.
	AppID AppID `json:"application_id,omitempty"`
	// ParentID for guild channels: id of the parent category for a channel
	// (each parent category can contain up to 50 channels), for threads: the
	// id of the text channel this thread was created.
	ParentID ChannelID `json:"parent_id,omitempty"`

	// LastPinTime is when the last pinned message was pinned.
	LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"`

	// RTCRegionID is the voice region id for the voice channel.
	RTCRegionID string `json:"rtc_region,omitempty"`
	// VideoQualityMode is the camera video quality mode of the voice channel.
	VideoQualityMode VideoQualityMode `json:"video_quality_mode,omitempty"`

	// MessageCount is an approximate count of messages in a thread. However,
	// counting stops at 50.
	MessageCount int `json:"message_count,omitempty"`
	// MemberCount is an approximate count of users in a thread. However,
	// counting stops at 50.
	MemberCount int `json:"member_count,omitempty"`

	// ThreadMetadata contains thread-specific fields not needed by other
	// channels.
	ThreadMetadata *ThreadMetadata `json:"thread_metadata,omitempty"`
	// ThreadMember is the thread member object for the current user, if they
	// have joined the thread, only included on certain API endpoints.
	ThreadMember *ThreadMember `json:"thread_member,omitempty"`
	// DefaultAutoArchiveDuration is the default duration for newly created
	// threads, in minutes, to automatically archive the thread after recent
	// activity.
	DefaultAutoArchiveDuration ArchiveDuration `json:"default_auto_archive_duration,omitempty"`

	// SelfPermissions are the computed permissions for the invoking user in
	// the channel, including overwrites, only included when part of the
	// resolved data received on a slash command interaction.
	SelfPermissions Permissions `json:"permissions,omitempty,string"`

	// AvailableTags is the set of tags that can be used in a GuildForum
	// channel.
	AvailableTags []Tag `json:"available_tags,omitempty"`
	// AppliedTags are the IDs of the set of tags that have been applied to a
	// thread in a GuildForum channel.
	AppliedTags []TagID `json:"applied_tags,omitempty"`
	// DefaultReactionEmoji is the emoji to show in the add reaction button on a
	// thread in a GuildForum channel
	DefaultReactionEmoji *ForumReaction `json:"default_reaction_emoji,omitempty"`
	// DefaultThreadRateLimitPerUser is the initial rate_limit_per_user to set on newly created threads in a channel. this field is copied to the thread at creation time and does not live update.
	DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user,omitempty"`
	// DefaultSoftOrder is the default sort order type used to order posts in GUILD_FORUM channels. Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
	DefaultSoftOrder *SortOrderType `json:"default_sort_order,omitempty"`
	// DefaultForumLayout is the default forum layout view used to display posts in GUILD_FORUM channels. Defaults to 0, which indicates a layout view has not been set by a channel admin.
	DefaultForumLayout ForumLayoutType `json:"default_forum_layout,omitempty"`
}

Channel represents a guild or DM channel within Discord.

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

func (Channel) CreatedAt

func (ch Channel) CreatedAt() time.Time

CreatedAt returns a time object representing when the channel was created.

func (Channel) IconURL

func (ch Channel) IconURL() string

IconURL returns the URL to the channel icon in the PNG format. An empty string is returned if there's no icon.

func (Channel) IconURLWithType

func (ch Channel) IconURLWithType(t ImageType) string

IconURLWithType returns the URL to the channel icon using the passed ImageType. An empty string is returned if there's no icon.

Supported ImageTypes: PNG, JPEG, WebP

func (Channel) Mention

func (ch Channel) Mention() string

Mention returns a mention of the channel.

func (Channel) URL added in v3.4.0

func (c Channel) URL() string

URL generates a Discord client URL to the channel. If the channel doesn't have a GuildID, it will generate a URL with the guild "@me".

func (*Channel) UnmarshalJSON

func (ch *Channel) UnmarshalJSON(data []byte) error

type ChannelFlags added in v3.2.0

type ChannelFlags uint64

ChannelFlags are the channel flags combined as a bitfield.

const (

	// PinnedThread means this thread is pinned to the top of its parent
	// GuildForum channel.
	PinnedThread ChannelFlags

	// ThreadRequireTag is whether a tag is required to be specified when
	// creating a thread in a GuildForum channel. Tags are specified in the
	// AppliedTags field.
	ThreadRequireTag
)

type ChannelID

type ChannelID Snowflake

ChannelID is the snowflake type for a ChannelID.

func (ChannelID) Increment

func (s ChannelID) Increment() uint16

func (ChannelID) IsNull

func (s ChannelID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (ChannelID) IsValid

func (s ChannelID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (ChannelID) MarshalJSON

func (s ChannelID) MarshalJSON() ([]byte, error)

func (ChannelID) Mention

func (s ChannelID) Mention() string

Mention generates the mention syntax for this channel ID.

func (ChannelID) PID

func (s ChannelID) PID() uint8

func (ChannelID) String

func (s ChannelID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (ChannelID) Time

func (s ChannelID) Time() time.Time

func (*ChannelID) UnmarshalJSON

func (s *ChannelID) UnmarshalJSON(v []byte) error

func (ChannelID) Worker

func (s ChannelID) Worker() uint8

type ChannelMention

type ChannelMention struct {
	// ChannelID is the ID of the channel.
	ChannelID ChannelID `json:"id"`
	// GuildID is the ID of the guild containing the channel.
	GuildID GuildID `json:"guild_id"`
	// ChannelType is the type of channel.
	ChannelType ChannelType `json:"type"`
	// ChannelName is the name of the channel.
	ChannelName string `json:"name"`
}

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

type ChannelOption

type ChannelOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	ChannelTypes             []ChannelType `json:"channel_types,omitempty"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

ChannelOption is a subcommand option that fits into a CommandOptionValue.

func NewChannelOption

func NewChannelOption(name, description string, required bool) *ChannelOption

NewChannelOption creates a new channel option.

func (*ChannelOption) MarshalJSON

func (c *ChannelOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals ChannelOption to JSON with the "type" field.

func (*ChannelOption) Name

func (c *ChannelOption) Name() string

Name implements CommandOption.

func (*ChannelOption) Type

func (c *ChannelOption) Type() CommandOptionType

Type implements CommandOptionValue.

type ChannelSelectComponent added in v3.2.0

type ChannelSelectComponent struct {
	// CustomID is the custom unique ID.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Placeholder is the custom placeholder text if nothing is selected. Max
	// 100 characters.
	Placeholder string `json:"placeholder,omitempty"`
	// ValueLimits is the minimum and maximum number of items that can be
	// chosen. The default is [1, 1] if ValueLimits is a zero-value.
	ValueLimits [2]int `json:"-"`
	// Disabled disables the select if true.
	Disabled bool `json:"disabled,omitempty"`
	// ChannelTypes is the types of channels that can be chosen from.
	ChannelTypes []ChannelType `json:"channel_types,omitempty"`
}

func (*ChannelSelectComponent) ID added in v3.2.0

ID implements the Component interface.

func (*ChannelSelectComponent) MarshalJSON added in v3.2.0

func (s *ChannelSelectComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the select in the format Discord expects.

func (*ChannelSelectComponent) Type added in v3.2.0

Type implements the Component interface.

type ChannelSelectInteraction added in v3.3.0

type ChannelSelectInteraction struct {
	CustomID ComponentID `json:"custom_id"`
	Values   []ChannelID `json:"values"`
}

ChannelSelectInteraction is a channel select component's response.

func (*ChannelSelectInteraction) ID added in v3.3.0

ID implements ComponentInteraction.

func (*ChannelSelectInteraction) InteractionType added in v3.3.0

func (s *ChannelSelectInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*ChannelSelectInteraction) Type added in v3.3.0

Type implements ComponentInteraction.

type ChannelType

type ChannelType uint16

ChannelType describes the type of the channel.

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

const (
	// GuildText is a text channel within a server.
	GuildText ChannelType = iota
	// DirectMessage is a direct message between users.
	DirectMessage
	// GuildVoice is a voice channel within a server.
	GuildVoice
	// GroupDM is a direct message between multiple users.
	GroupDM
	// GuildCategory is an organizational category that contains up to 50
	// channels.
	GuildCategory
	// GuildAnnouncement is a channel that users can follow and crosspost into
	// their own server.
	GuildAnnouncement
	// GuildStore is a channel in which game developers can sell their game on
	// Discord.
	GuildStore

	// GuildAnnouncementThread is a temporary sub-channel within a GUILD_NEWS channel
	GuildAnnouncementThread
	// GuildPublicThread is a temporary sub-channel within a GUILD_TEXT
	// channel.
	GuildPublicThread
	// GuildPrivateThread isa temporary sub-channel within a GUILD_TEXT channel
	// that is only viewable by those invited and those with the MANAGE_THREADS
	// permission.
	GuildPrivateThread
	// GuildStageVoice is a voice channel for hosting events with an audience.
	GuildStageVoice
	// GuildDirectory is the channel in a hub containing the listed servers.
	GuildDirectory
	// GuildForum is a channel that can only contain threads.
	GuildForum
)

type ClientStatus

type ClientStatus struct {
	// Desktop is the user's status set for an active desktop (Windows,
	// Linux, Mac) application session.
	Desktop Status `json:"desktop,omitempty"`
	// Mobile is the user's status set for an active mobile (iOS, Android)
	// application session.
	Mobile Status `json:"mobile,omitempty"`
	// Web is the user's status set for an active web (browser, bot
	// account) application session.
	Web Status `json:"web,omitempty"`
}

type Color

type Color int32

Color describes an RGB color (with NO alpha). If a value is -1, then it's marshaled to JSON as null.

const NullColor Color = -1

NullColor is a Color that's marshaled to null.

var DefaultEmbedColor Color = 0x303030

DefaultEmbedColor is the default color to use for an embed.

func MemberColor deprecated

func MemberColor(guild Guild, member Member) (Color, bool)

MemberColor computes the effective color of the Member, taking into account the role colors.

Deprecated: MemberColor relies on Guild, which may not have a []Role if it comes from the state. Use State's MemberColor instead.

func (Color) Int

func (c Color) Int() int

Int converts Color to int.

func (Color) MarshalJSON

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

func (Color) RGB

func (c Color) RGB() (uint8, uint8, uint8)

RGB splits Color into red, green, and blue. The maximum value is 255.

func (Color) String

func (c Color) String() string

String returns the Color in hexadecimal (#FFFFFF) format.

func (Color) Uint32

func (c Color) Uint32() uint32

Uint32 returns the color as a Uint32. If the color is null, then 0 is returned.

func (*Color) UnmarshalJSON

func (c *Color) UnmarshalJSON(json []byte) error

type Command

type Command struct {
	// ID is the unique id of the command.
	ID CommandID `json:"id"`
	// Type is the intended source of the command.
	Type CommandType `json:"type,omitempty"`
	// AppID is the unique id of the parent application.
	AppID AppID `json:"application_id"`
	// GuildID is the guild id of the command, if not global.
	GuildID GuildID `json:"guild_id,omitempty"`
	// Name is the 1-32 lowercase character name matching ^[\w-]{1,32}$.
	Name              string        `json:"name"`
	NameLocalizations StringLocales `json:"name_localizations,omitempty"`
	// Description is the 1-100 character description.
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	// LocalizedName is only populated when this is received from Discord's API.
	LocalizedName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
	// Options are the parameters for the command. Its types are value types,
	// which can either be a SubcommandOption or a SubcommandGroupOption.
	//
	// Note that required options must be listed before optional options, and
	// a command, or each individual subcommand, can have a maximum of 25
	// options.
	//
	// It is only present on ChatInputCommands.
	Options CommandOptions `json:"options,omitempty"`
	// DefaultMemberPermissions is set of permissions.
	DefaultMemberPermissions *Permissions `json:"default_member_permissions,string,omitempty"`
	// NoDMPermission indicates whether the command is NOT available in DMs with
	// the app, only for globally-scoped commands. By default, commands are visible.
	NoDMPermission bool `json:"-"`
	// NoDefaultPermissions defines whether the command is NOT enabled by
	// default when the app is added to a guild.
	NoDefaultPermission bool `json:"-"`
	// Version is an autoincrementing version identifier updated during
	// substantial record changes
	Version Snowflake `json:"version,omitempty"`
}

Command is the base "command" model that belongs to an application. This is what you are creating when you POST a new command.

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure

func NewCommand

func NewCommand(name, description string, options ...CommandOption) Command

NewCommand creates a new command.

func (*Command) CreatedAt

func (c *Command) CreatedAt() time.Time

CreatedAt returns a time object representing when the command was created.

func (*Command) MarshalJSON

func (c *Command) MarshalJSON() ([]byte, error)

func (*Command) UnmarshalJSON

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

type CommandID

type CommandID Snowflake

CommandID is the snowflake type for a CommandID.

func (CommandID) Increment

func (s CommandID) Increment() uint16

func (CommandID) IsNull

func (s CommandID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (CommandID) IsValid

func (s CommandID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (CommandID) MarshalJSON

func (s CommandID) MarshalJSON() ([]byte, error)

func (CommandID) PID

func (s CommandID) PID() uint8

func (CommandID) String

func (s CommandID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (CommandID) Time

func (s CommandID) Time() time.Time

func (*CommandID) UnmarshalJSON

func (s *CommandID) UnmarshalJSON(v []byte) error

func (CommandID) Worker

func (s CommandID) Worker() uint8

type CommandInteraction

type CommandInteraction struct {
	ID      CommandID                 `json:"id"`
	Name    string                    `json:"name"`
	Options CommandInteractionOptions `json:"options,omitempty"`
	// 	GuildID is the id of the guild the command is registered to
	GuildID GuildID `json:"guild_id,omitempty"`
	// TargetID is the id of the user or message targeted by a user or message command.
	//
	// See TargetUserID and TargetMessageID
	TargetID Snowflake `json:"target_id,omitempty"`
	Resolved struct {
		// User contains user objects.
		Users map[UserID]User `json:"users,omitempty"`
		// Members contains partial member objects (missing User, Deaf and
		// Mute).
		Members map[UserID]Member `json:"members,omitempty"`
		// Role contains role objects.
		Roles map[RoleID]Role `json:"roles,omitempty"`
		// Channels contains partial channel objects that only have ID, Name,
		// Type and Permissions. Threads will also have ThreadMetadata and
		// ParentID.
		Channels map[ChannelID]Channel `json:"channels,omitempty"`
		// Messages contains partial message objects. All fields without
		// omitempty are presumably present.
		Messages map[MessageID]Message `json:"messages,omitempty"`
		// Attachments contains attachments objects.
		Attachments map[AttachmentID]Attachment `json:"attachments,omitempty"`
	}
}

CommandInteraction is an application command interaction that Discord sends to us.

func (*CommandInteraction) InteractionType

func (*CommandInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*CommandInteraction) TargetMessageID

func (c *CommandInteraction) TargetMessageID() MessageID

TargetMessageID is the id of the message targeted by a message command

func (*CommandInteraction) TargetUserID

func (c *CommandInteraction) TargetUserID() UserID

TargetUserID is the id of the user targeted by a user command

type CommandInteractionOption

type CommandInteractionOption struct {
	Type    CommandOptionType         `json:"type"`
	Name    string                    `json:"name"`
	Value   json.Raw                  `json:"value,omitempty"`
	Options CommandInteractionOptions `json:"options,omitempty"`
}

CommandInteractionOption is an option for a Command interaction response.

func (CommandInteractionOption) BoolValue

func (o CommandInteractionOption) BoolValue() (bool, error)

BoolValue reads the option's value as a bool.

func (CommandInteractionOption) FloatValue

func (o CommandInteractionOption) FloatValue() (float64, error)

FloatValue reads the option's value as a float64.

func (CommandInteractionOption) IntValue

func (o CommandInteractionOption) IntValue() (int64, error)

IntValue reads the option's value as an int.

func (CommandInteractionOption) SnowflakeValue

func (o CommandInteractionOption) SnowflakeValue() (Snowflake, error)

SnowflakeValue reads the option's value as a snowflake.

func (CommandInteractionOption) String

func (o CommandInteractionOption) String() string

String will return the value if the option's value is a valid string. Otherwise, it will return the raw JSON value of the other type.

type CommandInteractionOptions

type CommandInteractionOptions []CommandInteractionOption

CommandInteractionOptions is a list of interaction options. Use `Find` to get your named interaction option

func (CommandInteractionOptions) Find

Find returns the named command option

func (CommandInteractionOptions) Unmarshal added in v3.1.0

func (o CommandInteractionOptions) Unmarshal(v interface{}) error

Unmarshal unmarshals the options into the struct pointer v. Each struct field must be exported and is of a supported type.

Fields that don't satisfy any of the above are ignored. The "discord" struct tag with a value "-" is ignored. Fields that aren't found in the list of options and have a "?" at the end of the "discord" struct tag are ignored.

Supported Types

The following types are supported:

  • ChannelID (ChannelOptionType)
  • UserID (UserOptionType)
  • RoleID (RoleOptionType)
  • Snowflake (MentionableOptionType)
  • string (StringOptionType)
  • bool (BooleanOptionType)
  • int* (int, int8, int16, int32, int64) (NumberOptionType, IntegerOptionType)
  • uint* (uint, uint8, uint16, uint32, uint64) (NumberOptionType, IntegerOptionType)
  • float* (float32, float64) (NumberOptionType)
  • (any struct and struct pointer) (not Discord-type-checked)

Any types that are derived from any of the above built-in types are also supported.

Pointer types to any of the above types are also supported and will also implicitly imply optionality.

Example
package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/diamondburned/arikawa/v3/discord"
	internaljson "github.com/diamondburned/arikawa/v3/utils/json"
)

func main() {
	options := discord.CommandInteractionOptions{
		opt(discord.ChannelOptionType, "channel_id", 1),
		opt(discord.StringOptionType, "string1", "hello"),
		opt(discord.StringOptionType, "string2", "hello"),
		opt(discord.StringOptionType, "string3", "hello"),
		opt(discord.SubcommandOptionType, "sub", discord.CommandInteractionOptions{
			{
				Type:  discord.RoleOptionType,
				Name:  "role_id",
				Value: mustJSON("2"),
			},
		}),
	}

	var quickCommand struct {
		ChannelID       discord.ChannelID `discord:"channel_id"`
		String1         string
		OptionalString2 *string `discord:"string2"`
		OptionalString3 string  `discord:"string3?"`
		OptionalString4 *string `discord:"string4"`
		OptionalString5 string  `discord:"string5?"`
		Suboption       struct {
			RoleID discord.RoleID `discord:"role_id"`
		} `discord:"sub"`
		OptionalSuboption2 *struct {
			RoleID discord.RoleID `discord:"role_id"`
		} `discord:"sub2"`
		OptionalSuboption3 struct {
			RoleID discord.RoleID `discord:"role_id"`
		} `discord:"sub3?"`
	}

	if err := options.Unmarshal(&quickCommand); err != nil {
		log.Fatalln(err)
	}

	b, _ := json.MarshalIndent(quickCommand, "", "  ")
	fmt.Println(string(b))

}

func opt(t discord.CommandOptionType, name string, v interface{}) discord.CommandInteractionOption {
	o := discord.CommandInteractionOption{
		Type: t,
		Name: name,
	}
	if opts, ok := v.(discord.CommandInteractionOptions); ok {
		o.Options = opts
	} else {
		o.Value = mustJSON(v)
	}
	return o
}

func mustJSON(v interface{}) internaljson.Raw {
	b, err := json.Marshal(v)
	if err != nil {
		panic(err)
	}
	return internaljson.Raw(b)
}
Output:

{
  "ChannelID": "1",
  "String1": "hello",
  "OptionalString2": "hello",
  "OptionalString3": "hello",
  "OptionalString4": null,
  "OptionalString5": "",
  "Suboption": {
    "RoleID": "2"
  },
  "OptionalSuboption2": null,
  "OptionalSuboption3": {
    "RoleID": null
  }
}

type CommandOption

type CommandOption interface {
	Name() string
	Type() CommandOptionType
}

CommandOption is a union of command option types. The constructors for CommandOption will hint the types that can be a CommandOption.

The following types implement this interface:

  • *SubcommandGroupOption
  • *SubcommandOption
  • *StringOption
  • *IntegerOption
  • *BooleanOption
  • *UserOption
  • *ChannelOption
  • *RoleOption
  • *MentionableOption
  • *NumberOption
  • *AttachmentOption

type CommandOptionType

type CommandOptionType uint

CommandOptionType is the enumerated integer type for command options. The user usually won't have to touch any of these enum constants.

const (
	SubcommandOptionType CommandOptionType = iota + 1
	SubcommandGroupOptionType
	StringOptionType
	IntegerOptionType
	BooleanOptionType
	UserOptionType
	ChannelOptionType
	RoleOptionType
	MentionableOptionType
	NumberOptionType
	AttachmentOptionType
)

type CommandOptionValue

type CommandOptionValue interface {
	CommandOption
	// contains filtered or unexported methods
}

CommandOptionValue is a subcommand option that fits into a subcommand.

The following types implement this interface:

  • *StringOption
  • *IntegerOption
  • *BooleanOption
  • *UserOption
  • *ChannelOption
  • *RoleOption
  • *MentionableOption
  • *NumberOption
  • *AttachmentOption

type CommandOptions

type CommandOptions []CommandOption

CommandOptions is used primarily for unmarshaling.

func (*CommandOptions) UnmarshalJSON

func (c *CommandOptions) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into these CommandOptions.

type CommandPermissionType

type CommandPermissionType uint8

type CommandType

type CommandType uint

CommandType is the type of the command, which describes the intended invokation source of the command.

const (
	ChatInputCommand CommandType = iota + 1
	UserCommand
	MessageCommand
)

type Component

type Component interface {
	// Type returns the type of the underlying component.
	Type() ComponentType
	// contains filtered or unexported methods
}

Component is a component that can be attached to an interaction response. A Component is either an InteractiveComponent or a ContainerComponent. See those appropriate types for more information.

The following types satisfy this interface:

  • *ActionRowComponent
  • *ButtonComponent
  • *StringSelectComponent
  • *TextInputComponent
  • *UserSelectComponent
  • *RoleSelectComponent
  • *MentionableSelectComponent
  • *ChannelSelectComponent

func ParseComponent

func ParseComponent(b []byte) (Component, error)

NewComponent returns a new Component from the given type that's matched with the global ComponentFunc map. If the type is unknown, then Unknown is used.

type ComponentEmoji

type ComponentEmoji struct {
	ID       EmojiID `json:"id,omitempty"`
	Name     string  `json:"name,omitempty"`
	Animated bool    `json:"animated,omitempty"`
}

ComponentEmoji is the emoji displayed on the button before the text. For more information, see Emoji.

type ComponentID

type ComponentID string

ComponentID is the type for a component's custom ID. It is NOT a snowflake, but rather a user-defined opaque string.

type ComponentInteraction

type ComponentInteraction interface {
	InteractionData
	// ID returns the ID of the component in response. Not all component
	// interactions will have a component ID.
	ID() ComponentID
	// Type returns the type of the component in response.
	Type() ComponentType
	// contains filtered or unexported methods
}

ComponentInteraction is a union component interaction response types. The types can be whatever the constructors for this type will return.

The following types implement this interface:

  • *StringSelectInteraction
  • *ChannelSelectInteraction
  • *RoleSelectInteraction
  • *UserSelectInteraction
  • *MentionableSelectInteraction
  • *ButtonInteraction

func ParseComponentInteraction

func ParseComponentInteraction(b []byte) (ComponentInteraction, error)

ParseComponentInteraction parses the given bytes as a component response.

type ComponentType

type ComponentType uint

ComponentType is the type of a component.

const (
	ActionRowComponentType ComponentType
	ButtonComponentType
	StringSelectComponentType
	TextInputComponentType
	UserSelectComponentType
	RoleSelectComponentType
	MentionableSelectComponentType
	ChannelSelectComponentType
)

func (ComponentType) String

func (t ComponentType) String() string

String formats Type's name as a string.

type Connection

type Connection struct {
	ID   string  `json:"id"`
	Name string  `json:"name"`
	Type Service `json:"type"`

	Revoked      bool `json:"revoked"`
	Verified     bool `json:"verified"`
	FriendSync   bool `json:"friend_sync"`
	ShowActivity bool `json:"show_activity"`

	Visibility ConnectionVisibility `json:"visibility"`

	// Only partial
	Integrations []Integration `json:"integrations"`
}

type ConnectionVisibility

type ConnectionVisibility uint8
const (
	ConnectionNotVisible ConnectionVisibility = iota
	ConnectionVisibleEveryone
)

type ContainerComponent

type ContainerComponent interface {
	Component
	// contains filtered or unexported methods
}

ContainerComponent is the opposite of InteractiveComponent: it describes components that only contain other components. The only component that satisfies that is ActionRow.

The following types satisfy this interface:

  • *ActionRowComponent

type ContainerComponents

type ContainerComponents []ContainerComponent

ContainerComponents is primarily used for unmarshaling. It is the top-level type for component lists.

func Components

func Components(components ...Component) ContainerComponents

Components wraps the given list of components inside ActionRows if it's not already in one. This is a convenient function that wraps components inside ActionRows for the user. It panics if any of the action rows have nested action rows in them.

Here's an example of how to use it:

discord.Components(
    discord.TextButtonComponent("Hello, world!"),
    discord.Components(
        discord.TextButtonComponent("Hello!"),
        discord.TextButtonComponent("Delete."),
    ),
)

func ComponentsPtr

func ComponentsPtr(components ...Component) *ContainerComponents

ComponentsPtr returns the pointer to Components' return. This is a convenient function.

func (*ContainerComponents) Find added in v3.1.0

func (c *ContainerComponents) Find(customID ComponentID) Component

Find finds any component with the given custom ID.

func (*ContainerComponents) Unmarshal added in v3.1.0

func (c *ContainerComponents) Unmarshal(v interface{}) error

Unmarshal unmarshals the components into the struct pointer v. Each struct field must be exported and is of a supported type.

Fields that don't satisfy any of the above are ignored. The "discord" struct tag with a value "-" is ignored. Fields that aren't found in the list of options and have a "?" at the end of the "discord" struct tag are ignored.

Each struct field will be used to search the tree of components for a matching custom ID. The struct must be a flat struct that lists all the components it needs using the custom ID.

Supported Types

The following types are supported:

  • string (SelectComponent if range = [n, 1], TextInputComponent)
  • int*, uint*, float* (uses Parse{Int,Uint,Float}, SelectComponent if range = [n, 1], TextInputComponent)
  • bool (ButtonComponent or any component, true if present)
  • []string (SelectComponent)

Any types that are derived from any of the above built-in types are also supported.

Pointer types to any of the above types are also supported and will also implicitly imply optionality.

Example
package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/diamondburned/arikawa/v3/discord"
)

func main() {
	components := &discord.ContainerComponents{
		&discord.ActionRowComponent{
			&discord.TextInputComponent{
				CustomID: "text1",
				Value:    "hello",
			},
		},
		&discord.ActionRowComponent{
			&discord.TextInputComponent{
				CustomID: "text2",
				Value:    "hello 2",
			},
			&discord.TextInputComponent{
				CustomID: "text3",
				Value:    "hello 3",
			},
		},
		&discord.ActionRowComponent{
			&discord.StringSelectComponent{
				CustomID: "select1",
				Options: []discord.SelectOption{
					{Value: "option 1"},
					{Value: "option 2"},
				},
			},
			&discord.ButtonComponent{
				CustomID: "button1",
			},
		},
		&discord.ActionRowComponent{
			&discord.StringSelectComponent{
				CustomID: "select2",
				Options: []discord.SelectOption{
					{Value: "option 1"},
				},
			},
		},
	}

	var data struct {
		Text1   string   `discord:"text1"`
		Text2   string   `discord:"text2?"`
		Text3   *string  `discord:"text3"`
		Text4   string   `discord:"text4?"`
		Text5   *string  `discord:"text5"`
		Select1 []string `discord:"select1"`
		Select2 string   `discord:"select2"`
		Button1 bool     `discord:"button1"`
	}

	if err := components.Unmarshal(&data); err != nil {
		log.Fatalln(err)
	}

	b, _ := json.MarshalIndent(data, "", "  ")
	fmt.Println(string(b))

}
Output:

{
  "Text1": "hello",
  "Text2": "hello 2",
  "Text3": "hello 3",
  "Text4": "",
  "Text5": null,
  "Select1": [
    "option 1",
    "option 2"
  ],
  "Select2": "option 1",
  "Button1": true
}

func (*ContainerComponents) UnmarshalJSON

func (c *ContainerComponents) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON into the component. It does type-checking and will only accept container components.

type Embed

type Embed struct {
	Title       string    `json:"title,omitempty"`
	Type        EmbedType `json:"type,omitempty"`
	Description string    `json:"description,omitempty"`

	URL URL `json:"url,omitempty"`

	Timestamp Timestamp `json:"timestamp,omitempty"`
	Color     Color     `json:"color,omitempty"`

	Footer    *EmbedFooter    `json:"footer,omitempty"`
	Image     *EmbedImage     `json:"image,omitempty"`
	Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
	Video     *EmbedVideo     `json:"video,omitempty"`
	Provider  *EmbedProvider  `json:"provider,omitempty"`
	Author    *EmbedAuthor    `json:"author,omitempty"`
	Fields    []EmbedField    `json:"fields,omitempty"`
}

Embed describes a box with a left colored border that sometimes appears in messages.

func NewEmbed

func NewEmbed() *Embed

NewEmbed creates a normal embed with default values.

func (Embed) Length

func (e Embed) Length() int

Length returns the sum of the lengths of all text in the embed.

func (*Embed) Validate

func (e *Embed) Validate() error

Validate validates the embed.

type EmbedAuthor

type EmbedAuthor struct {
	Name      string `json:"name,omitempty"`
	URL       URL    `json:"url,omitempty"`
	Icon      URL    `json:"icon_url,omitempty"`
	ProxyIcon URL    `json:"proxy_icon_url,omitempty"`
}

type EmbedField

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

type EmbedFooter

type EmbedFooter struct {
	Text      string `json:"text"`
	Icon      URL    `json:"icon_url,omitempty"`
	ProxyIcon URL    `json:"proxy_icon_url,omitempty"`
}

EmbedFooter is the footer of an embed.

type EmbedImage

type EmbedImage struct {
	URL    URL  `json:"url"`
	Proxy  URL  `json:"proxy_url"`
	Height uint `json:"height,omitempty"`
	Width  uint `json:"width,omitempty"`
}

EmbedImage is the large image of an embed.

type EmbedProvider

type EmbedProvider struct {
	Name string `json:"name"`
	URL  URL    `json:"url"`
}

type EmbedThumbnail

type EmbedThumbnail struct {
	URL    URL  `json:"url,omitempty"`
	Proxy  URL  `json:"proxy_url,omitempty"`
	Height uint `json:"height,omitempty"`
	Width  uint `json:"width,omitempty"`
}

EmbedThumbnail is the small image of an embed. It often appears on the right.

type EmbedType deprecated

type EmbedType string

EmbedTypes are "loosely defined" and, for the most part, are not used by our clients for rendering. Embed attributes power what is rendered.

Deprecated: Embed types should be considered deprecated and might be removed in a future API version.

const (
	NormalEmbed  EmbedType = "rich"
	ImageEmbed   EmbedType = "image"
	VideoEmbed   EmbedType = "video"
	GIFVEmbed    EmbedType = "gifv"
	ArticleEmbed EmbedType = "article"
	LinkEmbed    EmbedType = "link"
)

Embed type constants.

type EmbedVideo

type EmbedVideo struct {
	URL    URL  `json:"url"`
	Proxy  URL  `json:"proxy_url,omitempty"`
	Height uint `json:"height"`
	Width  uint `json:"width"`
}

EmbedVideo is the video of an embed.

type Emoji

type Emoji struct {
	// ID is the ID of the Emoji.
	// The ID will be NullSnowflake, if the Emoji is a Unicode emoji.
	ID EmojiID `json:"id"`
	// Name is the name of the emoji.
	Name string `json:"name"`

	// RoleIDs are the roles the emoji is whitelisted to.
	//
	// This field is only available for custom emojis.
	RoleIDs []RoleID `json:"roles,omitempty"`
	// User is the user that created the emoji.
	//
	// This field is only available for custom emojis.
	User User `json:"user,omitempty"`

	// RequireColons specifies whether the emoji must be wrapped in colons.
	//
	// This field is only available for custom emojis.
	RequireColons bool `json:"require_colons,omitempty"`
	// Managed specifies whether the emoji is managed.
	//
	// This field is only available for custom emojis.
	Managed bool `json:"managed,omitempty"`
	// Animated specifies whether the emoji is animated.
	//
	// This field is only available for custom emojis.
	Animated bool `json:"animated,omitempty"`
	// Available specifies whether the emoji can be used.
	// This may be false due to loss of Server Boosts.
	//
	// This field is only available for custom emojis.
	Available bool `json:"available,omitempty"`
}

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

func (Emoji) APIString

func (e Emoji) APIString() APIEmoji

APIString returns a string usable for sending over to the API.

func (Emoji) CreatedAt

func (e Emoji) CreatedAt() time.Time

CreatedAt returns a time object representing when the emoji was created.

This will only work for custom emojis.

func (Emoji) EmojiURL

func (e Emoji) EmojiURL() string

EmojiURL returns the URL of the emoji and auto-detects a suitable type.

This will only work for custom emojis.

func (Emoji) EmojiURLWithType

func (e Emoji) EmojiURLWithType(t ImageType) string

EmojiURLWithType returns the URL to the emoji's image.

This will only work for custom emojis.

Supported ImageTypes: PNG, GIF

func (Emoji) IsCustom

func (e Emoji) IsCustom() bool

IsCustom returns whether the emoji is a custom emoji.

func (Emoji) IsUnicode

func (e Emoji) IsUnicode() bool

IsUnicode returns whether the emoji is a unicode emoji.

func (Emoji) String

func (e Emoji) String() string

String formats the string like how the client does.

type EmojiID

type EmojiID Snowflake

EmojiID is the snowflake type for a EmojiID.

func (EmojiID) Increment

func (s EmojiID) Increment() uint16

func (EmojiID) IsNull

func (s EmojiID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (EmojiID) IsValid

func (s EmojiID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (EmojiID) MarshalJSON

func (s EmojiID) MarshalJSON() ([]byte, error)

func (EmojiID) PID

func (s EmojiID) PID() uint8

func (EmojiID) String

func (s EmojiID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (EmojiID) Time

func (s EmojiID) Time() time.Time

func (*EmojiID) UnmarshalJSON

func (s *EmojiID) UnmarshalJSON(v []byte) error

func (EmojiID) Worker

func (s EmojiID) Worker() uint8

type EntityID

type EntityID Snowflake

EntityID is the snowflake type for a EntityID.

func (EntityID) Increment

func (s EntityID) Increment() uint16

func (EntityID) IsNull

func (s EntityID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (EntityID) IsValid

func (s EntityID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (EntityID) MarshalJSON

func (s EntityID) MarshalJSON() ([]byte, error)

func (EntityID) PID

func (s EntityID) PID() uint8

func (EntityID) String

func (s EntityID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (EntityID) Time

func (s EntityID) Time() time.Time

func (*EntityID) UnmarshalJSON

func (s *EntityID) UnmarshalJSON(v []byte) error

func (EntityID) Worker

func (s EntityID) Worker() uint8

type EntityMetadata

type EntityMetadata struct {
	// Location describes where the event takes place at. This is not
	// optional when GuildScheduled#EntityType is set as ExternalEntity.
	Location string `json:"location,omitempty"`
}

EntityMetadata is the entity metadata of GuildScheduledEvent.

type EntityType

type EntityType int

EntityType describes the different types GuildScheduledEvent can be.

const (
	StageInstanceEntity EntityType = iota + 1
	VoiceEntity
	ExternalEntity
)

type EventID

type EventID Snowflake

EventID is the snowflake type for a EventID.

func (EventID) Increment

func (s EventID) Increment() uint16

func (EventID) IsNull

func (s EventID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (EventID) IsValid

func (s EventID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (EventID) MarshalJSON

func (s EventID) MarshalJSON() ([]byte, error)

func (EventID) PID

func (s EventID) PID() uint8

func (EventID) String

func (s EventID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (EventID) Time

func (s EventID) Time() time.Time

func (*EventID) UnmarshalJSON

func (s *EventID) UnmarshalJSON(v []byte) error

func (EventID) Worker

func (s EventID) Worker() uint8

type EventStatus

type EventStatus int

EventStatus describes the different statuses GuildScheduledEvent can be.

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

const (
	ScheduledEvent EventStatus = iota + 1
	ActiveEvent
	CompletedEvent
	CancelledEvent
)

type ExpireBehavior

type ExpireBehavior uint8

ExpireBehavior is the integration expire behavior that regulates what happens, if a subscriber expires.

const (
	// RemoveRole removes the role of the subscriber.
	RemoveRole ExpireBehavior = iota
	// Kick kicks the subscriber from the guild.
	Kick
)

https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors

type ExplicitFilter

type ExplicitFilter enum.Enum

ExplicitFilter is the explicit content filter level of a guild.

const (
	// NoContentFilter disables content filtering for the guild.
	NoContentFilter ExplicitFilter = iota
	// MembersWithoutRoles filters only members without roles.
	MembersWithoutRoles
	// AllMembers enables content filtering for all members.
	AllMembers
)

https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level

const NullExplicitFilter ExplicitFilter = enum.Null

NullExplicitFilter serialized to JSON null. This should only be used on nullable fields.

func (ExplicitFilter) MarshalJSON

func (f ExplicitFilter) MarshalJSON() ([]byte, error)

func (*ExplicitFilter) UnmarshalJSON

func (f *ExplicitFilter) UnmarshalJSON(b []byte) error

type ForumLayoutType added in v3.3.0

type ForumLayoutType uint8

https://discord.com/developers/docs/resources/channel#channel-object-forum-layout-types

const (
	// No default has been set for forum channel.
	ForumLayoutTypeNotSet ForumLayoutType = iota
	// Display posts as a list.
	ForumLayoutTypeListView
	// Display posts as a collection of tiles.
	ForumLayoutTypeGalleryView
)

type ForumReaction added in v3.2.0

type ForumReaction struct {
	// EmojiID is set when there is a custom emoji used.
	// Only one of EmojiID and EmojiName can be set
	EmojiID EmojiID `json:"emoji_id"`
	// EmojiName is set when the emoji is a normal unicode emoji.
	// Only one of EmojiID and EmojiName can be set
	EmojiName option.String `json:"emoji_name"`
}

ForumReaction is used in several forum-related structures. It is officially named the "Default Reaction" object.

type Guild

type Guild struct {
	// ID is the guild id.
	ID GuildID `json:"id"`
	// Name is the guild name (2-100 characters, excluding trailing and leading
	// whitespace).
	Name string `json:"name"`
	// Icon is the icon hash.&nullableUint64{}
	Icon Hash `json:"icon"`
	// Splash is the splash hash.
	Splash Hash `json:"splash,omitempty"`
	// DiscoverySplash is the discovery splash hash.
	//
	// Only present for guilds with the "DISCOVERABLE" feature.
	DiscoverySplash Hash `json:"discovery_splash,omitempty"`

	// Owner is true if the user is the owner of the guild.
	Owner bool `json:"owner,omitempty"`
	// Widget is true if the server widget is enabled.
	Widget bool `json:"widget_enabled,omitempty"`

	// SystemChannelFlags are the system channel flags.
	SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"`
	// Verification is the verification level required for the guild.
	Verification Verification `json:"verification_level"`
	// Notification is the default message notifications level.
	Notification Notification `json:"default_message_notifications"`
	// ExplicitFilter is the explicit content filter level.
	ExplicitFilter ExplicitFilter `json:"explicit_content_filter"`
	// NitroBoost is the premium tier (Server Boost level).
	NitroBoost NitroBoost `json:"premium_tier"`
	// MFA is the required MFA level for the guild.
	MFA MFALevel `json:"mfa_level"`

	// OwnerID is the id of owner.
	OwnerID UserID `json:"owner_id"`
	// WidgetChannelID is the channel id that the widget will generate an
	// invite to, or null if set to no invite.
	WidgetChannelID ChannelID `json:"widget_channel_id,omitempty"`
	// SystemChannelID is the the id of the channel where guild notices such as
	// welcome messages and boost events are posted.
	SystemChannelID ChannelID `json:"system_channel_id,omitempty"`

	// Permissions are the total permissions for the user in the guild
	// (excludes overrides).
	Permissions Permissions `json:"permissions,string,omitempty"`

	// VoiceRegion is the voice region id for the guild.
	VoiceRegion string `json:"region"`

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

	// Roles are the roles in the guild.
	Roles []Role `json:"roles"`
	// Emojis are the custom guild emojis.
	Emojis []Emoji `json:"emojis"`
	// Features are the enabled guild features.
	Features []GuildFeature `json:"features"`

	// AppID is the application id of the guild creator if it is bot-created.
	//
	// This field is nullable.
	AppID AppID `json:"application_id,omitempty"`

	// RulesChannelID is the id of the channel where guilds with the "PUBLIC"
	// feature can display rules and/or guidelines.
	RulesChannelID ChannelID `json:"rules_channel_id"`

	// MaxPresences is the maximum number of presences for the guild (the
	// default value, currently 25000, is in effect when null is returned, so
	// effectively when this field is 0).
	MaxPresences uint64 `json:"max_presences,omitempty"`
	// MaxMembers the maximum number of members for the guild.
	MaxMembers uint64 `json:"max_members,omitempty"`

	// VanityURL is the the vanity url code for the guild.
	VanityURLCode string `json:"vanity_url_code,omitempty"`
	// Description is the description for the guild, if the guild is
	// discoverable.
	Description string `json:"description,omitempty"`

	// Banner is the banner hash.
	Banner Hash `json:"banner,omitempty"`

	// NitroBoosters is the number of boosts this guild currently has.
	NitroBoosters uint64 `json:"premium_subscription_count,omitempty"`

	// PreferredLocale is the the preferred locale of a guild with the "PUBLIC"
	// feature; used in server discovery and notices from Discord. Defaults to
	// "en-US".
	PreferredLocale string `json:"preferred_locale"`

	// PublicUpdatesChannelID is the id of the channel where admins and
	// moderators of guilds with the "PUBLIC" feature receive notices from
	// Discord.
	PublicUpdatesChannelID ChannelID `json:"public_updates_channel_id"`

	// MaxVideoChannelUsers is the maximum amount of users in a video channel.
	MaxVideoChannelUsers uint64 `json:"max_video_channel_users,omitempty"`

	// ApproximateMembers is the approximate number of members in this guild,
	// returned by the GuildWithCount method.
	ApproximateMembers uint64 `json:"approximate_member_count,omitempty"`
	// ApproximatePresences is the approximate number of non-offline members in
	// this guild, returned by the GuildWithCount method.
	ApproximatePresences uint64 `json:"approximate_presence_count,omitempty"`
	// NSFWLevel is the level of NSFW of the guild.
	NSFWLevel NSFWLevel `json:"nsfw_level"`
}

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

func (Guild) BannerURL

func (g Guild) BannerURL() string

BannerURL returns the URL to the banner, which is the image on top of the channels list. This will always return a link to a PNG file.

func (Guild) BannerURLWithType

func (g Guild) BannerURLWithType(t ImageType) string

BannerURLWithType returns the URL to the banner, which is the image on top of the channels list using the passed image type.

Supported ImageTypes: PNG, JPEG, WebP

func (Guild) CreatedAt

func (g Guild) CreatedAt() time.Time

CreatedAt returns a time object representing when the guild was created.

func (Guild) DiscoverySplashURL

func (g Guild) DiscoverySplashURL() string

DiscoverySplashURL returns the URL to the guild discovery splash. This will always return a link to a PNG file.

func (Guild) DiscoverySplashURLWithType

func (g Guild) DiscoverySplashURLWithType(t ImageType) string

DiscoverySplashURLWithType returns the URL to the guild discovery splash, using the passed ImageType.

Supported ImageTypes: PNG, JPEG, WebP

func (Guild) IconURL

func (g Guild) IconURL() string

IconURL returns the URL to the guild icon and auto detects a suitable type. An empty string is returned if there's no icon.

func (Guild) IconURLWithType

func (g Guild) IconURLWithType(t ImageType) string

IconURLWithType returns the URL to the guild icon using the passed ImageType. An empty string is returned if there's no icon.

Supported ImageTypes: PNG, JPEG, WebP, GIF

func (Guild) SplashURL

func (g Guild) SplashURL() string

SplashURL returns the URL to the guild splash, which is the invite page's background. This will always return a link to a PNG file.

func (Guild) SplashURLWithType

func (g Guild) SplashURLWithType(t ImageType) string

SplashURLWithType returns the URL to the guild splash, which is the invite page's background, using the passed ImageType.

Supported ImageTypes: PNG, JPEG, WebP

type GuildCommandPermissions

type GuildCommandPermissions struct {
	ID          CommandID            `json:"id"`
	AppID       AppID                `json:"application_id"`
	GuildID     GuildID              `json:"guild_id"`
	Permissions []CommandPermissions `json:"permissions"`
}

https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure

type GuildFeature

type GuildFeature string
const (
	// InviteSplash is set, if the guild has access to set an invite splash
	// background.
	InviteSplash GuildFeature = "INVITE_SPLASH"
	// VIPRegions is set, if the guild has access to set 384kbps bitrate in
	// voice (previously VIP voice servers).
	VIPRegions GuildFeature = "VIP_REGIONS"
	// VanityURL is set, if the guild has access to set a vanity URL.
	VanityURL GuildFeature = "VANITY_URL"
	// Verified is set, if the guild is verified.
	Verified GuildFeature = "VERIFIED"
	// Partnered is set, if the guild is partnered.
	Partnered GuildFeature = "PARTNERED"
	// Public is set, if the guild is public.
	Public GuildFeature = "PUBLIC"
	// Commerce is set, if the guild has access to use commerce features
	// (i.e. create store channels).
	Commerce GuildFeature = "COMMERCE"
	// News is set, if the guild has access to create news channels.
	News GuildFeature = "NEWS"
	// Discoverable is set, if the guild is able to be discovered in the
	// directory.
	Discoverable GuildFeature = "DISCOVERABLE"
	// Featurable is set, if the guild is able to be featured in the directory.
	Featurable GuildFeature = "FEATURABLE"
	// AnimatedIcon is set, if the guild has access to set an animated guild
	// icon.
	AnimatedIcon GuildFeature = "ANIMATED_ICON"
	Banner GuildFeature = "BANNER"
)

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

type GuildID

type GuildID Snowflake

GuildID is the snowflake type for a GuildID.

func (GuildID) Increment

func (s GuildID) Increment() uint16

func (GuildID) IsNull

func (s GuildID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (GuildID) IsValid

func (s GuildID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (GuildID) MarshalJSON

func (s GuildID) MarshalJSON() ([]byte, error)

func (GuildID) PID

func (s GuildID) PID() uint8

func (GuildID) String

func (s GuildID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (GuildID) Time

func (s GuildID) Time() time.Time

func (*GuildID) UnmarshalJSON

func (s *GuildID) UnmarshalJSON(v []byte) error

func (GuildID) Worker

func (s GuildID) Worker() uint8

type GuildPreview

type GuildPreview struct {
	// ID is the guild id.
	ID GuildID `json:"id"`
	// Name is the guild name (2-100 characters).
	Name string `json:"name"`

	// Icon is the icon hash.
	Icon Hash `json:"icon"`
	// Splash is the splash hash.
	Splash Hash `json:"splash"`
	// DiscoverySplash is the discovery splash hash.
	DiscoverySplash Hash `json:"discovery_splash"`

	// Emojis are the custom guild emojis.
	Emojis []Emoji `json:"emojis"`
	// Features are the enabled guild features.
	Features []GuildFeature `json:"guild_features"`

	// ApproximateMembers is the approximate number of members in this guild.
	ApproximateMembers uint64 `json:"approximate_member_count"`
	// ApproximatePresences is the approximate number of online members in this
	// guild.
	ApproximatePresences uint64 `json:"approximate_presence_count"`

	// Description is the description for the guild.
	Description string `json:"description,omitempty"`
}

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

func (GuildPreview) CreatedAt

func (g GuildPreview) CreatedAt() time.Time

CreatedAt returns a time object representing when the guild the preview represents was created.

func (GuildPreview) DiscoverySplashURL

func (g GuildPreview) DiscoverySplashURL() string

DiscoverySplashURL returns the URL to the guild discovery splash. This will always return a link to a PNG file.

func (GuildPreview) DiscoverySplashURLWithType

func (g GuildPreview) DiscoverySplashURLWithType(t ImageType) string

DiscoverySplashURLWithType returns the URL to the guild discovery splash, using the passed ImageType.

Supported ImageTypes: PNG, JPEG, WebP

func (GuildPreview) IconURL

func (g GuildPreview) IconURL() string

IconURL returns the URL to the guild icon and auto detects a suitable type. An empty string is returned if there's no icon.

func (GuildPreview) IconURLWithType

func (g GuildPreview) IconURLWithType(t ImageType) string

IconURLWithType returns the URL to the guild icon using the passed ImageType. An empty string is returned if there's no icon.

Supported ImageTypes: PNG, JPEG, WebP, GIF

func (GuildPreview) SplashURL

func (g GuildPreview) SplashURL() string

SplashURL returns the URL to the guild splash, which is the invite page's background. This will always return a link to a PNG file.

func (GuildPreview) SplashURLWithType

func (g GuildPreview) SplashURLWithType(t ImageType) string

SplashURLWithType returns the URL to the guild splash, which is the invite page's background, using the passed ImageType.

Supported ImageTypes: PNG, JPEG, WebP

type GuildScheduledEvent

type GuildScheduledEvent struct {
	// ID is the id of the scheduled event.
	ID EventID `json:"id"`
	// GuildID is the guild id of where the scheduled event belongs to.
	GuildID GuildID `json:"guild_id"`
	// ChannelID is the channel id in which the scheduled event will be
	// hosted at, this may be NullChannelID if the EntityType is set
	// to ExternalEntity.
	ChannelID ChannelID `json:"channel_id"`
	// CreatorID is the user id of who created the scheduled event.
	CreatorID UserID `json:"creator_id"`
	// Name is the name of the scheduled event.
	Name string `json:"name"`
	// Description is the description of the scheduled event.
	Description string `json:"description"`
	// StartTime is when the scheduled event will start at.
	StartTime Timestamp `json:"scheduled_start_time"`
	// EndTime is when the scheduled event will end at, if it does.
	EndTime Timestamp `json:"scheduled_end_time"`
	// PrivacyLevel is the privacy level of the scheduled event.
	PrivacyLevel ScheduledEventPrivacyLevel `json:"privacy_level"`
	// Status is the status of the scheduled event.
	Status EventStatus `json:"status"`
	// EntityType describes the type of scheduled event.
	EntityType EntityType `json:"entity_type"`
	// EntityID is the id of an entity associated with a scheduled event.
	EntityID EntityID `json:"entity_id"`
	// EntityMetadata is additional metadata for the scheduled event.
	EntityMetadata *EntityMetadata `json:"entity_metadata"`
	// Creator is the the user responsible for creating the scheduled event. This field
	// will only be present if CreatorID is
	Creator *User `json:"creator"`
	// UserCount is the number of users subscribed to the scheduled event.
	UserCount int `json:"user_count"`
	// Image is the cover image hash of the scheduled event.
	Image Hash `json:"image,omitempty"`
}

GuildScheduledEvent describes the scheduled event structure.

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

type GuildUser

type GuildUser struct {
	User
	Member *Member `json:"member,omitempty"`
}

type GuildWidget

type GuildWidget struct {
	// ID is the ID of the guild.
	ID GuildID `json:"id"`
	// Name is the name of the guild.
	Name string `json:"name"`
	// InviteURl is the url of an instant invite to the guild.
	InviteURL string    `json:"instant_invite"`
	Channels  []Channel `json:"channels"`
	Members   []User    `json:"members"`
	// Presence count is the amount of presences in the guild
	PresenceCount int `json:"presence_count"`
}

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

type GuildWidgetSettings

type GuildWidgetSettings struct {
	// Enabled specifies whether the widget is enabled.
	Enabled bool `json:"enabled"`
	// ChannelID is the widget channel id.
	ChannelID ChannelID `json:"channel_id,omitempty"`
}

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

type Hash

type Hash = string

type ImageType

type ImageType string
const (
	// AutoImage chooses automatically between a PNG and GIF.
	AutoImage ImageType = "auto"

	// JPEGImage is the JPEG image type.
	JPEGImage ImageType = ".jpeg"
	// PNGImage is the PNG image type.
	PNGImage ImageType = ".png"
	// WebPImage is the WebP image type.
	WebPImage ImageType = ".webp"
	// GIFImage is the GIF image type.
	GIFImage ImageType = ".gif"
)

type InstallParams added in v3.3.0

type InstallParams struct {
	// Scopes is the scopes to add the application to the server with.
	Scopes []string `json:"scopes"`
	// Permissions is the permissions to request for the bot role.
	Permissions Permissions `json:"permissions,string"`
}

https://discord.com/developers/docs/resources/application#install-params-object

type IntegerChoice

type IntegerChoice struct {
	Name              string        `json:"name"`
	NameLocalizations StringLocales `json:"name_localizations,omitempty"`
	Value             int           `json:"value"`
	// LocalizedName is only populated when this is received from Discord's API.
	LocalizedName string `json:"name_localized,omitempty"`
}

IntegerChoice is a pair of string key to an integer.

type IntegerOption

type IntegerOption struct {
	OptionName               string          `json:"name"`
	OptionNameLocalizations  StringLocales   `json:"name_localizations,omitempty"`
	Description              string          `json:"description"`
	DescriptionLocalizations StringLocales   `json:"description_localizations,omitempty"`
	Required                 bool            `json:"required"`
	Min                      option.Int      `json:"min_value,omitempty"`
	Max                      option.Int      `json:"max_value,omitempty"`
	Choices                  []IntegerChoice `json:"choices,omitempty"`
	// Autocomplete must not be true if Choices are present.
	Autocomplete bool `json:"autocomplete"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

IntegerOption is a subcommand option that fits into a CommandOptionValue.

func NewIntegerOption

func NewIntegerOption(name, description string, required bool) *IntegerOption

NewIntegerOption creates a new integer option.

func (*IntegerOption) MarshalJSON

func (i *IntegerOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals IntegerOption to JSON with the "type" field.

func (*IntegerOption) Name

func (i *IntegerOption) Name() string

Name implements CommandOption.

func (*IntegerOption) Type

func (i *IntegerOption) Type() CommandOptionType

Type implements CommandOptionValue.

type Integration

type Integration struct {
	// ID is the integration id.
	ID IntegrationID `json:"id"`
	// Name is the integration name.
	Name string `json:"name"`
	// Type is the integration type (twitch, youtube, discord).
	Type Service `json:"type"`

	// Enables specifies if the integration is enabled.
	Enabled bool `json:"enabled"`
	// Syncing specifies if the integration is syncing.
	// This field is not provided for bot integrations.
	Syncing bool `json:"syncing,omitempty"`

	// RoleID is the id that this integration uses for "subscribers".
	// This field is not provided for bot integrations.
	RoleID RoleID `json:"role_id,omitempty"`

	// EnableEmoticons specifies whether emoticons should be synced for this
	// integration (twitch only currently).
	// This field is not provided for bot integrations.
	EnableEmoticons bool `json:"enable_emoticons,omitempty"`

	// ExpireBehavior is the behavior of expiring subscribers.
	// This field is not provided for bot integrations.
	ExpireBehavior ExpireBehavior `json:"expire_behavior,omitempty"`
	// ExpireGracePeriod is the grace period (in days) before expiring
	// subscribers.
	// This field is not provided for bot integrations.
	ExpireGracePeriod int `json:"expire_grace_period,omitempty"`

	// User is the user for this integration.
	// This field is not provided for bot integrations.
	User User `json:"user,omitempty"`
	// Account is the integration account information.
	Account IntegrationAccount `json:"account"`

	// SyncedAt specifies when this integration was last synced.
	// This field is not provided for bot integrations.
	SyncedAt Timestamp `json:"synced_at,omitempty"`
	// SubscriberCount specifies how many subscribers the integration has.
	// This field is not provided for bot integrations.
	SubscriberCount int `json:"subscriber_count,omitempty"`
	// Revoked specifies whether the integration has been revoked.
	// This field is not provided for bot integrations.
	Revoked bool `json:"revoked,omitempty"`
	// Application is the bot/OAuth2 application for integrations.
	Application *IntegrationApplication `json:"application,omitempty"`
}

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

func (Integration) CreatedAt

func (i Integration) CreatedAt() time.Time

CreatedAt returns a time object representing when the integration was created.

type IntegrationAccount

type IntegrationAccount struct {
	// ID is the id of the account.
	ID string `json:"id"`
	// Name is the name of the account.
	Name string `json:"name"`
}

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

type IntegrationApplication

type IntegrationApplication struct {
	// ID is the id of the app.
	ID IntegrationID `json:"id"`
	// Name is the name of the app.
	Name string `json:"name"`
	// Icon is the icon hash of the app.
	Icon *Hash `json:"icon"`
	// Description is the description of the app.
	Description string `json:"description"`
	// Summary is a summary of the app.
	Summary string `json:"summary"`
	// Bot is the bot associated with the app.
	Bot User `json:"bot,omitempty"`
}

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

func (IntegrationApplication) CreatedAt

func (i IntegrationApplication) CreatedAt() time.Time

CreatedAt returns a time object representing when the integration application was created.

type IntegrationID

type IntegrationID Snowflake

IntegrationID is the snowflake type for a IntegrationID.

func (IntegrationID) Increment

func (s IntegrationID) Increment() uint16

func (IntegrationID) IsNull

func (s IntegrationID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (IntegrationID) IsValid

func (s IntegrationID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (IntegrationID) MarshalJSON

func (s IntegrationID) MarshalJSON() ([]byte, error)

func (IntegrationID) PID

func (s IntegrationID) PID() uint8

func (IntegrationID) String

func (s IntegrationID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (IntegrationID) Time

func (s IntegrationID) Time() time.Time

func (*IntegrationID) UnmarshalJSON

func (s *IntegrationID) UnmarshalJSON(v []byte) error

func (IntegrationID) Worker

func (s IntegrationID) Worker() uint8

type InteractionData

type InteractionData interface {
	InteractionType() InteractionDataType
	// contains filtered or unexported methods
}

InteractionData holds the respose data of an interaction, or more specifically, the data that Discord sends to us. Type assertions should be made on it to access the underlying data.

The following types implement this interface:

  • *PingInteraction
  • *AutocompleteInteraction
  • *CommandInteraction
  • *ModalInteraction
  • *StringSelectInteraction (also ComponentInteraction)
  • *RoleSelectInteraction (also ComponentInteraction)
  • *UserSelectInteraction (also ComponentInteraction)
  • *ChannelSelectInteraction (also ComponentInteraction)
  • *MentionableSelectInteraction (also ComponentInteraction)
  • *ButtonInteraction (also ComponentInteraction)

type InteractionDataType

type InteractionDataType uint

InteractionDataType is the type of each Interaction, enumerated in integers.

const (
	PingInteractionType InteractionDataType = iota + 1
	CommandInteractionType
	ComponentInteractionType
	AutocompleteInteractionType
	ModalInteractionType
)

type InteractionEvent

type InteractionEvent struct {
	ID        InteractionID   `json:"id"`
	Data      InteractionData `json:"data"`
	AppID     AppID           `json:"application_id"`
	ChannelID ChannelID       `json:"channel_id,omitempty"`
	Token     string          `json:"token"`
	Version   int             `json:"version"`

	// Channel is the channel that the interaction was sent from.
	Channel *Channel `json:"channel,omitempty"`

	// Message is the message the component was attached to.
	// Only present for component interactions, not command interactions.
	Message *Message `json:"message,omitempty"`

	// Member is only present if this came from a guild. To get a user, use the
	// Sender method.
	Member  *Member `json:"member,omitempty"`
	GuildID GuildID `json:"guild_id,omitempty"`

	// User is only present if this didn't come from a guild. To get a user, use
	// the Sender method.
	User *User `json:"user,omitempty"`

	// Locale is the selected language of the invoking user. It is returned in
	// all interactions except ping interactions. Use this Locale field to
	// obtain the language of the user who used the interaction.
	Locale Language `json:"locale,omitempty"`
	// GuildLocale is the guild's preferred locale, if invoked in a guild.
	GuildLocale string `json:"guild_locale,omitempty"`
}

InteractionEvent describes the full incoming interaction event. It may be a gateway event or a webhook event.

https://discord.com/developers/docs/topics/gateway#interactions

func (*InteractionEvent) MarshalJSON

func (e *InteractionEvent) MarshalJSON() ([]byte, error)

func (*InteractionEvent) Sender

func (e *InteractionEvent) Sender() *User

Sender returns the sender of this event from either the Member field or the User field. If neither of those fields are available, then nil is returned.

func (*InteractionEvent) SenderID

func (e *InteractionEvent) SenderID() UserID

SenderID returns the sender's ID. See Sender for more information. If Sender returns nil, then 0 is returned.

func (*InteractionEvent) UnmarshalJSON

func (e *InteractionEvent) UnmarshalJSON(b []byte) error

type InteractionID

type InteractionID Snowflake

InteractionID is the snowflake type for a InteractionID.

func (InteractionID) Increment

func (s InteractionID) Increment() uint16

func (InteractionID) IsNull

func (s InteractionID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (InteractionID) IsValid

func (s InteractionID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (InteractionID) MarshalJSON

func (s InteractionID) MarshalJSON() ([]byte, error)

func (InteractionID) PID

func (s InteractionID) PID() uint8

func (InteractionID) String

func (s InteractionID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (InteractionID) Time

func (s InteractionID) Time() time.Time

func (*InteractionID) UnmarshalJSON

func (s *InteractionID) UnmarshalJSON(v []byte) error

func (InteractionID) Worker

func (s InteractionID) Worker() uint8

type InteractiveComponent

type InteractiveComponent interface {
	Component
	// ID returns the ID of the underlying component.
	ID() ComponentID
	// contains filtered or unexported methods
}

InteractiveComponent extends the Component for components that are interactible, or components that aren't containers (like ActionRow). This is useful for ActionRow to type-check that no nested ActionRows are allowed.

The following types satisfy this interface:

  • *ButtonComponent
  • *SelectComponent
  • *TextInputComponent
  • *UserSelectComponent
  • *RoleSelectComponent
  • *MentionableSelectComponent
  • *ChannelSelectComponent

type Invite

type Invite struct {
	// Code is the invite code (unique ID).
	Code string `json:"code"`
	// Guild is the partial guild this invite is for.
	Guild *Guild `json:"guild,omitempty"`
	// Channel is the partial channel this invite is for.
	Channel Channel `json:"channel"`
	// Inviter is the user who created the invite
	Inviter *User `json:"inviter,omitempty"`

	// Target is the target user for this invite.
	Target *User `json:"target_user,omitempty"`
	// Target type is the type of user target for this invite.
	TargetType InviteUserType `json:"target_user_type,omitempty"`

	// ApproximatePresences is the approximate count of online members (only
	// present when Target is set).
	ApproximatePresences uint `json:"approximate_presence_count,omitempty"`
	// ApproximateMembers is the approximate count of total members
	ApproximateMembers uint `json:"approximate_member_count,omitempty"`

	// InviteMetadata contains extra information about the invite.
	// So far, this field is only available when fetching Channel- or
	// GuildInvites. Additionally the Uses field is filled when getting the
	// VanityURL of a guild.
	InviteMetadata
}

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

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

func (Invite) LongURL

func (i Invite) LongURL() string

LongURL returns a long-form Discord invite URL linking to the invite.

func (Invite) URL

func (i Invite) URL() string

URL returns a Discord invite URL linking to the invite.

type InviteMetadata

type InviteMetadata struct {
	// Number of times this invite has been used
	Uses int `json:"uses"`
	// Max number of times this invite can be used
	MaxUses int `json:"max_uses"`
	// Duration (in seconds) after which the invite expires
	MaxAge Seconds `json:"max_age"`
	// Whether this invite only grants temporary membership
	Temporary bool `json:"temporary"`
	// When this invite was created
	CreatedAt Timestamp `json:"created_at"`
}

Extra information about an invite, will extend the invite object.

https://discord.com/developers/docs/resources/invite#invite-metadata-object

type Language

type Language string

Language is a string type for language codes, such as "en-US" or "fr". Refer to the constants for valid language codes.

The list of all valid language codes are at https://discord.com/developers/docs/reference#locales

const (
	Danish        Language = "da"
	German        Language = "de"
	EnglishUK     Language = "en-GB"
	EnglishUS     Language = "en-US"
	Spanish       Language = "es-ES"
	French        Language = "fr"
	Croatian      Language = "hr"
	Italian       Language = "it"
	Lithuanian    Language = "lt"
	Hungarian     Language = "hu"
	Dutch         Language = "nl"
	Norwegian     Language = "no"
	Polish        Language = "pl"
	PortugueseBR  Language = "pt-BR"
	Romanian      Language = "ro"
	Finnish       Language = "fi"
	Swedish       Language = "sv-SE"
	Vietnamese    Language = "vi"
	Turkish       Language = "tr"
	Czech         Language = "cs"
	Greek         Language = "el"
	Bulgarian     Language = "bg"
	Russian       Language = "ru"
	Ukrainian     Language = "uk"
	Hindi         Language = "hi"
	Thai          Language = "th"
	ChineseChina  Language = "zh-CN"
	Japanese      Language = "ja"
	ChineseTaiwan Language = "zh-TW"
	Korean        Language = "ko"
)

type MFALevel

type MFALevel uint8

MFALevel is the required MFA level for a guild.

type Member

type Member struct {
	// User is the user this guild member represents.
	User User `json:"user"`
	// Nick is this users guild nickname.
	Nick string `json:"nick,omitempty"`
	// RoleIDs is an array of role object ids.
	RoleIDs []RoleID `json:"roles"`
	// Avatar is this member's guild avatar.
	Avatar Hash `json:"avatar,omitempty"`

	// Joined specifies when the user joined the guild.
	Joined Timestamp `json:"joined_at"`
	// BoostedSince specifies when the user started boosting the guild.
	BoostedSince Timestamp `json:"premium_since,omitempty"`
	// CommunicationDisabledUntil specifies when the user's timeout will expire.
	CommunicationDisabledUntil Timestamp `json:"communication_disabled_until"`

	// Deaf specifies whether the user is deafened in voice channels.
	Deaf bool `json:"deaf"`
	// Mute specifies whether the user is muted in voice channels.
	Mute bool `json:"mute"`

	// Flags is the member's flags represented as a bit set, defaults to 0.
	Flags MemberFlags `json:"flags"`

	// IsPending specifies whether the user has not yet passed the guild's Membership Screening requirements
	IsPending bool `json:"pending"`
}

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

The field user won't be included in the member object attached to MESSAGE_CREATE and MESSAGE_UPDATE gateway events.

func (Member) AvatarURL

func (m Member) AvatarURL(guildID GuildID) string

AvatarURL returns the URL of the Avatar Image. It automatically detects a suitable type.

func (Member) AvatarURLWithType

func (m Member) AvatarURLWithType(t ImageType, guildID GuildID) string

AvatarURLWithType returns the URL of the Avatar Image using the passed type. If the member has no Avatar, an empty string will be returned.

Supported Image Types: PNG, JPEG, WebP, GIF

func (Member) Mention

func (m Member) Mention() string

Mention returns the mention of the role.

type MemberFlags added in v3.3.0

type MemberFlags uint32

MemberFlags represents the bit set of member flags.

type MembershipState

type MembershipState uint8
const (
	MembershipInvited MembershipState = iota + 1
	MembershipAccepted
)

type MentionableOption

type MentionableOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

MentionableOption is a subcommand option that fits into a CommandOptionValue.

func NewMentionableOption

func NewMentionableOption(name, description string, required bool) *MentionableOption

NewMentionableOption creates a new mentionable option.

func (*MentionableOption) MarshalJSON

func (m *MentionableOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals MentionableOption to JSON with the "type" field.

func (*MentionableOption) Name

func (m *MentionableOption) Name() string

Name implements CommandOption.

func (*MentionableOption) Type

Type implements CommandOptionValue.

type MentionableSelectComponent added in v3.2.0

type MentionableSelectComponent struct {
	// CustomID is the custom unique ID.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Placeholder is the custom placeholder text if nothing is selected. Max
	// 100 characters.
	Placeholder string `json:"placeholder,omitempty"`
	// ValueLimits is the minimum and maximum number of items that can be
	// chosen. The default is [1, 1] if ValueLimits is a zero-value.
	ValueLimits [2]int `json:"-"`
	// Disabled disables the select if true.
	Disabled bool `json:"disabled,omitempty"`
}

func (*MentionableSelectComponent) ID added in v3.2.0

ID implements the Component interface.

func (*MentionableSelectComponent) MarshalJSON added in v3.2.0

func (s *MentionableSelectComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the select in the format Discord expects.

func (*MentionableSelectComponent) Type added in v3.2.0

Type implements the Component interface.

type MentionableSelectInteraction added in v3.3.0

type MentionableSelectInteraction struct {
	CustomID ComponentID `json:"custom_id"`
	Values   []Snowflake `json:"values"`
}

MentionableSelectInteraction is a mentionable select component's response.

func (*MentionableSelectInteraction) ID added in v3.3.0

ID implements ComponentInteraction.

func (*MentionableSelectInteraction) InteractionType added in v3.3.0

InteractionType implements InteractionData.

func (*MentionableSelectInteraction) Type added in v3.3.0

Type implements ComponentInteraction.

type Message

type Message struct {
	// ID is the id of the message.
	ID MessageID `json:"id"`
	// ChannelID is the id of the channel the message was sent in.
	ChannelID ChannelID `json:"channel_id"`
	// GuildID is the id of the guild the message was sent in.
	GuildID GuildID `json:"guild_id,omitempty"`

	// Type is the type of message.
	Type MessageType `json:"type"`

	// Flags are the MessageFlags.
	Flags MessageFlags `json:"flags"`

	// TTS specifies whether the was a TTS message.
	TTS bool `json:"tts"`
	// Pinned specifies whether the message is pinned.
	Pinned bool `json:"pinned"`

	// MentionEveryone specifies whether the message mentions everyone.
	MentionEveryone bool `json:"mention_everyone"`
	// Mentions contains the users specifically mentioned in the message.
	//
	// The user objects in the mentions array will only have the partial
	// member field present in MESSAGE_CREATE and MESSAGE_UPDATE events from
	// text-based guild channels.
	Mentions []GuildUser `json:"mentions"`
	// MentionRoleIDs contains the ids of the roles specifically mentioned in
	// the message.
	MentionRoleIDs []RoleID `json:"mention_roles"`
	// MentionChannels are the channels specifically mentioned in the message.
	//
	// Not all channel mentions in a message will appear in mention_channels.
	// Only textual channels that are visible to everyone in a lurkable guild
	// will ever be included. Only crossposted messages (via Channel Following)
	// currently include mention_channels at all. If no mentions in the message
	// meet these requirements, the slice will be empty.
	MentionChannels []ChannelMention `json:"mention_channels,omitempty"`

	// Author is the author of the message.
	//
	// 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.
	Author User `json:"author"`

	// Content contains the contents of the message.
	Content string `json:"content"`

	// Timestamp specifies when the message was sent
	Timestamp Timestamp `json:"timestamp,omitempty"`
	// EditedTimestamp specifies when this message was edited.
	//
	// IsValid() will return false, if the messages hasn't been edited.
	EditedTimestamp Timestamp `json:"edited_timestamp,omitempty"`

	// Attachments contains any attached files.
	Attachments []Attachment `json:"attachments"`
	// Embeds contains any embedded content.
	Embeds []Embed `json:"embeds"`
	// Reactions contains any reactions to the message.
	Reactions []Reaction `json:"reactions,omitempty"`
	// Components contains any attached components.
	Components ContainerComponents `json:"components,omitempty"`

	// Used for validating a message was sent
	Nonce string `json:"nonce,omitempty"`

	// WebhookID contains the ID of the webhook, if the message was generated
	// by a webhook.
	WebhookID WebhookID `json:"webhook_id,omitempty"`

	// Activity is sent with Rich Presence-related chat embeds.
	Activity *MessageActivity `json:"activity,omitempty"`
	// Application is sent with Rich Presence-related chat embeds.
	Application *MessageApplication `json:"application,omitempty"`

	// ApplicationID contains the ID of the application, if this message was
	// generated by an interaction or an application-owned webhook.
	ApplicationID AppID `json:"application_id,omitempty"`

	// Reference is the reference data sent with crossposted messages and
	// inline replies.
	Reference *MessageReference `json:"message_reference,omitempty"`
	// ReferencedMessage is the message that was replied to. If not present and
	// the type is InlinedReplyMessage, the backend couldn't fetch the
	// replied-to message. If null, the message was deleted. If present and
	// non-null, it is a message object
	ReferencedMessage *Message `json:"referenced_message,omitempty"`

	// Interaction is the interaction that the message is in response to.
	// This is only present if the message is in response to an interaction.
	Interaction *MessageInteraction `json:"interaction,omitempty"`

	// Stickers contains the sticker "items" sent with the message.
	Stickers []StickerItem `json:"sticker_items,omitempty"`
}

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

func (Message) URL

func (m Message) URL() string

URL generates a Discord client URL to the message. If the message doesn't have a GuildID, it will generate a URL with the guild "@me".

type MessageActivity

type MessageActivity struct {
	// Type is the type of message activity.
	Type MessageActivityType `json:"type"`
	// PartyID is the party_id from a Rich Presence event.
	PartyID string `json:"party_id,omitempty"`
}

https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure

type MessageActivityType

type MessageActivityType uint8
const (
	JoinMessage MessageActivityType = iota + 1
	SpectateMessage
	ListenMessage
	JoinRequestMessage
)

https://discord.com/developers/docs/resources/channel#message-object-message-activity-types

type MessageApplication

type MessageApplication struct {
	// ID is the id of the application.
	ID AppID `json:"id"`
	// CoverID is the id of the embed's image asset.
	CoverID string `json:"cover_image,omitempty"`
	// Description is the application's description.
	Description string `json:"description"`
	// Icon is the id of the application's icon.
	Icon string `json:"icon"`
	// Name is the name of the application.
	Name string `json:"name"`
}

https://discord.com/developers/docs/resources/channel#message-object-message-application-structure

func (MessageApplication) CreatedAt

func (m MessageApplication) CreatedAt() time.Time

CreatedAt returns a time object representing when the message application was created.

type MessageFlags

type MessageFlags enum.Enum
const (
	// CrosspostedMessage specifies whether the message has been published to
	// subscribed channels (via Channel Following).
	CrosspostedMessage MessageFlags = 1 << iota
	// MessageIsCrosspost specifies whether the message originated from a
	// message in another channel (via Channel Following).
	MessageIsCrosspost
	// SuppressEmbeds specifies whether to not include any embeds when
	// serializing the message.
	SuppressEmbeds
	// SourceMessageDeleted specifies whether the source message for the
	// crosspost has been deleted (via Channel Following).
	SourceMessageDeleted
	// UrgentMessage specifies whether the message came from the urgent message
	// system.
	UrgentMessage
	// MessageHasThread specifies whether the message has an associated thread
	// with the same id as the message
	MessageHasThread
	// EphemeralMessage specifies whether the message is only visible to
	// the user who invoked the Interaction
	EphemeralMessage
	// MessageLoading specifies whether the message is an Interaction Response
	// and the bot is "thinking"
	MessageLoading

	// SuppressNotifications specifies whether the message will not trigger push and desktop notifications.
	SuppressNotifications = 1 << 12
)

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

const NullMessage MessageFlags = enum.Null

NullMessage is the JSON null value of MessageFlags.

type MessageID

type MessageID Snowflake

MessageID is the snowflake type for a MessageID.

func (MessageID) Increment

func (s MessageID) Increment() uint16

func (MessageID) IsNull

func (s MessageID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (MessageID) IsValid

func (s MessageID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (MessageID) MarshalJSON

func (s MessageID) MarshalJSON() ([]byte, error)

func (MessageID) PID

func (s MessageID) PID() uint8

func (MessageID) String

func (s MessageID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (MessageID) Time

func (s MessageID) Time() time.Time

func (*MessageID) UnmarshalJSON

func (s *MessageID) UnmarshalJSON(v []byte) error

func (MessageID) Worker

func (s MessageID) Worker() uint8

type MessageInteraction

type MessageInteraction struct {
	// ID is the id of the originating interaction.
	ID InteractionID `json:"id"`
	// Type is the type of the originating interaction.
	Type InteractionDataType `json:"type"`
	// Name is the name of the application command that was invoked with the
	// originating interaction.
	Name string `json:"name"`
	// User is the user who invoked the originating interaction.
	User User `json:"user"`
	// Member is the member who invoked the originating interaction in
	// the guild.
	Member *Member `json:"member,omitempty"`
}

https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure

type MessageReference

type MessageReference struct {
	// MessageID is the id of the originating message.
	MessageID MessageID `json:"message_id,omitempty"`
	// ChannelID is the id of the originating message's channel.
	ChannelID ChannelID `json:"channel_id,omitempty"`
	// GuildID is the id of the originating message's guild.
	GuildID GuildID `json:"guild_id,omitempty"`
}

MessageReference is used in four situations:

Crosspost messages

Messages that originated from another channel (IS_CROSSPOST flag). These messages have all three fields, with data of the original message that was crossposted.

Channel Follow Add messages

Automatic messages sent when a channel is followed into the current channel (type 12). These messages have the ChannelID and GuildID fields, with data of the followed announcement channel.

Pin messages

Automatic messages sent when a message is pinned (type 6). These messages have MessageID and ChannelID, and GuildID if it is in a guild, with data of the message that was pinned.

Replies

Messages replying to a previous message (type 19). These messages have MessageID, and ChannelID, and GuildID if it is in a guild, with data of the message that was replied to. The ChannelID and GuildID will be the same as the reply.

Replies are created by including a message_reference when sending a message. When sending, only MessageID is required. https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure

type MessageType

type MessageType uint8
const (
	DefaultMessage MessageType = iota
	RecipientAddMessage
	RecipientRemoveMessage
	CallMessage
	ChannelNameChangeMessage
	ChannelIconChangeMessage
	ChannelPinnedMessage
	GuildMemberJoinMessage
	NitroBoostMessage
	NitroTier1Message
	NitroTier2Message
	NitroTier3Message
	ChannelFollowAddMessage

	GuildDiscoveryDisqualifiedMessage
	GuildDiscoveryRequalifiedMessage
	GuildDiscoveryGracePeriodInitialWarning
	GuildDiscoveryGracePeriodFinalWarning
	// ThreadCreatedMessage is a new message sent to the parent GuildText
	// channel, used to inform users that a thread has been created. It is
	// currently only sent in one case: when a GuildPublicThread is created
	// from an older message (older is still TBD, but is currently set to a
	// very small value). The message contains a message reference with the
	// GuildID and ChannelID of the thread. The content of the message is the
	// name of the thread.
	ThreadCreatedMessage
	InlinedReplyMessage
	ChatInputCommandMessage
	// ThreadStarterMessage is a new message sent as the first message in
	// threads that are started from an existing message in the parent channel.
	// It only contains a message reference field that points to the message
	// from which the thread was started.
	ThreadStarterMessage
	GuildInviteReminderMessage
	ContextMenuCommand
	AutoModerationActionMessage
	RoleSubscriptionPurchaseMessage
	InteractionPremiumUpsellMessage

	StageStartMessage
	StageEndMessage
	StageSpeakerMessage

	StageTopicMessage

	GuildApplicationPremiumSubscriptionMessage
)

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

type Milliseconds

type Milliseconds float64

Milliseconds is in float64 because some Discord events return time with a trailing decimal.

func DurationToMilliseconds

func DurationToMilliseconds(dura time.Duration) Milliseconds

func (Milliseconds) Duration

func (ms Milliseconds) Duration() time.Duration

func (Milliseconds) String

func (ms Milliseconds) String() string

type ModalInteraction

type ModalInteraction struct {
	CustomID   ComponentID         `json:"custom_id"`
	Components ContainerComponents `json:"components"`
}

ModalInteraction is the submitted modal form

func (*ModalInteraction) InteractionType

func (m *ModalInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

type NSFWLevel added in v3.2.0

type NSFWLevel uint8

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

const (
	NSFWLevelDefault NSFWLevel = iota
	NSFWLevelExplicit
	NSFWLevelSafe
	NSFWLevelAgeRestricted
)

type NitroBoost

type NitroBoost uint8

NitroBoost is the premium tier (Server Boost level).

const (
	NoNitroLevel NitroBoost = iota
	NitroLevel1
	NitroLevel2
	NitroLevel3
)

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

type Notification

type Notification enum.Enum

Notification is the default message notification level of a guild.

const (
	// AllMessages sends notifications for all messages.
	AllMessages Notification = iota
	// OnlyMentions sends notifications only on mention.
	OnlyMentions
)

https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level

const NullNotification Notification = enum.Null

NullNotification serialized to JSON null. This should only be used on nullable fields.

func (Notification) MarshalJSON

func (n Notification) MarshalJSON() ([]byte, error)

func (*Notification) UnmarshalJSON

func (n *Notification) UnmarshalJSON(b []byte) error

type NumberChoice

type NumberChoice struct {
	Name              string        `json:"name"`
	NameLocalizations StringLocales `json:"name_localizations,omitempty"`
	Value             float64       `json:"value"`
	// LocalizedName is only populated when this is received from Discord's API.
	LocalizedName string `json:"name_localized,omitempty"`
}

NumberChoice is a pair of string key to a float64 values.

type NumberOption

type NumberOption struct {
	OptionName               string         `json:"name"`
	OptionNameLocalizations  StringLocales  `json:"name_localizations,omitempty"`
	Description              string         `json:"description"`
	DescriptionLocalizations StringLocales  `json:"description_localizations,omitempty"`
	Required                 bool           `json:"required"`
	Min                      option.Float   `json:"min_value,omitempty"`
	Max                      option.Float   `json:"max_value,omitempty"`
	Choices                  []NumberChoice `json:"choices,omitempty"`
	// Autocomplete must not be true if Choices are present.
	Autocomplete bool `json:"autocomplete"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

NumberOption is a subcommand option that fits into a CommandOptionValue.

func NewNumberOption

func NewNumberOption(name, description string, required bool) *NumberOption

NewNumberOption creates a new number option.

func (*NumberOption) MarshalJSON

func (n *NumberOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals NumberOption to JSON with the "type" field.

func (*NumberOption) Name

func (n *NumberOption) Name() string

Name implements CommandOption.

func (*NumberOption) Type

func (n *NumberOption) Type() CommandOptionType

Type implements CommandOptionValue.

type OptionalSeconds

type OptionalSeconds = *Seconds

OptionalSeconds is the option type for Seconds.

func NewOptionalSeconds

func NewOptionalSeconds(s Seconds) OptionalSeconds

NewOptionalSeconds creates a new OptionalSeconds using the value of the passed Seconds.

type OverboundError

type OverboundError struct {
	Count int
	Max   int

	Thing string
}

OverboundError is an error that's returned if any value is too long.

func (*OverboundError) Error

func (e *OverboundError) Error() string

type Overwrite

type Overwrite struct {
	// ID is the role or user id.
	ID Snowflake `json:"id"`
	// Type indicates the entity overwritten: role or member.
	Type OverwriteType `json:"type"`
	// Allow is a permission bit set for granted permissions.
	Allow Permissions `json:"allow,string"`
	// Deny is a permission bit set for denied permissions.
	Deny Permissions `json:"deny,string"`
}

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

type OverwriteType

type OverwriteType uint8

OverwriteType is an enumerated type to indicate the entity being overwritten: role or member

const (
	// OverwriteRole is an overwrite for a role.
	OverwriteRole OverwriteType = iota
	// OverwriteMember is an overwrite for a member.
	OverwriteMember
)

func (*OverwriteType) UnmarshalJSON

func (otype *OverwriteType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshalls both a string-quoted number and a regular number into OverwriteType. We need to do this because Discord is so bad that they can't even handle 1s and 0s properly.

type Permissions

type Permissions uint64
const (
	// Allows creation of instant invites
	PermissionCreateInstantInvite Permissions = 1 << iota
	// Allows kicking members
	PermissionKickMembers
	// Allows banning members
	PermissionBanMembers
	// Allows all permissions and bypasses channel permission overwrites
	PermissionAdministrator
	// Allows management and editing of channels
	PermissionManageChannels
	// Allows management and editing of the guild
	PermissionManageGuild
	// Allows for the addition of reactions to messages
	PermissionAddReactions
	// Allows for viewing of audit logs
	PermissionViewAuditLog
	// Allows for using priority speaker in a voice channel
	PermissionPrioritySpeaker
	// Allows the user to go live
	PermissionStream
	// Allows guild members to view a channel, which includes reading messages
	// in text channels
	PermissionViewChannel
	// Allows for sending messages in a channel
	PermissionSendMessages
	// Allows for sending of /tts messages
	PermissionSendTTSMessages
	// Allows for deletion of other users messages
	PermissionManageMessages
	// Links sent by users with this permission will be auto-embedded
	PermissionEmbedLinks
	// Allows for uploading images and files
	PermissionAttachFiles
	// Allows for reading of message history
	PermissionReadMessageHistory
	// 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
	PermissionMentionEveryone
	// Allows the usage of custom emojis from other servers
	PermissionUseExternalEmojis
	// Allows for viewing guild insights
	PermissionViewGuildInsights
	// Allows for joining of a voice channel
	PermissionConnect
	// Allows for speaking in a voice channel
	PermissionSpeak
	// Allows for muting members in a voice channel
	PermissionMuteMembers
	// Allows for deafening of members in a voice channel
	PermissionDeafenMembers
	// Allows for moving of members between voice channels
	PermissionMoveMembers
	// Allows for using voice-activity-detection in a voice channel
	PermissionUseVAD
	// Allows for modification of own nickname
	PermissionChangeNickname
	// Allows for modification of other users nicknames
	PermissionManageNicknames
	// Allows management and editing of roles
	PermissionManageRoles
	// Allows management and editing of webhooks
	PermissionManageWebhooks
	// Allows members to use slash commands in text channels
	PermissionManageEmojisAndStickers
	// Allows members to use slash commands in text channels
	PermissionUseSlashCommands
	// Allows for requesting to speak in stage channels. (This permission is
	// under active development and may be changed or removed.)
	PermissionRequestToSpeak
	// Allows for creating, editing, and deleting scheduled events.
	PermissionManageEvents
	// Allows for deleting and archiving threads, and viewing all private
	// threads
	PermissionManageThreads
	// Allows for creating and participating in threads.
	PermissionCreatePublicThreads
	// Allows for creating and participating in private threads.
	PermissionCreatePrivateThreads
	// Allows the usage of custom stickers from other servers
	PermissionUseExternalStickers
	// Allows for sending messages in threads
	PermissionSendMessagesInThreads
	// Allows for launching activities (applications with the EMBEDDED flag)
	// in a voice channel
	PermissionStartEmbeddedActivities
	// Allows for timing out users
	PermissionModerateMembers
	// Allows for viewing role subscription insights
	PermissionViewCreatorMonetizationAnalytics
	// Allows for using soundboard in a voice channel
	PermissionUseSoundboard

	// Allows the usage of custom soundboard sounds from other servers
	PermissionUseExternalSounds
	// Allows sending voice messages
	PermissionSendVoiceMessages

	PermissionAllText = 0 |
		PermissionViewChannel |
		PermissionSendMessages |
		PermissionSendTTSMessages |
		PermissionManageMessages |
		PermissionEmbedLinks |
		PermissionAttachFiles |
		PermissionReadMessageHistory |
		PermissionMentionEveryone |
		PermissionUseExternalEmojis |
		PermissionUseSlashCommands |
		PermissionManageThreads |
		PermissionCreatePublicThreads |
		PermissionCreatePrivateThreads |
		PermissionUseExternalStickers |
		PermissionAddReactions |
		PermissionSendMessagesInThreads

	PermissionAllVoice = 0 |
		PermissionViewChannel |
		PermissionConnect |
		PermissionSpeak |
		PermissionStream |
		PermissionMuteMembers |
		PermissionDeafenMembers |
		PermissionMoveMembers |
		PermissionUseVAD |
		PermissionPrioritySpeaker |
		PermissionRequestToSpeak |
		PermissionStartEmbeddedActivities

	PermissionAllChannel = 0 |
		PermissionAllText |
		PermissionAllVoice |
		PermissionCreateInstantInvite |
		PermissionManageRoles |
		PermissionManageChannels

	PermissionAll = 0 |
		PermissionAllChannel |
		PermissionKickMembers |
		PermissionBanMembers |
		PermissionManageGuild |
		PermissionAdministrator |
		PermissionManageWebhooks |
		PermissionManageEmojisAndStickers |
		PermissionManageNicknames |
		PermissionChangeNickname |
		PermissionViewAuditLog |
		PermissionManageEvents
)

https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags

func CalcOverrides added in v3.3.4

func CalcOverrides(
	guild Guild, channel Channel, member Member, roles []Role) Permissions

CalcOverrides calculates the permissions for a member in the given channel. Most of the time, you should use state.State.Permissions instead.

func NewPermissions

func NewPermissions(p ...Permissions) *Permissions

func (Permissions) Add

func (p Permissions) Add(perm Permissions) Permissions

func (Permissions) Has

func (p Permissions) Has(perm Permissions) bool

type PingInteraction

type PingInteraction struct{}

PingInteraction is a ping Interaction response.

func (*PingInteraction) InteractionType

func (*PingInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

type Presence

type Presence struct {
	// User is the user presence is being updated for. Only the ID field is
	// guaranteed to be valid per Discord documentation.
	User User `json:"user"`
	// GuildID is the id of the guild
	GuildID GuildID `json:"guild_id"`
	// Status is either "idle", "dnd", "online", or "offline".
	Status Status `json:"status"`
	// Activities are the user's current activities.
	Activities []Activity `json:"activities"`
	// ClientStatus is the user's platform-dependent status.
	ClientStatus ClientStatus `json:"client_status"`
}

Presence represents a partial Presence structure used by other structs to be easily embedded. It does not contain any ID to identify who it belongs to. For more information, refer to the PresenceUpdateEvent struct.

type PrivacyLevel

type PrivacyLevel int
const (
	// PublicStage is used if a StageInstance instance is visible publicly, such as on
	// StageInstance discovery.
	PublicStage PrivacyLevel = iota + 1
	// GuildOnlyStage is used if a StageInstance instance is visible to only guild
	// members.
	GuildOnlyStage
)

https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level

type Reaction

type Reaction struct {
	// Count is the amount of times the emoji has been used to react.
	Count int `json:"count"`
	// CountDetails contains burst (super) and normal reactions count.
	CountDetails ReactionCountDetails `json:"count_details"`
	// Me specifies whether the current user reacted using this emoji.
	Me bool `json:"me"`
	// Emoji contains emoji information.
	Emoji Emoji `json:"emoji"`
}

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

type ReactionCountDetails added in v3.3.4

type ReactionCountDetails struct {
	// Burst is the count of super reactions.
	Burst int `json:"burst"`
	// Normal is the count of normal reactions.
	Normal int `json:"normal"`
}

https://discord.com/developers/docs/resources/channel#reaction-count-details-object

type Relationship

type Relationship struct {
	UserID UserID           `json:"id"`
	User   User             `json:"user"`
	Type   RelationshipType `json:"type"`
}

A Relationship between the logged in user and the user in the struct. This struct is undocumented.

type RelationshipType

type RelationshipType uint8

RelationshipType is an enum for a relationship.

const (
	FriendRelationship RelationshipType
	BlockedRelationship
	IncomingFriendRequest
	SentFriendRequest
)

type Role

type Role struct {
	// ID is the role id.
	ID RoleID `json:"id"`
	// Name is the role name.
	Name string `json:"name"`

	// Permissions is the permission bit set.
	Permissions Permissions `json:"permissions,string"`

	// Position is the position of this role.
	Position int `json:"position"`
	// Color is the integer representation of hexadecimal color code.
	Color Color `json:"color"`

	// Hoist specifies if this role is pinned in the user listing.
	Hoist bool `json:"hoist"`
	// Manages specifies whether this role is managed by an integration.
	Managed bool `json:"managed"`
	// Mentionable specifies whether this role is mentionable.
	Mentionable bool `json:"mentionable"`

	// Icon is the icon hash of this role.
	Icon Hash `json:"icon,omitempty"`
	// UnicodeEmoji is the unicode emoji of this role.
	UnicodeEmoji string `json:"unicode_emoji,omitempty"`
	// Tags are the RoleTags of this role.
	Tags RoleTags `json:"tags,omitempty"`
}

https://discord.com/developers/docs/topics/permissions#role-object

func (Role) CreatedAt

func (r Role) CreatedAt() time.Time

CreatedAt returns a time object representing when the role was created.

func (Role) IconURL

func (r Role) IconURL() string

IconURL returns the URL to the role icon png. An empty string is returned if there's no icon.

func (Role) IconURLWithType

func (r Role) IconURLWithType(t ImageType) string

IconURLWithType returns the URL to the role icon using the passed ImageType. An empty string is returned if there's no icon.

Supported ImageTypes: PNG, JPEG, WebP

func (Role) Mention

func (r Role) Mention() string

Mention returns the mention of the Role.

type RoleID

type RoleID Snowflake

RoleID is the snowflake type for a RoleID.

func (RoleID) Increment

func (s RoleID) Increment() uint16

func (RoleID) IsNull

func (s RoleID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (RoleID) IsValid

func (s RoleID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (RoleID) MarshalJSON

func (s RoleID) MarshalJSON() ([]byte, error)

func (RoleID) Mention

func (s RoleID) Mention() string

Mention generates the mention syntax for this role ID.

func (RoleID) PID

func (s RoleID) PID() uint8

func (RoleID) String

func (s RoleID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (RoleID) Time

func (s RoleID) Time() time.Time

func (*RoleID) UnmarshalJSON

func (s *RoleID) UnmarshalJSON(v []byte) error

func (RoleID) Worker

func (s RoleID) Worker() uint8

type RoleOption

type RoleOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

RoleOption is a subcommand option that fits into a CommandOptionValue.

func NewRoleOption

func NewRoleOption(name, description string, required bool) *RoleOption

NewRoleOption creates a new role option.

func (*RoleOption) MarshalJSON

func (r *RoleOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals RoleOption to JSON with the "type" field.

func (*RoleOption) Name

func (r *RoleOption) Name() string

Name implements CommandOption.

func (*RoleOption) Type

func (r *RoleOption) Type() CommandOptionType

Type implements CommandOptionValue.

type RoleSelectComponent added in v3.2.0

type RoleSelectComponent struct {
	// CustomID is the custom unique ID.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Placeholder is the custom placeholder text if nothing is selected. Max
	// 100 characters.
	Placeholder string `json:"placeholder,omitempty"`
	// ValueLimits is the minimum and maximum number of items that can be
	// chosen. The default is [1, 1] if ValueLimits is a zero-value.
	ValueLimits [2]int `json:"-"`
	// Disabled disables the select if true.
	Disabled bool `json:"disabled,omitempty"`
}

func (*RoleSelectComponent) ID added in v3.2.0

ID implements the Component interface.

func (*RoleSelectComponent) MarshalJSON added in v3.2.0

func (s *RoleSelectComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the select in the format Discord expects.

func (*RoleSelectComponent) Type added in v3.2.0

Type implements the Component interface.

type RoleSelectInteraction added in v3.3.0

type RoleSelectInteraction struct {
	CustomID ComponentID `json:"custom_id"`
	Values   []RoleID    `json:"values"`
}

RoleSelectInteraction is a role select component's response.

func (*RoleSelectInteraction) ID added in v3.3.0

ID implements ComponentInteraction.

func (*RoleSelectInteraction) InteractionType added in v3.3.0

func (s *RoleSelectInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*RoleSelectInteraction) Type added in v3.3.0

Type implements ComponentInteraction.

type RoleTags

type RoleTags struct {
	// BotID is the id of the bot this role belongs to.
	BotID UserID `json:"bot_id,omitempty"`
	// IntegrationID is the id of the integration this role belongs to.
	IntegrationID IntegrationID `json:"integration_id,omitempty"`
	// PremiumSubscriber specifies whether this is the guild's premium subscriber role.
	PremiumSubscriber bool `json:"premium_subscriber,omitempty"`
}

type ScheduledEventPrivacyLevel

type ScheduledEventPrivacyLevel int

ScheduledEventPrivacy describes the privacy levels of GuildScheduledEvent.

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

const (
	// GuildOnly requires the scheduled event to be only accessible to guild members.
	GuildOnly ScheduledEventPrivacyLevel = iota + 2
)

type Seconds

type Seconds int

func DurationToSeconds

func DurationToSeconds(dura time.Duration) Seconds

func (Seconds) Duration

func (s Seconds) Duration() time.Duration

func (Seconds) MarshalJSON

func (s Seconds) MarshalJSON() ([]byte, error)

func (Seconds) String

func (s Seconds) String() string

func (*Seconds) UnmarshalJSON

func (s *Seconds) UnmarshalJSON(data []byte) error

type SelectInteraction deprecated

type SelectInteraction = StringSelectInteraction

SelectInteraction is a select component's response.

Deprecated: Use StringSelectInteraction instead.

type SelectOption

type SelectOption struct {
	// Label is the user-facing name of the option. Max 100 characters.
	Label string `json:"label"`
	// Value is the internal value that is echoed back to the program. It's
	// similar to the custom ID. Max 100 characters.
	Value string `json:"value"`
	// Description is the additional description of an option. Max 100 characters.
	Description string `json:"description,omitempty"`
	// Emoji is the optional emoji object.
	Emoji *ComponentEmoji `json:"emoji,omitempty"`
	// Default will render this option as selected by default if true.
	Default bool `json:"default,omitempty"`
}

SelectOption is an option in the select component.

type Service

type Service string

Service is used for guild integrations and user connections.

const (
	TwitchService  Service = "twitch"
	YouTubeService Service = "youtube"
	DiscordService Service = "discord"
)

type Snowflake

type Snowflake uint64

Snowflake is the format of Discord's ID type. It is a format that can be sorted chronologically.

func NewSnowflake

func NewSnowflake(t time.Time) Snowflake

NewSnowflake creates a new snowflake from the given time.

func ParseSnowflake

func ParseSnowflake(sf string) (Snowflake, error)

ParseSnowflake parses a snowflake.

func (Snowflake) Increment

func (s Snowflake) Increment() uint16

func (Snowflake) IsNull

func (s Snowflake) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (Snowflake) IsValid

func (s Snowflake) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (Snowflake) MarshalJSON

func (s Snowflake) MarshalJSON() ([]byte, error)

func (Snowflake) PID

func (s Snowflake) PID() uint8

func (Snowflake) String

func (s Snowflake) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (Snowflake) Time

func (s Snowflake) Time() time.Time

func (*Snowflake) UnmarshalJSON

func (s *Snowflake) UnmarshalJSON(v []byte) error

func (Snowflake) Worker

func (s Snowflake) Worker() uint8

type SortOrderType added in v3.3.0

type SortOrderType uint8

https://discord.com/developers/docs/resources/channel#channel-object-sort-order-types

const (
	// Sort forum posts by activity.
	SortOrderTypeLatestActivity SortOrderType = iota
	// Sort forum posts by creation time (from most recent to oldest)
	SoftOrderTypeCreationDate
)

type StageID

type StageID Snowflake

StageID is the snowflake type for a StageID.

func (StageID) Increment

func (s StageID) Increment() uint16

func (StageID) IsNull

func (s StageID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (StageID) IsValid

func (s StageID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (StageID) MarshalJSON

func (s StageID) MarshalJSON() ([]byte, error)

func (StageID) PID

func (s StageID) PID() uint8

func (StageID) String

func (s StageID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (StageID) Time

func (s StageID) Time() time.Time

func (*StageID) UnmarshalJSON

func (s *StageID) UnmarshalJSON(v []byte) error

func (StageID) Worker

func (s StageID) Worker() uint8

type StageInstance

type StageInstance struct {
	// ID is the id of this Stage instance.
	ID StageID `json:"id"`
	// GuildID is the guild id of the associated Stage channel.
	GuildID GuildID `json:"guild_id"`
	// ChannelID is the id of the associated Stage channel.
	ChannelID ChannelID `json:"channel_id"`
	// Topic is the topic of the Stage instance (1-120 characters).
	Topic string `json:"topic"`
	// PrivacyLevel is the privacy level of the Stage instance.
	PrivacyLevel PrivacyLevel `json:"privacy_level"`
	// NotDiscoverable defines whether or not Stage discovery is disabled.
	NotDiscoverable bool `json:"discoverable_disabled"`
}

A StageInstance holds information about a live stage instance.

https://discord.com/developers/docs/resources/stage-instance#stage-instance-object

type Status

type Status string

Status is the enumerate type for a user's status.

const (
	UnknownStatus      Status = ""
	OnlineStatus       Status = "online"
	DoNotDisturbStatus Status = "dnd"
	IdleStatus         Status = "idle"
	InvisibleStatus    Status = "invisible"
	OfflineStatus      Status = "offline"
)

type Sticker

type Sticker struct {
	// ID is the ID of the sticker.
	ID StickerID `json:"id"`
	// PackID is the ID of the pack the sticker is from.
	PackID StickerPackID `json:"pack_id,omitempty"`
	// Name is the name of the sticker.
	Name string `json:"name"`
	// Description is the description of the sticker.
	Description string `json:"description"`
	// Tags is a comma-delimited list of tags for the sticker. To get the list
	// as a slice, use TagList.
	Tags string `json:"tags"`
	// Type is the type of sticker.
	Type StickerType `json:"type"`
	// FormatType is the type of sticker format.
	FormatType StickerFormatType `json:"format_type"`
	// Available specifies whether this guild sticker can be used, may be false due to loss of Server Boosts.
	Available bool `json:"available,omitempty"`
	// GuildID is the id of the guild that owns this sticker.
	GuildID GuildID `json:"guild_id,omitempty"`
	// User is the user that uploaded the guild sticker
	User *User `json:"user,omitempty"`
	// SortValue is the standard sticker's sort order within its pack.
	SortValue *int `json:"sort_value,omitempty"`
}

https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure

func (Sticker) CreatedAt

func (s Sticker) CreatedAt() time.Time

CreatedAt returns a time object representing when the sticker was created.

func (Sticker) PackCreatedAt

func (s Sticker) PackCreatedAt() time.Time

PackCreatedAt returns a time object representing when the sticker's pack was created.

func (Sticker) StickerURLWithType

func (s Sticker) StickerURLWithType(t ImageType) string

StickerURLWithType returns the URL to the emoji's image.

Supported ImageTypes: PNG

func (Sticker) TagList

func (s Sticker) TagList() []string

TagList splits the sticker tags into a slice of strings. Each tag will have its trailing space trimmed.

type StickerFormatType

type StickerFormatType uint8

type StickerID

type StickerID Snowflake

StickerID is the snowflake type for a StickerID.

func (StickerID) Increment

func (s StickerID) Increment() uint16

func (StickerID) IsNull

func (s StickerID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (StickerID) IsValid

func (s StickerID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (StickerID) MarshalJSON

func (s StickerID) MarshalJSON() ([]byte, error)

func (StickerID) PID

func (s StickerID) PID() uint8

func (StickerID) String

func (s StickerID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (StickerID) Time

func (s StickerID) Time() time.Time

func (*StickerID) UnmarshalJSON

func (s *StickerID) UnmarshalJSON(v []byte) error

func (StickerID) Worker

func (s StickerID) Worker() uint8

type StickerItem

type StickerItem struct {
	// ID is the ID of the sticker.
	ID StickerID `json:"id"`
	// Name is the name of the sticker.
	Name string `json:"name"`
	// FormatType is the type of sticker format.
	FormatType StickerFormatType `json:"format_type"`
}

StickerItem contains partial data of a Sticker.

https://discord.com/developers/docs/resources/sticker#sticker-item-object

func (StickerItem) StickerURLWithType

func (s StickerItem) StickerURLWithType(t ImageType) string

StickerURLWithType returns the URL to the emoji's image.

Supported ImageTypes: PNG

type StickerPackID

type StickerPackID Snowflake

StickerPackID is the snowflake type for a StickerPackID.

func (StickerPackID) Increment

func (s StickerPackID) Increment() uint16

func (StickerPackID) IsNull

func (s StickerPackID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (StickerPackID) IsValid

func (s StickerPackID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (StickerPackID) MarshalJSON

func (s StickerPackID) MarshalJSON() ([]byte, error)

func (StickerPackID) PID

func (s StickerPackID) PID() uint8

func (StickerPackID) String

func (s StickerPackID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (StickerPackID) Time

func (s StickerPackID) Time() time.Time

func (*StickerPackID) UnmarshalJSON

func (s *StickerPackID) UnmarshalJSON(v []byte) error

func (StickerPackID) Worker

func (s StickerPackID) Worker() uint8

type StickerType

type StickerType int
const (
	// StandardSticker is an official sticker in a pack, part of Nitro or in a removed purchasable pack.
	StandardSticker StickerType = iota + 1
	// GuildSticker is a sticker uploaded to a boosted guild for the guild's members.
	GuildSticker
)

https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types

type StringChoice

type StringChoice struct {
	Name              string        `json:"name"`
	NameLocalizations StringLocales `json:"name_localizations,omitempty"`
	Value             string        `json:"value"`
	// LocalizedName is only populated when this is received from Discord's API.
	LocalizedName string `json:"name_localized,omitempty"`
}

StringChoice is a pair of string key to a string.

type StringLocales

type StringLocales map[Language]string

StringLocales is the map mapping a language code to a localized string.

type StringOption

type StringOption struct {
	OptionName               string         `json:"name"`
	OptionNameLocalizations  StringLocales  `json:"name_localizations,omitempty"`
	Description              string         `json:"description"`
	DescriptionLocalizations StringLocales  `json:"description_localizations,omitempty"`
	Required                 bool           `json:"required"`
	Choices                  []StringChoice `json:"choices,omitempty"`
	MinLength                option.Int     `json:"min_length,omitempty"`
	MaxLength                option.Int     `json:"max_length,omitempty"`
	// Autocomplete must not be true if Choices are present.
	Autocomplete bool `json:"autocomplete"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

StringOption is a subcommand option that fits into a CommandOptionValue.

func NewStringOption

func NewStringOption(name, description string, required bool) *StringOption

NewStringOption creates a new string option.

func (*StringOption) MarshalJSON

func (s *StringOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals StringOption to JSON with the "type" field.

func (*StringOption) Name

func (s *StringOption) Name() string

Name implements CommandOption.

func (*StringOption) Type

func (s *StringOption) Type() CommandOptionType

Type implements CommandOptionValue.

type StringSelectComponent added in v3.2.0

type StringSelectComponent struct {
	// Options are the choices in the select.
	Options []SelectOption `json:"options"`
	// CustomID is the custom unique ID.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Placeholder is the custom placeholder text if nothing is selected. Max
	// 100 characters.
	Placeholder string `json:"placeholder,omitempty"`
	// ValueLimits is the minimum and maximum number of items that can be
	// chosen. The default is [1, 1] if ValueLimits is a zero-value.
	ValueLimits [2]int `json:"-"`
	// Disabled disables the select if true.
	Disabled bool `json:"disabled,omitempty"`
}

StringSelectComponent is a dropdown menu that may be added to an interaction response.

func (*StringSelectComponent) ID added in v3.2.0

ID implements the Component interface.

func (*StringSelectComponent) MarshalJSON added in v3.2.0

func (s *StringSelectComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the select in the format Discord expects.

func (*StringSelectComponent) Type added in v3.2.0

Type implements the Component interface.

type StringSelectInteraction added in v3.3.0

type StringSelectInteraction struct {
	CustomID ComponentID `json:"custom_id"`
	Values   []string    `json:"values"`
}

StringSelectInteraction is a string select component's response.

func (*StringSelectInteraction) ID added in v3.3.0

ID implements ComponentInteraction.

func (*StringSelectInteraction) InteractionType added in v3.3.0

func (s *StringSelectInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*StringSelectInteraction) Type added in v3.3.0

Type implements ComponentInteraction.

type SubcommandGroupOption

type SubcommandGroupOption struct {
	OptionName               string              `json:"name"`
	OptionNameLocalizations  StringLocales       `json:"name_localizations,omitempty"`
	Description              string              `json:"description"`
	DescriptionLocalizations StringLocales       `json:"description_localizations,omitempty"`
	Required                 bool                `json:"required"`
	Subcommands              []*SubcommandOption `json:"options"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

SubcommandGroupOption is a subcommand group that fits into a CommandOption.

func NewSubcommandGroupOption

func NewSubcommandGroupOption(name, description string, subs ...*SubcommandOption) *SubcommandGroupOption

NewSubcommandGroupOption creates a new subcommand group option.

func (*SubcommandGroupOption) MarshalJSON

func (s *SubcommandGroupOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals SubcommandGroupOption to JSON with the "type" field.

func (*SubcommandGroupOption) Name

func (s *SubcommandGroupOption) Name() string

Name implements CommandOption.

func (*SubcommandGroupOption) Type

Type implements CommandOption.

type SubcommandOption

type SubcommandOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// Options contains command option values. All CommandOption types except
	// for SubcommandOption and SubcommandGroupOption will implement this
	// interface.
	Options []CommandOptionValue `json:"options"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

SubcommandOption is a subcommand option that fits into a CommandOption.

func NewSubcommandOption

func NewSubcommandOption(name, description string, options ...CommandOptionValue) *SubcommandOption

NewSubcommandOption creates a new subcommand option.

func (*SubcommandOption) MarshalJSON

func (s *SubcommandOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals SubcommandOption to JSON with the "type" field.

func (*SubcommandOption) Name

func (s *SubcommandOption) Name() string

Name implements CommandOption.

func (*SubcommandOption) Type

Type implements CommandOption.

func (*SubcommandOption) UnmarshalJSON

func (s *SubcommandOption) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the given JSON bytes. It actually does type-checking.

type SystemChannelFlags

type SystemChannelFlags uint8
const (
	// SuppressJoinNotifications suppresses member join notifications.
	SuppressJoinNotifications SystemChannelFlags = 1 << iota
	// SuppressPremiumSubscriptions suppresses server boost notifications.
	SuppressPremiumSubscriptions
)

https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags

type Tag added in v3.2.0

type Tag struct {
	ID        TagID  `json:"id,omitempty"`
	Name      string `json:"name"`
	Moderated bool   `json:"moderated"`
	ForumReaction
}

Tag represents a tag that is able to be applied to a thread in a GuildForum channel.

type TagID added in v3.2.0

type TagID Snowflake

TagID is the snowflake type for a TagID.

func (TagID) Increment added in v3.2.0

func (s TagID) Increment() uint16

func (TagID) IsNull added in v3.2.0

func (s TagID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (TagID) IsValid added in v3.2.0

func (s TagID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (TagID) MarshalJSON added in v3.2.0

func (s TagID) MarshalJSON() ([]byte, error)

func (TagID) PID added in v3.2.0

func (s TagID) PID() uint8

func (TagID) String added in v3.2.0

func (s TagID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (TagID) Time added in v3.2.0

func (s TagID) Time() time.Time

func (*TagID) UnmarshalJSON added in v3.2.0

func (s *TagID) UnmarshalJSON(v []byte) error

func (TagID) Worker added in v3.2.0

func (s TagID) Worker() uint8

type Team

type Team struct {
	// Icon is a hash of the image of the team's icon.
	Icon *Hash `json:"hash"`
	// ID is the unique ID of the team.
	ID TeamID `json:"id"`
	// Members is the members of the team.
	Members []TeamMember `json:"members"`
	// Name is the name of the team.
	Name string `json:"name"`
	// OwnerUserID is the user ID of the current team owner.
	OwnerID UserID `json:"owner_user_id"`
}

type TeamID

type TeamID Snowflake

TeamID is the snowflake type for a TeamID.

func (TeamID) Increment

func (s TeamID) Increment() uint16

func (TeamID) IsNull

func (s TeamID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (TeamID) IsValid

func (s TeamID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (TeamID) MarshalJSON

func (s TeamID) MarshalJSON() ([]byte, error)

func (TeamID) PID

func (s TeamID) PID() uint8

func (TeamID) String

func (s TeamID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (TeamID) Time

func (s TeamID) Time() time.Time

func (*TeamID) UnmarshalJSON

func (s *TeamID) UnmarshalJSON(v []byte) error

func (TeamID) Worker

func (s TeamID) Worker() uint8

type TeamMember

type TeamMember struct {
	// MembershipState is the user's membership state on the team.
	MembershipState MembershipState `json:"membership_state"`
	// Permissions will always be {"*"}
	Permissions []string `json:"permissions"`
	// TeamID is the ID of the parent team of which they are a member.
	TeamID TeamID `json:"team_id"`
	// User is the avatar, discriminator, ID, and username of the user.
	User User `json:"user"`
}

type TextInputComponent

type TextInputComponent struct {
	// CustomID provides a developer-defined ID for the input (max 100 chars)
	CustomID ComponentID `json:"custom_id"`
	// Style determines if the component should use the short or paragraph style
	Style TextInputStyle `json:"style"`
	// Label is the title of this component, describing its use
	Label string `json:"label"`
	// LengthLimits is the minimum and maximum length for the input
	LengthLimits [2]int `json:"-"`
	// Required dictates whether or not the user must fill out the component
	Required bool `json:"required"`
	// Value is the pre-filled value of this component (max 4000 chars)
	Value string `json:"value,omitempty"`
	// Placeholder is the text that appears when the input is empty (max 100 chars)
	Placeholder string `json:"placeholder,omitempty"`
}

TextInputComponents provide a user-facing text box to be filled out. They can only be used with modals.

func (*TextInputComponent) ID

func (*TextInputComponent) MarshalJSON

func (i *TextInputComponent) MarshalJSON() ([]byte, error)

func (*TextInputComponent) Type

type TextInputStyle

type TextInputStyle uint8
const (
	TextInputShortStyle TextInputStyle
	TextInputParagraphStyle
)

type ThreadMember

type ThreadMember struct {
	// ID is the id of the thread.
	//
	// This field will be omitted on the member sent within each thread in the
	// guild create event.
	ID ChannelID `json:"id,omitempty"`
	// UserID is the id of the user.
	//
	// This field will be omitted on the member sent within each thread in the
	// guild create event.
	UserID UserID `json:"user_id,omitempty"`
	// Member is the member, only included in Thread Members Update Events.
	Member *Member `json:"member,omitempty"`
	// Presence is the presence, only included in Thread Members Update Events.
	Presence *Presence `json:"presence,omitempty"`
	// JoinTimestamp is the time the current user last joined the thread.
	JoinTimestamp Timestamp `json:"join_timestamp"`
	// Flags are any user-thread settings.
	Flags ThreadMemberFlags `json:"flags"`
}

type ThreadMemberFlags

type ThreadMemberFlags uint64

ThreadMemberFlags are the flags of a ThreadMember. Currently, none are documented.

type ThreadMetadata

type ThreadMetadata struct {
	// Archived specifies whether the thread is archived.
	Archived bool `json:"archived"`
	// AutoArchiveDuration is the duration in minutes to automatically archive
	// the thread after recent activity.
	AutoArchiveDuration ArchiveDuration `json:"auto_archive_duration"`
	// ArchiveTimestamp timestamp when the thread's archive status was last
	// changed, used for calculating recent activity.
	ArchiveTimestamp Timestamp `json:"archive_timestamp"`
	// Locked specifies whether the thread is locked; when a thread is locked,
	// only users with MANAGE_THREADS can unarchive it.
	Locked bool `json:"locked"`
	// Invitable specifies whether non-moderators can add other
	// non-moderators to a thread; only available on private threads.
	Invitable bool `json:"invitable,omitempty"`
	// CreateTimestamp is the timestamp when the thread was created; only
	// populated for threads created after 2022-01-09.
	CreateTimestamp *Timestamp `json:"thread_metadata,omitempty"`
}

ThreadMetadata contains a number of thread-specific channel fields that are not needed by other channel types.

https://discord.com/developers/docs/resources/channel#thread-metadata-object

type Timestamp

type Timestamp time.Time

Timestamp has a valid zero-value, which can be checked using the IsValid() method. This is useful for optional timestamps such as EditedTimestamp.

func NewTimestamp

func NewTimestamp(t time.Time) Timestamp

func NowTimestamp

func NowTimestamp() Timestamp

func (Timestamp) Format

func (t Timestamp) Format(fmt string) string

func (Timestamp) IsValid

func (t Timestamp) IsValid() bool

func (Timestamp) MarshalJSON

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

MarshalJSON returns null if Timestamp is not valid (zero). It returns the time formatted in RFC3339 otherwise.

func (Timestamp) Time

func (t Timestamp) Time() time.Time

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(v []byte) error

UnmarshalJSON parses a nullable RFC3339 string into time.

type URL

type URL = string

type UnixMsTimestamp

type UnixMsTimestamp int64

func TimeToMilliseconds

func TimeToMilliseconds(t time.Time) UnixMsTimestamp

func (UnixMsTimestamp) String

func (t UnixMsTimestamp) String() string

func (UnixMsTimestamp) Time

func (t UnixMsTimestamp) Time() time.Time

type UnixTimestamp

type UnixTimestamp int64

func (UnixTimestamp) String

func (t UnixTimestamp) String() string

func (UnixTimestamp) Time

func (t UnixTimestamp) Time() time.Time

type UnknownCommandOption

type UnknownCommandOption struct {
	OptionName string            `json:"name"`
	OptionType CommandOptionType `json:"type"`
	// contains filtered or unexported fields
}

UnknownCommandOption is used for unknown or unmarshaled CommandOption values. It is used in the unmarshaling stage for all CommandOption types.

An UnknownCommandOption will satisfy both CommandOption and CommandOptionValue. Code that type-switches on either of them should not assume that only the expected types are used.

func (*UnknownCommandOption) Data

Data returns the underlying data type, which is a type that satisfies either CommandOption or CommandOptionValue.

func (*UnknownCommandOption) Name

func (u *UnknownCommandOption) Name() string

Name returns the supposeed name for this UnknownCommandOption.

func (*UnknownCommandOption) Raw

func (u *UnknownCommandOption) Raw() json.Raw

Raw returns the raw JSON of this UnknownCommandOption. It will only return a non-nil blob of JSON if the command option's type cannot be found. If this method doesn't return nil, then Data's type will be UnknownCommandOption.

func (*UnknownCommandOption) Type

Type returns the supposed type for this UnknownCommandOption.

func (*UnknownCommandOption) UnmarshalJSON

func (u *UnknownCommandOption) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the JSON into the struct as-is then reads all its children Options/Choices (if subcommand(group)). Typed command options are created into u.Data, or u.Raw if the type is unknown. This is done from the bottom up.

type UnknownComponent

type UnknownComponent struct {
	json.Raw
	// contains filtered or unexported fields
}

Unknown is reserved for components with unknown or not yet implemented components types. It can also be used in place of a ComponentInteraction.

func (*UnknownComponent) ID

func (u *UnknownComponent) ID() ComponentID

ID implements the Component and ComponentInteraction interfaces.

func (*UnknownComponent) InteractionType

func (u *UnknownComponent) InteractionType() InteractionDataType

Type implements InteractionData.

func (*UnknownComponent) Type

func (u *UnknownComponent) Type() ComponentType

Type implements the Component and ComponentInteraction interfaces.

type UnknownInteractionData

type UnknownInteractionData struct {
	json.Raw
	// contains filtered or unexported fields
}

UnknownInteractionData describes an Interaction response with an unknown type.

func (*UnknownInteractionData) InteractionType

func (u *UnknownInteractionData) InteractionType() InteractionDataType

InteractionType implements InteractionData.

type User

type User struct {
	ID            UserID `json:"id"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"` // This is "0" if the user has migrated to the new username system.
	Avatar        Hash   `json:"avatar"`
	DisplayName   string `json:"global_name"`

	Bot bool `json:"bot,omitempty"`
	MFA bool `json:"mfa_enabled,omitempty"`

	Nitro       UserNitro `json:"premium_type,omitempty"`
	Flags       UserFlags `json:"flags,omitempty"`
	PublicFlags UserFlags `json:"public_flags,omitempty"`

	DiscordSystem bool `json:"system,omitempty"`
	EmailVerified bool `json:"verified,omitempty"`

	Locale string `json:"locale,omitempty"`
	Email  string `json:"email,omitempty"`

	Banner Hash  `json:"banner,omitempty"`
	Accent Color `json:"accent_color,omitempty"`
}

func (User) AvatarURL

func (u User) AvatarURL() string

AvatarURL returns the URL of the Avatar Image. It automatically detects a suitable type.

func (User) AvatarURLWithType

func (u User) AvatarURLWithType(t ImageType) string

AvatarURLWithType returns the URL of the Avatar Image using the passed type. If the user has no Avatar, his default avatar will be returned. This requires ImageType Auto or PNG

Supported Image Types: PNG, JPEG, WebP, GIF (read above for caveat)

func (User) BannerURL

func (u User) BannerURL() string

BannerURL returns the URL of the Banner Image. It automatically detects a suitable type.

func (User) BannerURLWithType

func (u User) BannerURLWithType(t ImageType) string

BannerURLWithType returns the URL of the Banner Image using the passed type. If the user has no Banner, an empty string will be returned.

func (User) CreatedAt

func (u User) CreatedAt() time.Time

CreatedAt returns a time object representing when the user was created.

func (User) DisplayOrTag added in v3.3.1

func (u User) DisplayOrTag() string

DisplayOrTag returns the DisplayName if it is set, otherwise the Tag.

func (User) DisplayOrUsername added in v3.3.1

func (u User) DisplayOrUsername() string

DisplayOrUsername returns the DisplayName if it is set, otherwise the Username.

func (User) Mention

func (u User) Mention() string

Mention returns a mention of the user.

func (User) Tag

func (u User) Tag() string

Tag returns a tag of the user.

type UserFlags

type UserFlags uint32
const (
	Employee UserFlags = 1 << iota
	Partner
	HypeSquadEvents
	BugHunterLvl1

	HouseBravery
	HouseBrilliance
	HouseBalance
	EarlySupporter
	TeamUser

	System

	BugHunterLvl2

	VerifiedBot
	VerifiedBotDeveloper
	CertifiedModerator
	LikelySpammer // undocumented
)
const NoFlag UserFlags = 0

type UserID

type UserID Snowflake

UserID is the snowflake type for a UserID.

func (UserID) Increment

func (s UserID) Increment() uint16

func (UserID) IsNull

func (s UserID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (UserID) IsValid

func (s UserID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (UserID) MarshalJSON

func (s UserID) MarshalJSON() ([]byte, error)

func (UserID) Mention

func (s UserID) Mention() string

Mention generates the mention syntax for this user ID.

func (UserID) PID

func (s UserID) PID() uint8

func (UserID) String

func (s UserID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (UserID) Time

func (s UserID) Time() time.Time

func (*UserID) UnmarshalJSON

func (s *UserID) UnmarshalJSON(v []byte) error

func (UserID) Worker

func (s UserID) Worker() uint8

type UserNitro

type UserNitro uint8
const (
	NoUserNitro UserNitro = iota
	NitroClassic
	NitroFull
	NitroBasic
)

type UserOption

type UserOption struct {
	OptionName               string        `json:"name"`
	OptionNameLocalizations  StringLocales `json:"name_localizations,omitempty"`
	Description              string        `json:"description"`
	DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
	Required                 bool          `json:"required"`
	// LocalizedOptionName is only populated when this is received from
	// Discord's API.
	LocalizedOptionName string `json:"name_localized,omitempty"`
	// LocalizedDescription is only populated when this is received from
	// Discord's API.
	LocalizedDescription string `json:"description_localized,omitempty"`
}

UserOption is a subcommand option that fits into a CommandOptionValue.

func NewUserOption

func NewUserOption(name, description string, required bool) *UserOption

NewUserOption creates a new user option.

func (*UserOption) MarshalJSON

func (u *UserOption) MarshalJSON() ([]byte, error)

MarshalJSON marshals UserOption to JSON with the "type" field.

func (*UserOption) Name

func (u *UserOption) Name() string

Name implements CommandOption.

func (*UserOption) Type

func (u *UserOption) Type() CommandOptionType

Type implements CommandOptionValue.

type UserSelectComponent added in v3.2.0

type UserSelectComponent struct {
	// CustomID is the custom unique ID.
	CustomID ComponentID `json:"custom_id,omitempty"`
	// Placeholder is the custom placeholder text if nothing is selected. Max
	// 100 characters.
	Placeholder string `json:"placeholder,omitempty"`
	// ValueLimits is the minimum and maximum number of items that can be
	// chosen. The default is [1, 1] if ValueLimits is a zero-value.
	ValueLimits [2]int `json:"-"`
	// Disabled disables the select if true.
	Disabled bool `json:"disabled,omitempty"`
}

func (*UserSelectComponent) ID added in v3.2.0

ID implements the Component interface.

func (*UserSelectComponent) MarshalJSON added in v3.2.0

func (s *UserSelectComponent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the select in the format Discord expects.

func (*UserSelectComponent) Type added in v3.2.0

Type implements the Component interface.

type UserSelectInteraction added in v3.3.0

type UserSelectInteraction struct {
	CustomID ComponentID `json:"custom_id"`
	Values   []UserID    `json:"values"`
}

UserSelectInteraction is a user select component's response.

func (*UserSelectInteraction) ID added in v3.3.0

ID implements ComponentInteraction.

func (*UserSelectInteraction) InteractionType added in v3.3.0

func (s *UserSelectInteraction) InteractionType() InteractionDataType

InteractionType implements InteractionData.

func (*UserSelectInteraction) Type added in v3.3.0

Type implements ComponentInteraction.

type Verification

type Verification enum.Enum

Verification is the verification level required for a guild.

const (
	// NoVerification required no verification.
	NoVerification Verification = iota
	// LowVerification requires a verified email
	LowVerification
	// MediumVerification requires the user be registered for at least 5
	// minutes.
	MediumVerification
	// HighVerification requires the member be in the server for more than 10
	// minutes.
	HighVerification
	// VeryHighVerification requires the member to have a verified phone
	// number.
	VeryHighVerification
)

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

const NullVerification Verification = enum.Null

NullVerification serialized to JSON null. This should only be used on nullable fields.

func (Verification) MarshalJSON

func (v Verification) MarshalJSON() ([]byte, error)

func (*Verification) UnmarshalJSON

func (v *Verification) UnmarshalJSON(b []byte) error

type VoiceRegion

type VoiceRegion struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	VIP        bool   `json:"vip"`
	Optimal    bool   `json:"optimal"`
	Deprecated bool   `json:"deprecated"`
	Custom     bool   `json:"custom"` // used for events
}

type VoiceState

type VoiceState struct {
	// GuildID isn't available from the Guild struct.
	GuildID GuildID `json:"guild_id"`

	ChannelID ChannelID `json:"channel_id"`
	UserID    UserID    `json:"user_id"`
	Member    *Member   `json:"member,omitempty"`
	SessionID string    `json:"session_id"`

	Deaf bool `json:"deaf"`
	Mute bool `json:"mute"`

	SelfDeaf   bool `json:"self_deaf"`
	SelfMute   bool `json:"self_mute"`
	SelfStream bool `json:"self_stream,omitempty"`
	SelfVideo  bool `json:"self_video,omitempty"`
	Suppress   bool `json:"suppress"`

	RequestToSpeakTimestamp *Timestamp `json:"request_to_speak_timestamp"`
}

type Webhook

type Webhook struct {
	// ID is the id of the webhook.
	ID WebhookID `json:"id"`
	// Type is the WebhookType of the webhook.
	Type WebhookType `json:"type"`
	// GuildID is the guild id this webhook is for, if any.
	GuildID GuildID `json:"guild_id,omitempty"`
	// ChannelID is the channel id this webhook is for, if any.
	ChannelID ChannelID `json:"channel_id"`
	// User is the user this webhook was created by.
	//
	// This field is not returned when getting a webhook with its token.
	User *User `json:"user,omitempty"`

	// Name is the default name of the webhook.
	Name string `json:"name"`
	// Avatar is the default user avatar hash of the webhook.
	Avatar Hash `json:"avatar"`
	// Token is the secure token of the webhook, returned for incoming
	// webhooks.
	Token string `json:"token,omitempty"`

	// ApplicationID is the bot/OAuth2 application that created this webhook.
	ApplicationID AppID `json:"application_id"`

	// SourceGuild is the guild of the channel that this webhook is following.
	// It is returned for channel follower webhooks.
	//
	// This field will only be filled partially.
	SourceGuild *Guild `json:"source_guild,omitempty"`
	// SourceChannel is the channel that this webhook is following. It is
	// returned for channel follower webhooks.
	//
	// This field will only be filled partially.
	SourceChannel *Channel `json:"source_channel,omitempty"`
	// URL is the url used for executing the webhook. It is returned by the
	// webhooks OAuth2 flow.
	URL URL `json:"url,omitempty"`
}

Webhook is used to represent a webhook.

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

func (Webhook) CreatedAt

func (w Webhook) CreatedAt() time.Time

CreatedAt returns a time object representing when the webhook was created.

type WebhookID

type WebhookID Snowflake

WebhookID is the snowflake type for a WebhookID.

func (WebhookID) Increment

func (s WebhookID) Increment() uint16

func (WebhookID) IsNull

func (s WebhookID) IsNull() bool

IsNull returns whether or not the snowflake is null. This method is rarely ever useful; most people should use IsValid instead.

func (WebhookID) IsValid

func (s WebhookID) IsValid() bool

IsValid returns whether or not the snowflake is valid.

func (WebhookID) MarshalJSON

func (s WebhookID) MarshalJSON() ([]byte, error)

func (WebhookID) PID

func (s WebhookID) PID() uint8

func (WebhookID) String

func (s WebhookID) String() string

String returns the ID, or nothing if the snowflake isn't valid.

func (WebhookID) Time

func (s WebhookID) Time() time.Time

func (*WebhookID) UnmarshalJSON

func (s *WebhookID) UnmarshalJSON(v []byte) error

func (WebhookID) Worker

func (s WebhookID) Worker() uint8

type WebhookType

type WebhookType uint8
const (
	IncomingWebhook WebhookType
	ChannelFollowerWebhook
)

Jump to

Keyboard shortcuts

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