discord

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: ISC Imports: 9 Imported by: 86

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

Constants

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 NullAppID = AppID(NullSnowflake)
View Source
const NullAttachmentID = AttachmentID(NullSnowflake)
View Source
const NullAuditLogEntryID = AuditLogEntryID(NullSnowflake)
View Source
const NullChannelID = ChannelID(NullSnowflake)
View Source
const NullCommandID = CommandID(NullSnowflake)
View Source
const NullEmojiID = EmojiID(NullSnowflake)
View Source
const NullGuildID = GuildID(NullSnowflake)
View Source
const NullIntegrationID = IntegrationID(NullSnowflake)
View Source
const NullInteractionID = InteractionID(NullSnowflake)
View Source
const NullMessageID = MessageID(NullSnowflake)
View Source
const NullRoleID = RoleID(NullSnowflake)
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 NullStickerID = StickerID(NullSnowflake)
View Source
const NullStickerPackID = StickerPackID(NullSnowflake)
View Source
const NullUserID = UserID(NullSnowflake)
View Source
const NullWebhookID = WebhookID(NullSnowflake)
View Source
const TimestampFormat = time.RFC3339 // same as ISO8601

Variables

This section is empty.

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.

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 NewCustomEmoji

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.

func (APIEmoji) PathString

func (e APIEmoji) PathString() string

PathString returns the APIEmoji as a path-encoded string.

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 *ActivityTimestamp `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 ActivityTimestamp

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

type ActivityType

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

type AppID

type AppID Snowflake

func (AppID) Increment

func (s AppID) Increment() uint16

func (AppID) IsNull

func (s AppID) IsNull() bool

func (AppID) IsValid

func (s AppID) IsValid() bool

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

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 Attachment

type Attachment struct {
	// ID is the attachment id.
	ID AttachmentID `json:"id"`
	// Filename is the name of file attached.
	Filename string `json:"filename"`
	// 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"`
}

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

type AttachmentID

type AttachmentID Snowflake

func (AttachmentID) Increment

func (s AttachmentID) Increment() uint16

func (AttachmentID) IsNull

func (s AttachmentID) IsNull() bool

func (AttachmentID) IsValid

func (s AttachmentID) IsValid() bool

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

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 AuditEntryInfo

type AuditEntryInfo struct {
	// 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"`
}

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

type AuditLogEntryID

type AuditLogEntryID Snowflake

func (AuditLogEntryID) Increment

func (s AuditLogEntryID) Increment() uint16

func (AuditLogEntryID) IsNull

func (s AuditLogEntryID) IsNull() bool

func (AuditLogEntryID) IsValid

func (s AuditLogEntryID) IsValid() bool

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

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 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 Channel

type Channel struct {
	// ID is the id of this channel.
	ID ChannelID `json:"id"`
	// GuildID is the id of the guild.
	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"`
	// Permissions are the explicit permission overrides for members and roles.
	Permissions []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"`

	// 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"`
	// DMOwnerID is the id of the DM creator.
	DMOwnerID 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"`

	// CategoryID is the id of the parent category for a channel (each parent
	// category can contain up to 50 channels).
	CategoryID ChannelID `json:"parent_id,omitempty"`
	// LastPinTime is when the last pinned message was pinned.
	LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"`
}

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

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.

type ChannelID

type ChannelID Snowflake

func (ChannelID) Increment

func (s ChannelID) Increment() uint16

func (ChannelID) IsNull

func (s ChannelID) IsNull() bool

func (ChannelID) IsValid

func (s ChannelID) IsValid() bool

func (ChannelID) MarshalJSON

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

func (ChannelID) Mention

func (s ChannelID) Mention() string

func (ChannelID) PID

func (s ChannelID) PID() uint8

func (ChannelID) String

func (s ChannelID) String() string

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 ChannelType

type ChannelType uint8
var (
	// GuildText is a text channel within a server.
	GuildText ChannelType = 0
	// DirectMessage is a direct message between users.
	DirectMessage ChannelType = 1
	// GuildVoice is a voice channel within a server.
	GuildVoice ChannelType = 2
	// GroupDM is a direct message between multiple users.
	GroupDM ChannelType = 3
	// GuildCategory is an organizational category that contains up to 50
	// channels.
	GuildCategory ChannelType = 4
	// GuildNews is a channel that users can follow and crosspost into their
	// own server.
	GuildNews ChannelType = 5
	// GuildStore is a channel in which game developers can sell their game on
	// Discord.
	GuildStore ChannelType = 6
)

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

type Color

type Color uint32
var DefaultEmbedColor Color = 0x303030
var DefaultMemberColor Color = 0x0

DefaultMemberColor is the color used for members without colored roles.

func MemberColor

func MemberColor(guild Guild, member Member) Color

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

func (Color) Int

func (c Color) Int() int

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

func (c Color) Uint32() uint32

type Command added in v2.0.2

type Command struct {
	ID          CommandID       `json:"id"`
	AppID       AppID           `json:"application_id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Options     []CommandOption `json:"options,omitempty"`
}

type CommandID added in v2.0.2

type CommandID Snowflake

func (CommandID) Increment added in v2.0.2

func (s CommandID) Increment() uint16

func (CommandID) IsNull added in v2.0.2

func (s CommandID) IsNull() bool

func (CommandID) IsValid added in v2.0.2

func (s CommandID) IsValid() bool

func (CommandID) MarshalJSON added in v2.0.2

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

func (CommandID) PID added in v2.0.2

func (s CommandID) PID() uint8

func (CommandID) String added in v2.0.2

func (s CommandID) String() string

func (CommandID) Time added in v2.0.2

func (s CommandID) Time() time.Time

func (*CommandID) UnmarshalJSON added in v2.0.2

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

func (CommandID) Worker added in v2.0.2

func (s CommandID) Worker() uint8

type CommandOption added in v2.0.2

type CommandOption struct {
	Type        CommandOptionType     `json:"type"`
	Name        string                `json:"name"`
	Description string                `json:"description"`
	Required    bool                  `json:"required"`
	Choices     []CommandOptionChoice `json:"choices,omitempty"`
	Options     []CommandOption       `json:"options,omitempty"`
}

type CommandOptionChoice added in v2.0.2

type CommandOptionChoice struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type CommandOptionType added in v2.0.2

type CommandOptionType uint
const (
	SubcommandOption CommandOptionType = iota + 1
	SubcommandGroupOption
	StringOption
	IntegerOption
	BooleanOption
	UserOption
	ChannelOption
	RoleOption
)

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

func NewEmbed

func NewEmbed() *Embed

func (*Embed) Validate

func (e *Embed) Validate() error

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

type EmbedImage

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

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

type EmbedType

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

type EmbedVideo

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

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 tue 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) 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) String

func (e Emoji) String() string

String formats the string like how the client does.

type EmojiID

type EmojiID Snowflake

func (EmojiID) Increment

func (s EmojiID) Increment() uint16

func (EmojiID) IsNull

func (s EmojiID) IsNull() bool

func (EmojiID) IsValid

func (s EmojiID) IsValid() bool

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

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 ErrOverbound

type ErrOverbound struct {
	Count int
	Max   int

	Thing string
}

func (ErrOverbound) Error

func (e ErrOverbound) Error() string

type ExpireBehavior

type ExpireBehavior uint8

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

var (
	// RemoveRole removes the role of the subscriber.
	RemoveRole ExpireBehavior = 0
	// Kick kicks the subscriber from the guild.
	Kick ExpireBehavior = 1
)

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.

var (
	// NullExplicitFilter serialized to JSON null.
	// This should only be used on nullable fields.
	NullExplicitFilter ExplicitFilter = enum.Null
	// NoContentFilter disables content filtering for the guild.
	NoContentFilter ExplicitFilter = 0
	// MembersWithoutRoles filters only members without roles.
	MembersWithoutRoles ExplicitFilter = 1
	// AllMembers enables content filtering for all members.
	AllMembers ExplicitFilter = 2
)

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

func (ExplicitFilter) MarshalJSON

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

func (*ExplicitFilter) UnmarshalJSON

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

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

	// 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:"guild_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"`
}

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

func (GuildID) Increment

func (s GuildID) Increment() uint16

func (GuildID) IsNull

func (s GuildID) IsNull() bool

func (GuildID) IsValid

func (s GuildID) IsValid() bool

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

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

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

type IntegrationID

type IntegrationID Snowflake

func (IntegrationID) Increment

func (s IntegrationID) Increment() uint16

func (IntegrationID) IsNull

func (s IntegrationID) IsNull() bool

func (IntegrationID) IsValid

func (s IntegrationID) IsValid() bool

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

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 InteractionID added in v2.0.5

type InteractionID Snowflake

func (InteractionID) Increment added in v2.0.5

func (s InteractionID) Increment() uint16

func (InteractionID) IsNull added in v2.0.5

func (s InteractionID) IsNull() bool

func (InteractionID) IsValid added in v2.0.5

func (s InteractionID) IsValid() bool

func (InteractionID) MarshalJSON added in v2.0.5

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

func (InteractionID) PID added in v2.0.5

func (s InteractionID) PID() uint8

func (InteractionID) String added in v2.0.5

func (s InteractionID) String() string

func (InteractionID) Time added in v2.0.5

func (s InteractionID) Time() time.Time

func (*InteractionID) UnmarshalJSON added in v2.0.5

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

func (InteractionID) Worker added in v2.0.5

func (s InteractionID) Worker() uint8

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

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

	// 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"`

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

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

func (m Member) Mention() string

Mention returns the mention of the role.

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 []Reaction `json:"reactions,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"`

	// 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"`

	// Stickers contains the sticker sent with the message.
	Stickers []Sticker `json:"stickers,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

type MessageFlags

type MessageFlags enum.Enum
var (
	// NullMessage is the JSON null value of MessageFlags.
	NullMessage MessageFlags = enum.Null
	// CrosspostedMessage specifies whether the message has been published to
	// subscribed channels (via Channel Following).
	CrosspostedMessage MessageFlags = 1
	// MessageIsCrosspost specifies whether the message originated from a
	// message in another channel (via Channel Following).
	MessageIsCrosspost MessageFlags = 2
	// SuppressEmbeds specifies whether to not include any embeds when
	// serializing the message.
	SuppressEmbeds MessageFlags = 4
	// SourceMessageDeleted specifies whether the source message for the
	// crosspost has been deleted (via Channel Following).
	SourceMessageDeleted MessageFlags = 8
	// UrgentMessage specifies whether the message came from the urgent message
	// system.
	UrgentMessage MessageFlags = 16
)

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

type MessageID

type MessageID Snowflake

func (MessageID) Increment

func (s MessageID) Increment() uint16

func (MessageID) IsNull

func (s MessageID) IsNull() bool

func (MessageID) IsValid

func (s MessageID) IsValid() bool

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

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 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 = 0
	RecipientAddMessage               MessageType = 1
	RecipientRemoveMessage            MessageType = 2
	CallMessage                       MessageType = 3
	ChannelNameChangeMessage          MessageType = 4
	ChannelIconChangeMessage          MessageType = 5
	ChannelPinnedMessage              MessageType = 6
	GuildMemberJoinMessage            MessageType = 7
	NitroBoostMessage                 MessageType = 8
	NitroTier1Message                 MessageType = 9
	NitroTier2Message                 MessageType = 10
	NitroTier3Message                 MessageType = 11
	ChannelFollowAddMessage           MessageType = 12
	GuildDiscoveryDisqualifiedMessage MessageType = 14
	GuildDiscoveryRequalifiedMessage  MessageType = 15
	InlinedReplyMessage               MessageType = 19
	ApplicationCommandMessage         MessageType = 20
)

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

var (
	// NullNotification serialized to JSON null.
	// This should only be used on nullable fields.
	NullNotification Notification = enum.Null
	// AllMessages sends notifications for all messages.
	AllMessages Notification = 0
	// OnlyMentions sends notifications only on mention.
	OnlyMentions Notification = 1
)

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

func (Notification) MarshalJSON

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

func (*Notification) UnmarshalJSON

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

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
var (
	// Allows creation of instant invites
	PermissionCreateInstantInvite Permissions = 1 << 0
	// Allows kicking members
	PermissionKickMembers Permissions = 1 << 1
	// Allows banning members
	PermissionBanMembers Permissions = 1 << 2
	// Allows all permissions and bypasses channel permission overwrites
	PermissionAdministrator Permissions = 1 << 3
	// Allows management and editing of channels
	PermissionManageChannels Permissions = 1 << 4
	// Allows management and editing of the guild
	PermissionManageGuild Permissions = 1 << 5
	// Allows for the addition of reactions to messages
	PermissionAddReactions Permissions = 1 << 6
	// Allows for viewing of audit logs
	PermissionViewAuditLog Permissions = 1 << 7
	// Allows for using priority speaker in a voice channel
	PermissionPrioritySpeaker Permissions = 1 << 8
	// Allows the user to go live
	PermissionStream Permissions = 1 << 9
	// Allows guild members to view a channel, which includes reading messages
	// in text channels
	PermissionViewChannel Permissions = 1 << 10
	// Allows for sending messages in a channel
	PermissionSendMessages Permissions = 1 << 11
	// Allows for sending of /tts messages
	PermissionSendTTSMessages Permissions = 1 << 12
	// Allows for deletion of other users messages
	PermissionManageMessages Permissions = 1 << 13
	// Links sent by users with this permission will be auto-embedded
	PermissionEmbedLinks Permissions = 1 << 14
	// Allows for uploading images and files
	PermissionAttachFiles Permissions = 1 << 15
	// Allows for reading of message history
	PermissionReadMessageHistory Permissions = 1 << 16
	// 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 Permissions = 1 << 17
	// Allows the usage of custom emojis from other servers
	PermissionUseExternalEmojis Permissions = 1 << 18

	// Allows for joining of a voice channel
	PermissionConnect Permissions = 1 << 20
	// Allows for speaking in a voice channel
	PermissionSpeak Permissions = 1 << 21
	// Allows for muting members in a voice channel
	PermissionMuteMembers Permissions = 1 << 22
	// Allows for deafening of members in a voice channel
	PermissionDeafenMembers Permissions = 1 << 23
	// Allows for moving of members between voice channels
	PermissionMoveMembers Permissions = 1 << 24
	// Allows for using voice-activity-detection in a voice channel
	PermissionUseVAD Permissions = 1 << 25
	// Allows for modification of own nickname
	PermissionChangeNickname Permissions = 1 << 26
	// Allows for modification of other users nicknames
	PermissionManageNicknames Permissions = 1 << 27
	// Allows management and editing of roles
	PermissionManageRoles Permissions = 1 << 28
	// Allows management and editing of webhooks
	PermissionManageWebhooks Permissions = 1 << 29
	// Allows management and editing of emojis
	PermissionManageEmojis Permissions = 1 << 30

	PermissionAllText = 0 |
		PermissionViewChannel |
		PermissionSendMessages |
		PermissionSendTTSMessages |
		PermissionManageMessages |
		PermissionEmbedLinks |
		PermissionAttachFiles |
		PermissionReadMessageHistory |
		PermissionMentionEveryone |
		PermissionUseExternalEmojis

	PermissionAllVoice = 0 |
		PermissionConnect |
		PermissionSpeak |
		PermissionMuteMembers |
		PermissionDeafenMembers |
		PermissionMoveMembers |
		PermissionUseVAD |
		PermissionPrioritySpeaker

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

	PermissionAll = 0 |
		PermissionAllChannel |
		PermissionKickMembers |
		PermissionBanMembers |
		PermissionManageGuild |
		PermissionAdministrator |
		PermissionManageWebhooks |
		PermissionManageEmojis |
		PermissionManageNicknames |
		PermissionChangeNickname
)

func CalcOverwrites

func CalcOverwrites(guild Guild, channel Channel, member Member) Permissions

func (Permissions) Add

func (p Permissions) Add(perm Permissions) Permissions

func (Permissions) Has

func (p Permissions) Has(perm Permissions) bool

type Reaction

type Reaction struct {
	// Count is the amount of times the emoji has been used to react.
	Count int `json:"count"`
	// 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 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"`
}

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

func (Role) Mention

func (r Role) Mention() string

Mention returns the mention of the Role.

type RoleID

type RoleID Snowflake

func (RoleID) Increment

func (s RoleID) Increment() uint16

func (RoleID) IsNull

func (s RoleID) IsNull() bool

func (RoleID) IsValid

func (s RoleID) IsValid() bool

func (RoleID) MarshalJSON

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

func (RoleID) Mention

func (s RoleID) Mention() string

func (RoleID) PID

func (s RoleID) PID() uint8

func (RoleID) String

func (s RoleID) String() string

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

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

func NewSnowflake

func NewSnowflake(t time.Time) Snowflake

func ParseSnowflake

func ParseSnowflake(sf string) (Snowflake, error)

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.

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 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"`
	// 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:"-"`
	// Asset is the sticker's assert hash.
	Asset Hash `json:"asset"`
	// PreviewAsset is the sticker preview asset hash.
	PreviewAsset Hash `json:"preview_asset"`
	// FormatType is the type of sticker format.
	FormatType StickerFormatType `json:"format_type"`
}

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

func (Sticker) TagList

func (s Sticker) TagList() []string

TagList splits the sticker tags into a slice of strings.

type StickerFormatType

type StickerFormatType uint8

type StickerID

type StickerID Snowflake

func (StickerID) Increment

func (s StickerID) Increment() uint16

func (StickerID) IsNull

func (s StickerID) IsNull() bool

func (StickerID) IsValid

func (s StickerID) IsValid() bool

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

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 StickerPackID

type StickerPackID Snowflake

func (StickerPackID) Increment

func (s StickerPackID) Increment() uint16

func (StickerPackID) IsNull

func (s StickerPackID) IsNull() bool

func (StickerPackID) IsValid

func (s StickerPackID) IsValid() bool

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

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 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 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 User

type User struct {
	ID            UserID `json:"id"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	Avatar        Hash   `json:"avatar"`

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

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

func (u User) Mention() string

type UserFlags

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

	HouseBravery
	HouseBrilliance
	HouseBalance
	EarlySupporter
	TeamUser

	System

	BugHunterLvl2

	VerifiedBot
	VerifiedBotDeveloper
)
const NoFlag UserFlags = 0

type UserID

type UserID Snowflake

func (UserID) Increment

func (s UserID) Increment() uint16

func (UserID) IsNull

func (s UserID) IsNull() bool

func (UserID) IsValid

func (s UserID) IsValid() bool

func (UserID) MarshalJSON

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

func (UserID) Mention

func (s UserID) Mention() string

func (UserID) PID

func (s UserID) PID() uint8

func (UserID) String

func (s UserID) String() string

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
)

type Verification

type Verification enum.Enum

Verification is the verification level required for a guild.

var (
	// NullVerification serialized to JSON null.
	// This should only be used on nullable fields.
	NullVerification Verification = enum.Null
	// NoVerification required no verification.
	NoVerification Verification = 0
	// LowVerification requires a verified email
	LowVerification Verification = 1
	// MediumVerification requires the user be registered for at least 5
	// minutes.
	MediumVerification Verification = 2
	// HighVerification requires the member be in the server for more than 10
	// minutes.
	HighVerification Verification = 3
	// VeryHighVerification requires the member to have a verified phone
	// number.
	VeryHighVerification Verification = 4
)

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

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"`
	Suppress   bool `json:"suppress"`
}

type Webhook

type Webhook struct {
	ID   WebhookID   `json:"id"`
	Type WebhookType `json:"type"`
	User User        `json:"user"` // creator

	GuildID   GuildID   `json:"guild_id,omitempty"`
	ChannelID ChannelID `json:"channel_id"`

	Name   string `json:"name"`
	Avatar Hash   `json:"avatar"`
	Token  string `json:"token"` // incoming webhooks only
}

type WebhookID

type WebhookID Snowflake

func (WebhookID) Increment

func (s WebhookID) Increment() uint16

func (WebhookID) IsNull

func (s WebhookID) IsNull() bool

func (WebhookID) IsValid

func (s WebhookID) IsValid() bool

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

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