discord

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: ISC Imports: 8 Imported by: 39

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 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 NullEmojiID = EmojiID(NullSnowflake)
View Source
const NullGuildID = GuildID(NullSnowflake)
View Source
const NullIntegrationID = IntegrationID(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 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 added in v1.0.0

func DurationSinceEpoch(t time.Time) time.Duration

DurationSinceEpoch returns the duration from the Discord epoch to current.

func HasFlag added in v0.6.2

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'd into flag. This function could be used for different constants such as Permission.

Types

type Activity

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

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

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

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

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

type ActivityAssets added in v0.2.0

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 added in v0.2.0

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

type ActivitySecrets added in v0.2.0

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

type ActivityTimestamp added in v0.2.0

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 added in v1.0.0

type AppID Snowflake

func (AppID) Increment added in v1.0.0

func (s AppID) Increment() uint16

func (AppID) IsNull added in v1.0.0

func (s AppID) IsNull() bool

func (AppID) IsValid added in v1.0.0

func (s AppID) IsValid() bool

func (AppID) MarshalJSON added in v1.0.0

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

func (AppID) PID added in v1.0.0

func (s AppID) PID() uint8

func (AppID) String added in v1.0.0

func (s AppID) String() string

func (AppID) Time added in v1.0.0

func (s AppID) Time() time.Time

func (*AppID) UnmarshalJSON added in v1.0.0

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

func (AppID) Worker added in v1.0.0

func (s AppID) Worker() uint8

type Attachment

type Attachment struct {
	ID       AttachmentID `json:"id,string"`
	Filename string       `json:"filename"`
	Size     uint64       `json:"size"`

	URL   URL `json:"url"`
	Proxy URL `json:"proxy_url"`

	// Only if Image
	Height uint `json:"height,omitempty"`
	Width  uint `json:"width,omitempty"`
}

type AttachmentID added in v1.0.0

type AttachmentID Snowflake

func (AttachmentID) Increment added in v1.0.0

func (s AttachmentID) Increment() uint16

func (AttachmentID) IsNull added in v1.0.0

func (s AttachmentID) IsNull() bool

func (AttachmentID) IsValid added in v1.0.0

func (s AttachmentID) IsValid() bool

func (AttachmentID) MarshalJSON added in v1.0.0

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

func (AttachmentID) PID added in v1.0.0

func (s AttachmentID) PID() uint8

func (AttachmentID) String added in v1.0.0

func (s AttachmentID) String() string

func (AttachmentID) Time added in v1.0.0

func (s AttachmentID) Time() time.Time

func (*AttachmentID) UnmarshalJSON added in v1.0.0

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

func (AttachmentID) Worker added in v1.0.0

func (s AttachmentID) Worker() uint8

type AuditEntryInfo added in v0.6.3

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 ChannelOverwritten `json:"type,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 added in v0.6.3

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 added in v0.6.3

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 added in v0.6.4

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

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

type AuditLogChangeKey added in v0.6.3

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 added in v0.6.4

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 string `json:"target_id,omitempty"`
	// 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 added in v1.0.0

type AuditLogEntryID Snowflake

func (AuditLogEntryID) Increment added in v1.0.0

func (s AuditLogEntryID) Increment() uint16

func (AuditLogEntryID) IsNull added in v1.0.0

func (s AuditLogEntryID) IsNull() bool

func (AuditLogEntryID) IsValid added in v1.0.0

func (s AuditLogEntryID) IsValid() bool

func (AuditLogEntryID) MarshalJSON added in v1.0.0

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

func (AuditLogEntryID) PID added in v1.0.0

func (s AuditLogEntryID) PID() uint8

func (AuditLogEntryID) String added in v1.0.0

func (s AuditLogEntryID) String() string

func (AuditLogEntryID) Time added in v1.0.0

func (s AuditLogEntryID) Time() time.Time

func (*AuditLogEntryID) UnmarshalJSON added in v1.0.0

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

func (AuditLogEntryID) Worker added in v1.0.0

func (s AuditLogEntryID) Worker() uint8

type AuditLogEvent added in v0.6.3

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,string"`
	// Type is the type of channel.
	Type ChannelType `json:"type"`
	// GuildID is the id of the guild.
	GuildID GuildID `json:"guild_id,string,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"`
	// NSFW specifies whether the channel is nsfw.
	NSFW bool `json:"nsfw"`

	// 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,string,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,string,omitempty"`

	// AppID is the application id of the group DM creator if it is
	// bot-created.
	AppID AppID `json:"application_id,string,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,string,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 added in v0.2.0

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 added in v0.9.1

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 added in v0.0.11

func (ch Channel) Mention() string

Mention returns a mention of the channel.

type ChannelID added in v1.0.0

type ChannelID Snowflake

func (ChannelID) Increment added in v1.0.0

func (s ChannelID) Increment() uint16

func (ChannelID) IsNull added in v1.0.0

func (s ChannelID) IsNull() bool

func (ChannelID) IsValid added in v1.0.0

func (s ChannelID) IsValid() bool

func (ChannelID) MarshalJSON added in v1.0.0

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

func (ChannelID) Mention added in v1.3.3

func (s ChannelID) Mention() string

func (ChannelID) PID added in v1.0.0

func (s ChannelID) PID() uint8

func (ChannelID) String added in v1.0.0

func (s ChannelID) String() string

func (ChannelID) Time added in v1.0.0

func (s ChannelID) Time() time.Time

func (*ChannelID) UnmarshalJSON added in v1.0.0

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

func (ChannelID) Worker added in v1.0.0

func (s ChannelID) Worker() uint8

type ChannelMention

type ChannelMention struct {
	ChannelID   ChannelID   `json:"id,string"`
	GuildID     GuildID     `json:"guild_id,string"`
	ChannelType ChannelType `json:"type"`
	ChannelName string      `json:"name"`
}

type ChannelOverwritten added in v0.6.3

type ChannelOverwritten string

ChannelOverwritten is the type of overwritten entity in (AuditEntryInfo).Type.

const (
	MemberChannelOverwritten ChannelOverwritten = "member"
	RoleChannelOverwritten   ChannelOverwritten = "role"
)

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 added in v0.0.7

func MemberColor(guild Guild, member Member) Color

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

func (Color) Int added in v0.0.7

func (c Color) Int() int

func (Color) RGB added in v0.1.5

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

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

func (Color) Uint32 added in v0.0.7

func (c Color) Uint32() uint32

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   EmojiID `json:"id,string"` // NullSnowflake for unicode emojis
	Name string  `json:"name"`

	RoleIDs []RoleID `json:"roles,omitempty"`
	User    User     `json:"user,omitempty"`

	RequireColons bool `json:"require_colons,omitempty"`
	Managed       bool `json:"managed,omitempty"`
	Animated      bool `json:"animated,omitempty"`
}

func (Emoji) APIString

func (e Emoji) APIString() string

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

func (Emoji) EmojiURL added in v0.8.1

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 added in v0.8.1

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 added in v1.0.0

type EmojiID Snowflake

func (EmojiID) Increment added in v1.0.0

func (s EmojiID) Increment() uint16

func (EmojiID) IsNull added in v1.0.0

func (s EmojiID) IsNull() bool

func (EmojiID) IsValid added in v1.0.0

func (s EmojiID) IsValid() bool

func (EmojiID) MarshalJSON added in v1.0.0

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

func (EmojiID) PID added in v1.0.0

func (s EmojiID) PID() uint8

func (EmojiID) String added in v1.0.0

func (s EmojiID) String() string

func (EmojiID) Time added in v1.0.0

func (s EmojiID) Time() time.Time

func (*EmojiID) UnmarshalJSON added in v1.0.0

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

func (EmojiID) Worker added in v1.0.0

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 added in v0.7.0

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 added in v0.7.0

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

func (*ExplicitFilter) UnmarshalJSON added in v0.7.0

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

type Guild

type Guild struct {
	// ID is the guild id.
	ID GuildID `json:"id,string"`
	// 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"`
	// OwnerID is the id of owner.
	OwnerID UserID `json:"owner_id,string"`

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

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

	// Embeddable is true if the server widget is enabled.
	//
	// Deprecated: replaced with WidgetEnabled
	Embeddable bool `json:"embed_enabled,omitempty"`
	// EmbedChannelID is the channel id that the widget will generate an invite
	// to, or null if set to no invite .
	//
	// Deprecated: replaced with WidgetChannelID
	EmbedChannelID ChannelID `json:"embed_channel_id,string,omitempty"`

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

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

	// MFA is the required MFA level for the guild.
	MFA MFALevel `json:"mfa"`

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

	// Widget is true if the server widget is enabled.
	Widget bool `json:"widget_enabled,omitempty"`
	// 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,string,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,string,omitempty"`
	// SystemChannelFlags are the system channel flags.
	SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"`

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

	// NitroBoost is the premium tier (Server Boost level).
	NitroBoost NitroBoost `json:"premium_tier"`
	// 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 from the GET /guild/<id> endpoint when with_counts is true
	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 added in v0.1.1

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 added in v0.8.1

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 added in v0.9.1

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 added in v0.9.1

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 added in v0.1.1

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 added in v0.8.1

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 added in v0.1.1

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 added in v0.8.1

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 added in v1.0.0

type GuildID Snowflake

func (GuildID) Increment added in v1.0.0

func (s GuildID) Increment() uint16

func (GuildID) IsNull added in v1.0.0

func (s GuildID) IsNull() bool

func (GuildID) IsValid added in v1.0.0

func (s GuildID) IsValid() bool

func (GuildID) MarshalJSON added in v1.0.0

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

func (GuildID) PID added in v1.0.0

func (s GuildID) PID() uint8

func (GuildID) String added in v1.0.0

func (s GuildID) String() string

func (GuildID) Time added in v1.0.0

func (s GuildID) Time() time.Time

func (*GuildID) UnmarshalJSON added in v1.0.0

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

func (GuildID) Worker added in v1.0.0

func (s GuildID) Worker() uint8

type GuildPreview added in v0.8.1

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 added in v0.8.1

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 added in v0.8.1

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 added in v0.8.1

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 added in v0.8.1

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 added in v0.8.1

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 added in v0.8.1

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 added in v0.8.2

type GuildWidget 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 added in v0.8.1

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, etc).
	Type Service `json:"type"`

	// Enables specifies if the integration is enabled.
	Enabled bool `json:"enabled"`
	// Syncing specifies if the integration is syncing.
	Syncing bool `json:"syncing"`

	// RoleID is the id that this integration uses for "subscribers".
	RoleID RoleID `json:"role_id"`

	// EnableEmoticons specifies whether emoticons should be synced for this
	// integration (twitch only currently).
	EnableEmoticons bool `json:"enable_emoticons,omitempty"`

	// ExpireBehavior is the behavior of expiring subscribers
	ExpireBehavior ExpireBehavior `json:"expire_behavior"`
	// ExpireGracePeriod is the grace period (in days) before expiring
	// subscribers.
	ExpireGracePeriod int `json:"expire_grace_period"`

	// User is the user for this integration.
	User User `json:"user"`
	// Account is the integration account information.
	//
	// https://discord.com/developers/docs/resources/guild#integration-account-object
	Account struct {
		// ID is the id of the account.
		ID string `json:"id"`
		// Name is the name of the account.
		Name string `json:"name"`
	} `json:"account"`

	// SyncedAt specifies when this integration was last synced.
	SyncedAt Timestamp `json:"synced_at"`
}

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

type IntegrationID added in v1.0.0

type IntegrationID Snowflake

func (IntegrationID) Increment added in v1.0.0

func (s IntegrationID) Increment() uint16

func (IntegrationID) IsNull added in v1.0.0

func (s IntegrationID) IsNull() bool

func (IntegrationID) IsValid added in v1.0.0

func (s IntegrationID) IsValid() bool

func (IntegrationID) MarshalJSON added in v1.0.0

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

func (IntegrationID) PID added in v1.0.0

func (s IntegrationID) PID() uint8

func (IntegrationID) String added in v1.0.0

func (s IntegrationID) String() string

func (IntegrationID) Time added in v1.0.0

func (s IntegrationID) Time() time.Time

func (*IntegrationID) UnmarshalJSON added in v1.0.0

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

func (IntegrationID) Worker added in v1.0.0

func (s IntegrationID) 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 added in v0.6.3

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 added in v0.0.11

func (m Member) Mention() string

Mention returns the mention of the role.

type Message

type Message struct {
	ID        MessageID   `json:"id,string"`
	Type      MessageType `json:"type"`
	ChannelID ChannelID   `json:"channel_id,string"`
	GuildID   GuildID     `json:"guild_id,string,omitempty"`

	// 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 string `json:"content"`

	Timestamp       Timestamp `json:"timestamp,omitempty"`
	EditedTimestamp Timestamp `json:"edited_timestamp,omitempty"`

	TTS    bool `json:"tts"`
	Pinned bool `json:"pinned"`

	// 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  []RoleID `json:"mention_roles"`
	MentionEveryone bool     `json:"mention_everyone"`

	// Not all channel mentions in a message will appear in mention_channels.
	MentionChannels []ChannelMention `json:"mention_channels,omitempty"`

	Attachments []Attachment `json:"attachments"`
	Embeds      []Embed      `json:"embeds"`

	Reactions []Reaction `json:"reactions,omitempty"`

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

	WebhookID   WebhookID           `json:"webhook_id,string,omitempty"`
	Activity    *MessageActivity    `json:"activity,omitempty"`
	Application *MessageApplication `json:"application,omitempty"`
	Reference   *MessageReference   `json:"message_reference,omitempty"`
	Flags       MessageFlags        `json:"flags"`
}

func (Message) URL added in v0.0.11

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 MessageActivityType `json:"type"`

	// From a Rich Presence event
	PartyID string `json:"party_id,omitempty"`
}

type MessageActivityType

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

type MessageApplication

type MessageApplication struct {
	ID          AppID  `json:"id,string"`
	CoverID     string `json:"cover_image,omitempty"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Name        string `json:"name"`
}

type MessageFlags

type MessageFlags enum.Enum
var (
	NullMessage          MessageFlags = enum.Null
	CrosspostedMessage   MessageFlags = 1
	MessageIsCrosspost   MessageFlags = 2
	SuppressEmbeds       MessageFlags = 4
	SourceMessageDeleted MessageFlags = 8
	UrgentMessage        MessageFlags = 16
)

type MessageID added in v1.0.0

type MessageID Snowflake

func (MessageID) Increment added in v1.0.0

func (s MessageID) Increment() uint16

func (MessageID) IsNull added in v1.0.0

func (s MessageID) IsNull() bool

func (MessageID) IsValid added in v1.0.0

func (s MessageID) IsValid() bool

func (MessageID) MarshalJSON added in v1.0.0

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

func (MessageID) PID added in v1.0.0

func (s MessageID) PID() uint8

func (MessageID) String added in v1.0.0

func (s MessageID) String() string

func (MessageID) Time added in v1.0.0

func (s MessageID) Time() time.Time

func (*MessageID) UnmarshalJSON added in v1.0.0

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

func (MessageID) Worker added in v1.0.0

func (s MessageID) Worker() uint8

type MessageReference

type MessageReference struct {
	ChannelID ChannelID `json:"channel_id,string"`

	// Field might not be provided
	MessageID MessageID `json:"message_id,string,omitempty"`
	GuildID   GuildID   `json:"guild_id,string,omitempty"`
}

type MessageType

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

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 added in v0.7.0

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

func (*Notification) UnmarshalJSON added in v0.7.0

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

type Overwrite

type Overwrite struct {
	// ID is the role or user id.
	ID Snowflake `json:"id"`
	// Type is either "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

func (*Overwrite) UnmarshalJSON added in v1.1.7

func (o *Overwrite) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON unmarshals the passed json data into the Overwrite. This is necessary because Discord has different names for fields when sending than receiving.

type OverwriteType

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

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 Presence

type Presence struct {
	// User is the user presence is being updated for.
	User User `json:"user"`
	// RoleIDs are the roles this user is in.
	RoleIDs []RoleID `json:"roles"`

	// Game is null, or the user's current activity.
	Game *Activity `json:"game"`

	// 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"`
	// ClientStaus is the user's platform-dependent status.
	//
	// https://discord.com/developers/docs/topics/gateway#client-status-object
	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"`
	} `json:"client_status"`
	// Premium since specifies when the user started boosting the guild.
	PremiumSince Timestamp `json:"premium_since,omitempty"`
	// Nick is this users guild nickname (if one is set).
	Nick string `json:"nick,omitempty"`
}

https://discord.com/developers/docs/topics/gateway#presence-update

type Reaction

type Reaction struct {
	Count int   `json:"count"`
	Me    bool  `json:"me"` // for current user
	Emoji Emoji `json:"emoji"`
}

type Relationship added in v0.10.5

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 added in v0.10.5

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,string"`
	// Name is the role name.
	Name string `json:"name"`

	// 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"`
	// Position is the position of this role.
	Position int `json:"position"`

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

	// 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 added in v0.0.11

func (r Role) Mention() string

Mention returns the mention of the Role.

type RoleID added in v1.0.0

type RoleID Snowflake

func (RoleID) Increment added in v1.0.0

func (s RoleID) Increment() uint16

func (RoleID) IsNull added in v1.0.0

func (s RoleID) IsNull() bool

func (RoleID) IsValid added in v1.0.0

func (s RoleID) IsValid() bool

func (RoleID) MarshalJSON added in v1.0.0

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

func (RoleID) Mention added in v1.3.3

func (s RoleID) Mention() string

func (RoleID) PID added in v1.0.0

func (s RoleID) PID() uint8

func (RoleID) String added in v1.0.0

func (s RoleID) String() string

func (RoleID) Time added in v1.0.0

func (s RoleID) Time() time.Time

func (*RoleID) UnmarshalJSON added in v1.0.0

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

func (RoleID) Worker added in v1.0.0

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 added in v0.7.0

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 (
	Twitch  Service = "twitch"
	YouTube Service = "youtube"
)

type Snowflake

type Snowflake uint64

func NewSnowflake

func NewSnowflake(t time.Time) Snowflake

func ParseSnowflake added in v0.0.9

func ParseSnowflake(sf string) (Snowflake, error)

func (Snowflake) Increment

func (s Snowflake) Increment() uint16

func (Snowflake) IsNull added in v1.0.0

func (s Snowflake) IsNull() bool

IsNull returns whether or not the snowflake is null.

func (Snowflake) IsValid added in v1.0.0

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 Status

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

type SystemChannelFlags added in v0.8.6

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 added in v0.0.13

func NewTimestamp(t time.Time) Timestamp

func NowTimestamp added in v0.0.13

func NowTimestamp() Timestamp

func (Timestamp) Format added in v0.0.7

func (t Timestamp) Format(fmt string) string

func (Timestamp) IsValid added in v1.0.0

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 added in v0.0.7

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 added in v0.2.0

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,string"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	Avatar        Hash   `json:"avatar"`

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

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

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

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

func (User) AvatarURL added in v0.0.11

func (u User) AvatarURL() string

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

func (User) AvatarURLWithType added in v0.8.1

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 added in v0.0.11

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 added in v1.0.0

type UserID Snowflake

func (UserID) Increment added in v1.0.0

func (s UserID) Increment() uint16

func (UserID) IsNull added in v1.0.0

func (s UserID) IsNull() bool

func (UserID) IsValid added in v1.0.0

func (s UserID) IsValid() bool

func (UserID) MarshalJSON added in v1.0.0

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

func (UserID) Mention added in v1.3.3

func (s UserID) Mention() string

func (UserID) PID added in v1.0.0

func (s UserID) PID() uint8

func (UserID) String added in v1.0.0

func (s UserID) String() string

func (UserID) Time added in v1.0.0

func (s UserID) Time() time.Time

func (*UserID) UnmarshalJSON added in v1.0.0

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

func (UserID) Worker added in v1.0.0

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 added in v0.7.0

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

func (*Verification) UnmarshalJSON added in v0.7.0

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

	ChannelID ChannelID `json:"channel_id,string"`
	UserID    UserID    `json:"user_id,string"`
	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 added in v1.0.0

type WebhookID Snowflake

func (WebhookID) Increment added in v1.0.0

func (s WebhookID) Increment() uint16

func (WebhookID) IsNull added in v1.0.0

func (s WebhookID) IsNull() bool

func (WebhookID) IsValid added in v1.0.0

func (s WebhookID) IsValid() bool

func (WebhookID) MarshalJSON added in v1.0.0

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

func (WebhookID) PID added in v1.0.0

func (s WebhookID) PID() uint8

func (WebhookID) String added in v1.0.0

func (s WebhookID) String() string

func (WebhookID) Time added in v1.0.0

func (s WebhookID) Time() time.Time

func (*WebhookID) UnmarshalJSON added in v1.0.0

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

func (WebhookID) Worker added in v1.0.0

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