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
- func TimeToDiscordEpoch(t time.Time) int64
- type Activity
- type ActivityFlags
- type ActivityType
- type Attachment
- type Ban
- type Channel
- type ChannelMention
- type ChannelType
- type Color
- type Connection
- type ConnectionVisibility
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedType
- type EmbedVideo
- type Emoji
- type ErrOverbound
- type ExplicitFilter
- type Guild
- type GuildEmbed
- type GuildFeature
- type GuildUser
- type Hash
- type Integration
- type Invite
- type InviteUserType
- type MFALevel
- type Member
- type Message
- type MessageActivity
- type MessageActivityType
- type MessageApplication
- type MessageFlags
- type MessageReference
- type MessageType
- type Milliseconds
- type NitroBoost
- type Notification
- type Overwrite
- type OverwriteType
- type Permissions
- type Presence
- type Reaction
- type Role
- type Seconds
- type Service
- type Snowflake
- func (s Snowflake) Increment() uint16
- func (s *Snowflake) MarshalJSON() ([]byte, error)
- func (s Snowflake) PID() uint8
- func (s Snowflake) String() string
- func (s Snowflake) Time() time.Time
- func (s *Snowflake) UnmarshalJSON(v []byte) error
- func (s Snowflake) Valid() bool
- func (s Snowflake) Worker() uint8
- type Status
- type Timestamp
- type URL
- type UnixMsTimestamp
- type UnixTimestamp
- type User
- type UserFlags
- type UserNitro
- type Verification
- type VoiceRegion
- type VoiceState
- type Webhook
- type WebhookType
Constants ¶
View Source
const DefaultMaxPresences = 5000
Guild.MaxPresences is 5000 when it's 0. Seriously. The fucker who thought of this API thought it was also a good idea to return "null" instead of "5000." What the fucK? It has the same byte count, thus the same size. Sending the number over means it could be changed anytime and not force the developers to recheck. You could make the change right today and it would just work on all the clients. But no. IT'S FUCKING NULL!
View Source
const DiscordEpoch = 1420070400000 * int64(time.Millisecond)
View Source
const TimestampFormat = time.RFC3339 // same as ISO8601
Variables ¶
This section is empty.
Functions ¶
func TimeToDiscordEpoch ¶
Types ¶
type Activity ¶
type Activity struct { Name string `json:"name"` Type ActivityType `json:"type"` URL URL `json:"url"` CreatedAt UnixTimestamp `json:"created_at"` Timestamps struct { Start UnixMsTimestamp `json:"start,omitempty"` End UnixMsTimestamp `json:"end,omitempty"` } `json:"timestamps,omitempty"` ApplicationID Snowflake `json:"application_id,omitempty"` Details string `json:"details,omitempty"` State string `json:"state,omitempty"` // party status Emoji Emoji `json:"emoji,omitempty"` Party struct { ID string `json:"id,omitempty"` Size [2]int `json:"size,omitempty"` // [ current, max ] } `json:"party,omitempty"` Assets 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"` } `json:"assets,omitempty"` Secrets struct { Join string `json:"join,omitempty"` Spectate string `json:"spectate,omitempty"` Match string `json:"match,omitempty"` } `json:"secrets,omitempty"` Instance bool `json:"instance,omitempty"` Flags ActivityFlags `json:"flags,omitempty"` }
type ActivityFlags ¶
type ActivityFlags uint8
const ( InstanceActivity ActivityFlags = 1 << iota JoinActivity SpectateActivity JoinRequestActivity SyncActivity PlayActivity )
type ActivityType ¶
type ActivityType uint8
const ( // Playing $name GameActivity ActivityType = iota // Streaming $details StreamingActivity // Listening to $name ListeningActivity // $emoji $name CustomActivity )
type Attachment ¶
type Channel ¶
type Channel struct { ID Snowflake `json:"id,string"` Type ChannelType `json:"type"` GuildID Snowflake `json:"guild_id,string,omitempty"` Position int `json:"position,omitempty"` Name string `json:"name,omitempty"` // 2-100 chars Topic string `json:"topic,omitempty"` // 0-1024 chars NSFW bool `json:"nsfw"` Icon Hash `json:"icon,omitempty"` // Direct Messaging fields DMOwnerID Snowflake `json:"owner_id,string,omitempty"` DMRecipients []User `json:"recipients,omitempty"` // AppID of the group DM creator if it's bot-created AppID Snowflake `json:"application_id,string,omitempty"` // ID of the category the channel is in, if any. CategoryID Snowflake `json:"parent_id,string,omitempty"` LastPinTime Timestamp `json:"last_pin_timestamp,omitempty"` // Explicit permission overrides for members and roles. Permissions []Overwrite `json:"permission_overwrites,omitempty"` // ID of the last message, may not point to a valid one. LastMessageID Snowflake `json:"last_message_id,string,omitempty"` // Slow mode duration. Bots and people with "manage_messages" or // "manage_channel" permissions are unaffected. UserRateLimit Seconds `json:"rate_limit_per_user,omitempty"` // Voice, so GuildVoice only VoiceBitrate uint `json:"bitrate,omitempty"` VoiceUserLimit uint `json:"user_limit,omitempty"` }
type ChannelMention ¶
type ChannelMention struct { ChannelID Snowflake `json:"id,string"` GuildID Snowflake `json:"guild_id,string"` ChannelType ChannelType `json:"type"` ChannelName string `json:"name"` }
type ChannelType ¶
type ChannelType uint8
const ( GuildText ChannelType = iota DirectMessage GuildVoice GroupDM GuildCategory GuildNews GuildStore )
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
type Connection ¶
type Connection struct { ID Snowflake `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"` 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"` }
type EmbedAuthor ¶
type EmbedField ¶
type EmbedFooter ¶
type EmbedFooter struct {}
type EmbedImage ¶
type EmbedProvider ¶
type EmbedThumbnail ¶
type EmbedVideo ¶
type Emoji ¶
type Emoji struct { ID Snowflake `json:"id,string"` // 0 for Unicode emojis Name string `json:"name"` RoleIDs []Snowflake `json:"roles,omitempty"` User User `json:"user,omitempty"` RequireColons bool `json:"require_colons,omitempty"` Managed bool `json:"managed,omitempty"` Animated bool `json:"animated,omitempty"` }
type ErrOverbound ¶
func (ErrOverbound) Error ¶
func (e ErrOverbound) Error() string
type ExplicitFilter ¶
type ExplicitFilter uint8
const ( NoContentFilter ExplicitFilter = iota MembersWithoutRoles AllMembers )
type Guild ¶
type Guild struct { ID Snowflake `json:"id,string"` Name string `json:"name"` Icon Hash `json:"icon"` Splash Hash `json:"splash,omitempty"` // server invite bg Owner bool `json:"owner,omitempty"` // self is owner OwnerID Snowflake `json:"owner_id,string"` Permissions Permissions `json:"permissions,omitempty"` VoiceRegion string `json:"region"` AFKChannelID Snowflake `json:"afk_channel_id,string,omitempty"` AFKTimeout Seconds `json:"afk_timeout"` Embeddable bool `json:"embed_enabled,omitempty"` EmbedChannelID Snowflake `json:"embed_channel_id,string,omitempty"` Verification Verification `json:"verification_level"` Notification Notification `json:"default_message_notifications"` ExplicitFilter ExplicitFilter `json:"explicit_content_filter"` Roles []Role `json:"roles"` Emojis []Emoji `json:"emojis"` Features []GuildFeature `json:"guild_features"` MFA MFALevel `json:"mfa"` AppID Snowflake `json:"application_id,string,omitempty"` Widget bool `json:"widget_enabled,omitempty"` WidgetChannelID Snowflake `json:"widget_channel_id,string,omitempty"` SystemChannelID Snowflake `json:"system_channel_id,string,omitempty"` // It's DefaultMaxPresences when MaxPresences is 0. MaxPresences uint64 `json:"max_presences,omitempty"` MaxMembers uint64 `json:"max_members,omitempty"` VanityURLCode string `json:"vanity_url_code,omitempty"` Description string `json:"description,omitempty"` Banner Hash `json:"banner,omitempty"` NitroBoost NitroBoost `json:"premium_tier"` NitroBoosters uint64 `json:"premium_subscription_count,omitempty"` // Defaults to en-US, only set if guild has DISCOVERABLE PreferredLocale string `json:"preferred_locale"` }
type GuildEmbed ¶
type GuildFeature ¶
type GuildFeature string
const ( // Guild has access to set an invite splash background InviteSplash GuildFeature = "INVITE_SPLASH" // Guild has access to set 384kbps bitrate in voice (previously VIP voice // servers) VIPRegions GuildFeature = "VIP_REGIONS" // Guild has access to set a vanity URL VanityURL GuildFeature = "VANITY_URL" // Guild is verified Verified GuildFeature = "VERIFIED" // Guild is partnered Partnered GuildFeature = "PARTNERED" // Guild is public Public GuildFeature = "PUBLIC" // Guild has access to use commerce features (i.e. create store channels) Commerce GuildFeature = "COMMERCE" // Guild has access to create news channels News GuildFeature = "NEWS" // Guild is able to be discovered in the directory Discoverable GuildFeature = "DISCOVERABLE" // Guild is able to be featured in the directory Featurable GuildFeature = "FEATURABLE" // Guild has access to set an animated guild icon AnimatedIcon GuildFeature = "ANIMATED_ICON" // Guild has access to set a guild banner image Banner GuildFeature = "BANNER" )
type Integration ¶
type Integration struct { ID Snowflake `json:"id"` Name string `json:"name"` Type Service `json:"type"` Enabled bool `json:"enabled"` Syncing bool `json:"syncing"` // used for subscribers RoleID Snowflake `json:"role_id"` ExpireBehavior int `json:"expire_behavior"` ExpireGracePeriod int `json:"expire_grace_period"` User User `json:"user"` Account struct { ID string `json:"id"` Name string `json:"name"` } `json:"account"` SyncedAt Timestamp `json:"synced_at"` }
type Invite ¶
type Invite struct { Code string `json:"code"` Channel Channel `json:"channel"` // partial Guild *Guild `json:"guild,omitempty"` // partial ApproxMembers uint `json:"approximate_members_count,omitempty"` Target *User `json:"target_user,omitempty"` // partial TargetType InviteUserType `json:"target_user_type,omitempty"` // Only available if Target is ApproxPresences uint `json:"approximate_presence_count,omitempty"` }
type InviteUserType ¶
type InviteUserType uint8
const ( InviteNormalUser InviteUserType = iota InviteUserStream )
type Message ¶
type Message struct { ID Snowflake `json:"id,string"` Type MessageType `json:"type"` ChannelID Snowflake `json:"channel_id,string"` GuildID Snowflake `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"` // The member object exists in MESSAGE_CREATE and MESSAGE_UPDATE // events from text-based guild channels. Member *Member `json:"member,omitempty"` 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 []Snowflake `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:"reaction,omitempty"` // Used for validating a message was sent Nonce string `json:"nonce,omitempty"` WebhookID Snowflake `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"` }
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 MessageFlags ¶
type MessageFlags uint8
const ( CrosspostedMessage MessageFlags = 1 << iota MessageIsCrosspost SuppressEmbeds SourceMessageDeleted UrgentMessage )
type MessageReference ¶
type MessageType ¶
type MessageType uint8
const ( DefaultMessage MessageType = iota RecipientAddMessage RecipientRemoveMessage CallMessage ChannelNameChangeMessage ChannelIconChangeMessage ChannelPinnedMessage GuildMemberJoinMessage NitroBoostMessage NitroTier1Message NitroTier2Message NitroTier3Message ChannelFollowAddMessage )
type Milliseconds ¶
type Milliseconds int
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
const ( NoNitroLevel NitroBoost = iota NitroLevel1 NitroLevel2 NitroLevel3 )
type Overwrite ¶
type Overwrite struct { ID Snowflake `json:"id,string,omitempty"` Type OverwriteType `json:"type"` Allow Permissions `json:"allow"` Deny Permissions `json:"deny"` }
type OverwriteType ¶
type OverwriteType string
const ( OverwriteRole OverwriteType = "role" OverwriteMember OverwriteType = "member" )
type Permissions ¶
type Permissions uint64
const ( // Allows creation of instant invites PermissionCreateInstantInvite Permissions = 1 << iota // Allows kicking members PermissionKickMembers // Allows banning members PermissionBanMembers // Allows all permissions and bypasses channel permission overwrites PermissionAdministrator // Allows management and editing of channels PermissionManageChannels // Allows management and editing of the guild PermissionManageGuild // Allows for the addition of reactions to messages PermissionAddReactions // Allows for viewing of audit logs PermissionViewAuditLog // Allows for using priority speaker in a voice channel PermissionPrioritySpeaker // Allows the user to go live PermissionStream // Allows guild members to view a channel, which includes reading messages // in text channels PermissionViewChannel // Allows for sending messages in a channel PermissionSendMessages // Allows for sending of /tts messages PermissionSendTTSMessages // Allows for deletion of other users messages PermissionManageMessages // Links sent by users with this permission will be auto-embedded PermissionEmbedLinks // Allows for uploading images and files PermissionAttachFiles // Allows for reading of message history PermissionReadMessageHistory // Allows for using the @everyone tag to notify all users in a channel, // and the @here tag to notify all online users in a channel PermissionMentionEveryone // Allows the usage of custom emojis from other servers PermissionUseExternalEmojis // Allows for joining of a voice channel PermissionConnect // Allows for speaking in a voice channel PermissionSpeak // Allows for muting members in a voice channel PermissionMuteMembers // Allows for deafening of members in a voice channel PermissionDeafenMembers // Allows for moving of members between voice channels PermissionMoveMembers // Allows for using voice-activity-detection in a voice channel PermissionUseVAD // Allows for modification of own nickname PermissionChangeNickname // Allows for modification of other users nicknames PermissionManageNicknames // Allows management and editing of roles PermissionManageRoles // Allows management and editing of webhooks PermissionManageWebhooks // Allows management and editing of emojis PermissionManageEmojis PermissionAllText = 0 | PermissionViewChannel | PermissionSendMessages | PermissionSendTTSMessages | PermissionManageMessages | PermissionEmbedLinks | PermissionAttachFiles | PermissionReadMessageHistory | PermissionMentionEveryone 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 )
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 User `json:"user"` RoleIDs []Snowflake `json:"roles"` Nick string `json:"nick"` GuildID Snowflake `json:"guild_id"` PremiumSince Timestamp `json:"premium_since,omitempty"` Game *Activity `json:"game"` Activities []Activity `json:"activities"` Status Status `json:"status"` ClientStatus struct { Desktop Status `json:"status,omitempty"` Mobile Status `json:"mobile,omitempty"` Web Status `json:"web,omitempty"` } `json:"client_status"` }
type Role ¶
type Role struct { ID Snowflake `json:"id,string"` Name string `json:"name"` Color Color `json:"color"` Hoist bool `json:"hoist"` // if the role is separated Position int `json:"position"` Permissions Permissions `json:"permissions"` Managed bool `json:"managed"` Mentionable bool `json:"mentionable"` }
type Snowflake ¶
type Snowflake int64
func NewSnowflake ¶
func ParseSnowflake ¶ added in v0.0.9
func (*Snowflake) MarshalJSON ¶
func (*Snowflake) UnmarshalJSON ¶
type UnixMsTimestamp ¶
type UnixMsTimestamp int64
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 Snowflake `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"` Nitro UserNitro `json:"premium_type,omitempty"` }
type Verification ¶
type Verification uint8
const ( NoVerification Verification = iota // LowVerification requires a verified email LowVerification // MediumVerification requires the user be registered for at least 5 // minutes. MediumVerification // HighVerification requires the member be in the server for more than 10 // minutes. HighVerification // VeryHighVerification requires the member to have a verified phone // number. VeryHighVerification )
type VoiceRegion ¶
type VoiceState ¶
type VoiceState struct { // GuildID isn't available from the Guild struct. GuildID Snowflake `json:"guild_id,string"` ChannelID Snowflake `json:"channel_id,string"` UserID Snowflake `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 Snowflake `json:"id"` Type WebhookType `json:"type"` User User `json:"user"` // creator GuildID Snowflake `json:"guild_id,omitempty"` ChannelID Snowflake `json:"channel_id"` Name string `json:"name"` Avatar Hash `json:"avatar"` Token string `json:"token"` // incoming webhooks only }
type WebhookType ¶
type WebhookType uint8
const ( IncomingWebhook WebhookType ChannelFollowerWebhook )
Click to show internal directories.
Click to hide internal directories.