Documentation ¶
Overview ¶
Package discordgo provides Discord binding for Go
Index ¶
- Constants
- Variables
- func CheckRetry(_ context.Context, resp *http.Response, err error) (bool, error)
- func GetEventInterface(evtType string) interface{}
- func MemberPermissions(guild *Guild, channel *Channel, member *Member) (apermissions int)
- func SnowflakeTimestamp(ID string) (t time.Time, err error)
- func StrID(id int64) string
- type APIErrorMessage
- type Ack
- type Application
- type Asset
- type Assets
- type AuditLogEntry
- type Bucket
- type Channel
- type ChannelCreate
- type ChannelDelete
- type ChannelEdit
- type ChannelEvent
- type ChannelPinsUpdate
- type ChannelType
- type ChannelUpdate
- type Connect
- type Disconnect
- type DiscordFloat
- type DiscordInt64
- type Emoji
- type EmojiName
- type Event
- type EventHandler
- type EventInterfaceProvider
- type ExplicitContentFilterLevel
- type File
- type FriendSourceFlags
- type Game
- type GameType
- type GatewayBotResponse
- type GatewayConnection
- func (g *GatewayConnection) Close() error
- func (g *GatewayConnection) Reconnect(forceReIdentify bool) error
- func (g *GatewayConnection) ReconnectUnlessClosed(forceReIdentify bool) error
- func (g *GatewayConnection) RequestGuildMembers(guildID int64, query string, limit int)
- func (g *GatewayConnection) Status() (st GatewayStatus)
- func (g *GatewayConnection) SubscribeGuild(guildID int64, typing, activities bool)
- func (g *GatewayConnection) UpdateStatusComplex(usd UpdateStatusData)
- type GatewayConnectionManager
- func (g *GatewayConnectionManager) ChannelVoiceJoin(gID, cID int64, mute, deaf bool) (voice *VoiceConnection, err error)
- func (g *GatewayConnectionManager) ChannelVoiceLeave(gID int64)
- func (g *GatewayConnectionManager) Close() (err error)
- func (s *GatewayConnectionManager) GetSessionInfo() (sessionID string, sequence int64)
- func (g *GatewayConnectionManager) HeartBeatStats() (lastSend time.Time, lastAck time.Time)
- func (g *GatewayConnectionManager) Open() error
- func (g *GatewayConnectionManager) Reconnect(forceIdentify bool) error
- func (g *GatewayConnectionManager) RequestGuildMembers(guildID int64, query string, limit int)
- func (s *GatewayConnectionManager) SetSessionInfo(sessionID string, sequence int64)
- func (g *GatewayConnectionManager) Status() GatewayStatus
- func (g *GatewayConnectionManager) SubscribeGuild(guildID int64, typing, activities bool)
- type GatewayIdentifyRatelimiter
- type GatewayOP
- type GatewayStatus
- type Guild
- type GuildAuditLog
- type GuildBan
- type GuildBanAdd
- type GuildBanRemove
- type GuildCreate
- type GuildDelete
- type GuildEmbed
- type GuildEmojisUpdate
- type GuildEvent
- type GuildIntegrationsUpdate
- type GuildMemberAdd
- type GuildMemberRemove
- type GuildMemberUpdate
- type GuildMembersChunk
- type GuildParams
- type GuildRole
- type GuildRoleCreate
- type GuildRoleDelete
- type GuildRoleUpdate
- type GuildUpdate
- type ICEServer
- type IDSlice
- type Integration
- type IntegrationAccount
- type Invite
- type Login
- type LoginResponse
- type Member
- type Message
- type MessageAck
- type MessageAttachment
- type MessageCreate
- type MessageDelete
- type MessageDeleteBulk
- type MessageEdit
- type MessageEmbed
- type MessageEmbedAuthor
- type MessageEmbedField
- type MessageEmbedFooter
- type MessageEmbedImage
- type MessageEmbedProvider
- type MessageEmbedThumbnail
- type MessageEmbedVideo
- type MessageReaction
- type MessageReactionAdd
- type MessageReactionRemove
- type MessageReactionRemoveAll
- type MessageReactions
- type MessageSend
- type MessageType
- type MessageUpdate
- type MfaLevel
- type OptionalRequestHeaders
- type Packet
- type PermissionOverwrite
- type PremiumType
- type Presence
- type PresenceUpdate
- type PresencesReplace
- type RESTError
- type RateLimit
- type RateLimiter
- type ReadState
- type ReaderWithMockClose
- type Ready
- type Relationship
- type RelationshipAdd
- type RelationshipRemove
- type Resumed
- type Role
- type Roles
- type SelfUser
- type Session
- func (s *Session) AddHandler(handler interface{}) func()
- func (s *Session) AddHandlerOnce(handler interface{}) func()
- func (s *Session) Application(appID int64) (st *Application, err error)
- func (s *Session) ApplicationAssets(appID int64) (ass []*Asset, err error)
- func (s *Session) ApplicationBotCreate(appID int64) (st *User, err error)
- func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error)
- func (s *Session) ApplicationDelete(appID int64) (err error)
- func (s *Session) ApplicationUpdate(appID int64, ap *Application) (st *Application, err error)
- func (s *Session) Applications() (st []*Application, err error)
- func (s *Session) Channel(channelID int64) (st *Channel, err error)
- func (s *Session) ChannelDelete(channelID int64) (st *Channel, err error)
- func (s *Session) ChannelEdit(channelID int64, name string) (*Channel, error)
- func (s *Session) ChannelEditComplex(channelID int64, data *ChannelEdit) (st *Channel, err error)
- func (s *Session) ChannelFileSend(channelID int64, name string, r io.Reader) (*Message, error)
- func (s *Session) ChannelFileSendWithMessage(channelID int64, content string, name string, r io.Reader) (*Message, error)
- func (s *Session) ChannelInviteCreate(channelID int64, i Invite) (st *Invite, err error)
- func (s *Session) ChannelInvites(channelID int64) (st []*Invite, err error)
- func (s *Session) ChannelMessage(channelID, messageID int64) (st *Message, err error)
- func (s *Session) ChannelMessageAck(channelID, messageID int64, lastToken string) (st *Ack, err error)
- func (s *Session) ChannelMessageDelete(channelID, messageID int64) (err error)
- func (s *Session) ChannelMessageEdit(channelID, messageID int64, content string) (*Message, error)
- func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err error)
- func (s *Session) ChannelMessageEditEmbed(channelID, messageID int64, embed *MessageEmbed) (*Message, error)
- func (s *Session) ChannelMessagePin(channelID, messageID int64) (err error)
- func (s *Session) ChannelMessageSend(channelID int64, content string) (*Message, error)
- func (s *Session) ChannelMessageSendComplex(channelID int64, data *MessageSend) (st *Message, err error)
- func (s *Session) ChannelMessageSendEmbed(channelID int64, embed *MessageEmbed) (*Message, error)
- func (s *Session) ChannelMessageSendTTS(channelID int64, content string) (*Message, error)
- func (s *Session) ChannelMessageUnpin(channelID, messageID int64) (err error)
- func (s *Session) ChannelMessages(channelID int64, limit int, beforeID, afterID, aroundID int64) (st []*Message, err error)
- func (s *Session) ChannelMessagesBulkDelete(channelID int64, messages []int64) (err error)
- func (s *Session) ChannelMessagesPinned(channelID int64) (st []*Message, err error)
- func (s *Session) ChannelPermissionDelete(channelID, targetID int64) (err error)
- func (s *Session) ChannelPermissionSet(channelID, targetID int64, targetType string, allow, deny int) (err error)
- func (s *Session) ChannelTyping(channelID int64) (err error)
- func (s *Session) ChannelWebhooks(channelID int64) (st []*Webhook, err error)
- func (s *Session) Close() error
- func (s *Session) Gateway() (gateway string, err error)
- func (s *Session) GatewayBot() (st *GatewayBotResponse, err error)
- func (s *Session) Guild(guildID int64) (st *Guild, err error)
- func (s *Session) GuildAuditLog(guildID, userID, beforeID int64, actionType, limit int) (st *GuildAuditLog, err error)
- func (s *Session) GuildBanCreate(guildID, userID int64, days int) (err error)
- func (s *Session) GuildBanCreateWithReason(guildID, userID int64, reason string, days int) (err error)
- func (s *Session) GuildBanDelete(guildID, userID int64) (err error)
- func (s *Session) GuildBans(guildID int64) (st []*GuildBan, err error)
- func (s *Session) GuildChannelCreate(guildID int64, name string, ctype ChannelType) (st *Channel, err error)
- func (s *Session) GuildChannelCreateWithOverwrites(guildID int64, name string, ctype ChannelType, parentID int64, ...) (st *Channel, err error)
- func (s *Session) GuildChannels(guildID int64) (st []*Channel, err error)
- func (s *Session) GuildChannelsReorder(guildID int64, channels []*Channel) (err error)
- func (s *Session) GuildCreate(name string) (st *Guild, err error)
- func (s *Session) GuildDelete(guildID int64) (st *Guild, err error)
- func (s *Session) GuildEdit(guildID int64, g GuildParams) (st *Guild, err error)
- func (s *Session) GuildEmbed(guildID int64) (st *GuildEmbed, err error)
- func (s *Session) GuildEmbedEdit(guildID int64, enabled bool, channelID int64) (err error)
- func (s *Session) GuildEmojiCreate(guildID int64, name, image string, roles []int64) (emoji *Emoji, err error)
- func (s *Session) GuildEmojiDelete(guildID, emojiID int64) (err error)
- func (s *Session) GuildEmojiEdit(guildID, emojiID int64, name string, roles []int64) (emoji *Emoji, err error)
- func (s *Session) GuildIcon(guildID int64) (img image.Image, err error)
- func (s *Session) GuildIntegrationCreate(guildID int64, integrationType string, integrationID int64) (err error)
- func (s *Session) GuildIntegrationDelete(guildID, integrationID int64) (err error)
- func (s *Session) GuildIntegrationEdit(guildID, integrationID int64, expireBehavior, expireGracePeriod int, ...) (err error)
- func (s *Session) GuildIntegrationSync(guildID, integrationID int64) (err error)
- func (s *Session) GuildIntegrations(guildID int64) (st []*Integration, err error)
- func (s *Session) GuildInvites(guildID int64) (st []*Invite, err error)
- func (s *Session) GuildLeave(guildID int64) (err error)
- func (s *Session) GuildMember(guildID, userID int64) (st *Member, err error)
- func (s *Session) GuildMemberAdd(accessToken string, guildID, userID int64, nick string, roles []int64, ...) (err error)
- func (s *Session) GuildMemberDelete(guildID, userID int64) (err error)
- func (s *Session) GuildMemberDeleteWithReason(guildID, userID int64, reason string) (err error)
- func (s *Session) GuildMemberEdit(guildID, userID int64, roles []string) (err error)
- func (s *Session) GuildMemberMove(guildID, userID, channelID int64) (err error)
- func (s *Session) GuildMemberNickname(guildID, userID int64, nickname string) (err error)
- func (s *Session) GuildMemberNicknameMe(guildID int64, nickname string) (err error)
- func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID int64) (err error)
- func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID int64) (err error)
- func (s *Session) GuildMembers(guildID int64, after int64, limit int) (st []*Member, err error)
- func (s *Session) GuildPrune(guildID int64, days uint32) (count uint32, err error)
- func (s *Session) GuildPruneCount(guildID int64, days uint32) (count uint32, err error)
- func (s *Session) GuildRoleCreate(guildID int64) (st *Role, err error)
- func (s *Session) GuildRoleDelete(guildID, roleID int64) (err error)
- func (s *Session) GuildRoleEdit(guildID, roleID int64, name string, color int, hoist bool, perm int, ...) (st *Role, err error)
- func (s *Session) GuildRoleReorder(guildID int64, roles []*Role) (st []*Role, err error)
- func (s *Session) GuildRoles(guildID int64) (st []*Role, err error)
- func (s *Session) GuildSplash(guildID int64) (img image.Image, err error)
- func (s *Session) GuildWebhooks(guildID int64) (st []*Webhook, err error)
- func (s *Session) Invite(inviteID string) (st *Invite, err error)
- func (s *Session) InviteAccept(inviteID string) (st *Invite, err error)
- func (s *Session) InviteDelete(inviteID string) (st *Invite, err error)
- func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error)
- func (s *Session) Login(email, password, mfa string) (err error)
- func (s *Session) Logout() (err error)
- func (s *Session) MessageReactionAdd(channelID, messageID int64, emoji string) error
- func (s *Session) MessageReactionRemove(channelID, messageID int64, emoji string, userID int64) error
- func (s *Session) MessageReactionRemoveMe(channelID, messageID int64, emoji string) error
- func (s *Session) MessageReactions(channelID, messageID int64, emoji string, limit int, before, after int64) (st []*User, err error)
- func (s *Session) MessageReactionsRemoveAll(channelID, messageID int64) error
- func (s *Session) Open() error
- func (s *Session) Register(username string) (token string, err error)
- func (s *Session) RelationshipDelete(userID int64) (err error)
- func (s *Session) RelationshipFriendRequestAccept(userID int64) (err error)
- func (s *Session) RelationshipFriendRequestSend(userID int64) (err error)
- func (s *Session) RelationshipUserBlock(userID int64) (err error)
- func (s *Session) RelationshipsGet() (r []*Relationship, err error)
- func (s *Session) RelationshipsMutualGet(userID int64) (mf []*User, err error)
- func (s *Session) Request(method, urlStr string, data interface{}) (response []byte, err error)
- func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, bucketID string) (response []byte, err error)
- func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b []byte, bucket *Bucket) (response []byte, err error)
- func (s *Session) SetNextRequestHeaders(headers OptionalRequestHeaders)
- func (s *Session) TOTP(ticket, code string) (*LoginResponse, error)
- func (s *Session) UpdateListeningStatus(game string) (err error)
- func (s *Session) UpdateStatus(idle int, game string) (err error)
- func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error)
- func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error)
- func (s *Session) User(userID int64) (st *User, err error)
- func (s *Session) UserAvatar(userID int64) (img image.Image, err error)
- func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error)
- func (s *Session) UserChannelCreate(recipientID int64) (st *Channel, err error)
- func (s *Session) UserChannelPermissions(userID, channelID int64) (apermissions int, err error)
- func (s *Session) UserChannels() (st []*Channel, err error)
- func (s *Session) UserConnections() (conn []*UserConnection, err error)
- func (s *Session) UserGuildSettingsEdit(guildID int64, settings *UserGuildSettingsEdit) (st *UserGuildSettings, err error)
- func (s *Session) UserGuilds(limit int, beforeID, afterID int64) (st []*UserGuild, err error)
- func (s *Session) UserMe() (st *User, err error)
- func (s *Session) UserNoteSet(userID int64, message string) (err error)
- func (s *Session) UserSettings() (st *Settings, err error)
- func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error)
- func (s *Session) UserUpdateStatus(status Status) (st *Settings, err error)
- func (s *Session) VoiceICE() (st *VoiceICE, err error)
- func (s *Session) VoiceRegions() (st []*VoiceRegion, err error)
- func (s *Session) Webhook(webhookID int64) (st *Webhook, err error)
- func (s *Session) WebhookCreate(channelID int64, name, avatar string) (st *Webhook, err error)
- func (s *Session) WebhookDelete(webhookID int64) (err error)
- func (s *Session) WebhookDeleteWithToken(webhookID int64, token string) (st *Webhook, err error)
- func (s *Session) WebhookEdit(webhookID int64, name, avatar string, channelID int64) (st *Role, err error)
- func (s *Session) WebhookEditWithToken(webhookID int64, token, name, avatar string) (st *Role, err error)
- func (s *Session) WebhookExecute(webhookID int64, token string, wait bool, data *WebhookParams) (err error)
- func (s *Session) WebhookWithToken(webhookID int64, token string) (st *Webhook, err error)
- type SessionStartLimit
- type Settings
- type State
- func (s *State) Channel(channelID int64) (*Channel, error)
- func (s *State) ChannelAdd(channel *Channel) error
- func (s *State) ChannelRemove(channel *Channel) error
- func (s *State) Emoji(guildID, emojiID int64) (*Emoji, error)
- func (s *State) EmojiAdd(guildID int64, emoji *Emoji) error
- func (s *State) EmojisAdd(guildID int64, emojis []*Emoji) error
- func (s *State) Guild(guildID int64) (*Guild, error)
- func (s *State) GuildAdd(guild *Guild) error
- func (s *State) GuildChannel(guildID, channelID int64) (*Channel, error)
- func (s *State) GuildRemove(guild *Guild) error
- func (s *State) Member(guildID, userID int64) (*Member, error)
- func (s *State) MemberAdd(member *Member) error
- func (s *State) MemberRemove(member *Member) error
- func (s *State) Message(channelID, messageID int64) (*Message, error)
- func (s *State) MessageAdd(message *Message) error
- func (s *State) MessageRemove(message *Message) error
- func (s *State) OnInterface(se *Session, i interface{}) (err error)
- func (s *State) Presence(guildID, userID int64) (*Presence, error)
- func (s *State) PresenceAdd(guildID int64, presence *Presence) error
- func (s *State) PresenceRemove(guildID int64, presence *Presence) error
- func (s *State) PrivateChannel(channelID int64) (*Channel, error)
- func (s *State) Role(guildID, roleID int64) (*Role, error)
- func (s *State) RoleAdd(guildID int64, role *Role) error
- func (s *State) RoleRemove(guildID, roleID int64) error
- func (s *State) UserChannelPermissions(userID, channelID int64) (apermissions int, err error)
- func (s *State) UserColor(userID, channelID int64) int
- type Status
- type StdGatewayIdentifyRatleimiter
- type TOTP
- type TimeStamps
- type Timestamp
- type TooManyRequests
- type TypingStart
- type UpdateStatusData
- type User
- type UserConnection
- type UserGuild
- type UserGuildSettings
- type UserGuildSettingsChannelOverride
- type UserGuildSettingsEdit
- type UserGuildSettingsUpdate
- type UserNoteUpdate
- type UserSettingsUpdate
- type UserUpdate
- type VerificationLevel
- type VoiceConnection
- type VoiceICE
- type VoiceRegion
- type VoiceServerUpdate
- type VoiceSpeakingUpdate
- type VoiceSpeakingUpdateHandler
- type VoiceState
- type VoiceStateUpdate
- type Webhook
- type WebhookParams
- type WebhooksUpdate
Constants ¶
const ( // LogError level is used for critical errors that could lead to data loss // or panic that would not be returned to a calling function. LogError int = iota // LogWarning level is used for very abnormal events and errors that are // also returned to a calling function. LogWarning // LogInformational level is used for normal non-error activity LogInformational // LogDebug level is for very detailed non-error activity. This is // very spammy and will impact performance. LogDebug )
const ( AuditLogActionGuildUpdate = 1 AuditLogActionChannelCreate = 10 AuditLogActionChannelUpdate = 11 AuditLogActionChannelDelete = 12 AuditLogActionChannelOverwriteCreate = 13 AuditLogActionChannelOverwriteUpdate = 14 AuditLogActionChannelOverwriteDelete = 15 AuditLogActionMemberKick = 20 AuditLogActionMemberPrune = 21 AuditLogActionMemberBanAdd = 22 AuditLogActionMemberBanRemove = 23 AuditLogActionMemberUpdate = 24 AuditLogActionMemberRoleUpdate = 25 AuditLogActionRoleCreate = 30 AuditLogActionRoleUpdate = 31 AuditLogActionRoleDelete = 32 AuditLogActionInviteCreate = 40 AuditLogActionInviteUpdate = 41 AuditLogActionInviteDelete = 42 AuditLogActionWebhookCreate = 50 AuditLogActionWebhookUpdate = 51 AuditLogActionWebhookDelete = 52 AuditLogActionEmojiCreate = 60 AuditLogActionEmojiUpdate = 61 AuditLogActionEmojiDelete = 62 AuditLogActionMessageDelete = 72 )
Block contains Discord Audit Log Action Types
const ( PermissionReadMessages = 1 << (iota + 10) PermissionSendMessages PermissionSendTTSMessages PermissionManageMessages PermissionEmbedLinks PermissionAttachFiles PermissionReadMessageHistory PermissionMentionEveryone PermissionUseExternalEmojis )
Constants for the different bit offsets of text channel permissions
const ( PermissionVoiceConnect = 1 << (iota + 20) PermissionVoiceSpeak PermissionVoiceMuteMembers PermissionVoiceDeafenMembers PermissionVoiceMoveMembers PermissionVoiceUseVAD PermissionVoicePrioritySpeaker = 1 << (iota + 2) )
Constants for the different bit offsets of voice permissions
const ( PermissionChangeNickname = 1 << (iota + 26) PermissionManageNicknames PermissionManageRoles PermissionManageWebhooks PermissionManageEmojis )
Constants for general management.
const ( PermissionCreateInstantInvite = 1 << iota PermissionKickMembers PermissionBanMembers PermissionAdministrator PermissionManageChannels PermissionManageServer PermissionAddReactions PermissionViewAuditLogs PermissionAllText = PermissionReadMessages | PermissionSendMessages | PermissionSendTTSMessages | PermissionManageMessages | PermissionEmbedLinks | PermissionAttachFiles | PermissionReadMessageHistory | PermissionMentionEveryone PermissionAllVoice = PermissionVoiceConnect | PermissionVoiceSpeak | PermissionVoiceMuteMembers | PermissionVoiceDeafenMembers | PermissionVoiceMoveMembers | PermissionVoiceUseVAD | PermissionVoicePrioritySpeaker PermissionAllChannel = PermissionAllText | PermissionAllVoice | PermissionCreateInstantInvite | PermissionManageRoles | PermissionManageChannels | PermissionAddReactions | PermissionViewAuditLogs | PermissionManageWebhooks PermissionAll = PermissionAllChannel | PermissionKickMembers | PermissionBanMembers | PermissionManageServer | PermissionAdministrator | PermissionManageNicknames | PermissionManageEmojis )
Constants for the different bit offsets of general permissions
const ( ErrCodeUnknownAccount = 10001 ErrCodeUnknownApplication = 10002 ErrCodeUnknownChannel = 10003 ErrCodeUnknownGuild = 10004 ErrCodeUnknownIntegration = 10005 ErrCodeUnknownInvite = 10006 ErrCodeUnknownMember = 10007 ErrCodeUnknownMessage = 10008 ErrCodeUnknownOverwrite = 10009 ErrCodeUnknownProvider = 10010 ErrCodeUnknownRole = 10011 ErrCodeUnknownToken = 10012 ErrCodeUnknownUser = 10013 ErrCodeUnknownEmoji = 10014 ErrCodeUnknownWebhook = 10015 ErrCodeBotsCannotUseEndpoint = 20001 ErrCodeOnlyBotsCanUseEndpoint = 20002 ErrCodeMaximumGuildsReached = 30001 ErrCodeMaximumFriendsReached = 30002 ErrCodeMaximumPinsReached = 30003 ErrCodeMaximumGuildRolesReached = 30005 ErrCodeTooManyReactions = 30010 ErrCodeMissingAccess = 50001 ErrCodeInvalidAccountType = 50002 ErrCodeCannotExecuteActionOnDMChannel = 50003 ErrCodeEmbedCisabled = 50004 ErrCodeCannotEditFromAnotherUser = 50005 ErrCodeCannotSendEmptyMessage = 50006 ErrCodeCannotSendMessagesToThisUser = 50007 ErrCodeCannotSendMessagesInVoiceChannel = 50008 ErrCodeChannelVerificationLevelTooHigh = 50009 ErrCodeOAuth2ApplicationDoesNotHaveBot = 50010 ErrCodeOAuth2ApplicationLimitReached = 50011 ErrCodeInvalidOAuthState = 50012 ErrCodeMissingPermissions = 50013 ErrCodeInvalidAuthenticationToken = 50014 ErrCodeNoteTooLong = 50015 ErrCodeTooFewOrTooManyMessagesToDelete = 50016 ErrCodeCanOnlyPinMessageToOriginatingChannel = 50019 ErrCodeCannotExecuteActionOnSystemMessage = 50021 ErrCodeMessageProvidedTooOldForBulkDelete = 50034 ErrCodeInvalidFormBody = 50035 ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036 ErrCodeReactionBlocked = 90001 )
Block contains Discord JSON Error Response codes
const MaxIntermediaryBuffersSize = 100000
max size of buffers before they're discarded (e.g after a big incmoing event)
const VERSION = "1.0.3"
VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/)
Variables ¶
var ( EndpointStatus = "https://status.discordapp.com/api/v2/" EndpointSm = EndpointStatus + "scheduled-maintenances/" EndpointSmActive = EndpointSm + "active.json" EndpointSmUpcoming = EndpointSm + "upcoming.json" EndpointDiscord = "https://discordapp.com/" EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/" EndpointGuilds = EndpointAPI + "guilds/" EndpointChannels = EndpointAPI + "channels/" EndpointUsers = EndpointAPI + "users/" EndpointGateway = EndpointAPI + "gateway" EndpointGatewayBot = EndpointGateway + "/bot" EndpointWebhooks = EndpointAPI + "webhooks/" EndpointCDN = "https://cdn.discordapp.com/" EndpointCDNAttachments = EndpointCDN + "attachments/" EndpointCDNAvatars = EndpointCDN + "avatars/" EndpointCDNIcons = EndpointCDN + "icons/" EndpointCDNSplashes = EndpointCDN + "splashes/" EndpointCDNChannelIcons = EndpointCDN + "channel-icons/" EndpointAuth = EndpointAPI + "auth/" EndpointTOTP = EndpointAuth + "mfa/totp" EndpointLogin = EndpointAuth + "login" EndpointLogout = EndpointAuth + "logout" EndpointVerify = EndpointAuth + "verify" EndpointVerifyResend = EndpointAuth + "verify/resend" EndpointForgotPassword = EndpointAuth + "forgot" EndpointResetPassword = EndpointAuth + "reset" EndpointRegister = EndpointAuth + "register" EndpointVoice = EndpointAPI + "/voice/" EndpointVoiceRegions = EndpointVoice + "regions" EndpointVoiceIce = EndpointVoice + "ice" EndpointTutorial = EndpointAPI + "tutorial/" EndpointTutorialIndicators = EndpointTutorial + "indicators" EndpointTrack = EndpointAPI + "track" EndpointSso = EndpointAPI + "sso" EndpointReport = EndpointAPI + "report" EndpointIntegrations = EndpointAPI + "integrations" EndpointUser = func(uID string) string { return EndpointUsers + uID } EndpointUserAvatar = func(uID int64, aID string) string { return EndpointCDNAvatars + StrID(uID) + "/" + aID + ".png" } EndpointUserAvatarAnimated = func(uID int64, aID string) string { return EndpointCDNAvatars + StrID(uID) + "/" + aID + ".gif" } EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" } EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" } EndpointUserGuild = func(uID string, gID int64) string { return EndpointUsers + uID + "/guilds/" + StrID(gID) } EndpointUserGuildSettings = func(uID string, gID int64) string { return EndpointUsers + uID + "/guilds/" + StrID(gID) + "/settings" } EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" } EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" } EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" } EndpointUserNotes = func(uID int64) string { return EndpointUsers + "@me/notes/" + StrID(uID) } EndpointGuild = func(gID int64) string { return EndpointGuilds + StrID(gID) } EndpointGuildChannels = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/channels" } EndpointGuildMembers = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/members" } EndpointGuildMember = func(gID int64, uID int64) string { return EndpointGuilds + StrID(gID) + "/members/" + StrID(uID) } EndpointGuildMemberMe = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/members/@me" } EndpointGuildMemberRole = func(gID, uID, rID int64) string { return EndpointGuilds + StrID(gID) + "/members/" + StrID(uID) + "/roles/" + StrID(rID) } EndpointGuildBans = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/bans" } EndpointGuildBan = func(gID, uID int64) string { return EndpointGuilds + StrID(gID) + "/bans/" + StrID(uID) } EndpointGuildIntegrations = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/integrations" } EndpointGuildIntegration = func(gID, iID int64) string { return EndpointGuilds + StrID(gID) + "/integrations/" + StrID(iID) } EndpointGuildIntegrationSync = func(gID, iID int64) string { return EndpointGuilds + StrID(gID) + "/integrations/" + StrID(iID) + "/sync" } EndpointGuildRoles = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/roles" } EndpointGuildRole = func(gID, rID int64) string { return EndpointGuilds + StrID(gID) + "/roles/" + StrID(rID) } EndpointGuildInvites = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/invites" } EndpointGuildEmbed = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/embed" } EndpointGuildPrune = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/prune" } EndpointGuildIcon = func(gID int64, hash string) string { return EndpointCDNIcons + StrID(gID) + "/" + hash + ".png" } EndpointGuildSplash = func(gID int64, hash string) string { return EndpointCDNSplashes + StrID(gID) + "/" + hash + ".png" } EndpointGuildWebhooks = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/webhooks" } EndpointGuildAuditLogs = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/audit-logs" } EndpointGuildEmojis = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/emojis" } EndpointGuildEmoji = func(gID, eID int64) string { return EndpointGuilds + StrID(gID) + "/emojis/" + StrID(eID) } EndpointChannel = func(cID int64) string { return EndpointChannels + StrID(cID) } EndpointChannelPermissions = func(cID int64) string { return EndpointChannels + StrID(cID) + "/permissions" } EndpointChannelPermission = func(cID, tID int64) string { return EndpointChannels + StrID(cID) + "/permissions/" + StrID(tID) } EndpointChannelInvites = func(cID int64) string { return EndpointChannels + StrID(cID) + "/invites" } EndpointChannelTyping = func(cID int64) string { return EndpointChannels + StrID(cID) + "/typing" } EndpointChannelMessages = func(cID int64) string { return EndpointChannels + StrID(cID) + "/messages" } EndpointChannelMessage = func(cID, mID int64) string { return EndpointChannels + StrID(cID) + "/messages/" + StrID(mID) } EndpointChannelMessageAck = func(cID, mID int64) string { return EndpointChannels + StrID(cID) + "/messages/" + StrID(mID) + "/ack" } EndpointChannelMessagesBulkDelete = func(cID int64) string { return EndpointChannel(cID) + "/messages/bulk-delete" } EndpointChannelMessagesPins = func(cID int64) string { return EndpointChannel(cID) + "/pins" } EndpointChannelMessagePin = func(cID, mID int64) string { return EndpointChannel(cID) + "/pins/" + StrID(mID) } EndpointGroupIcon = func(cID int64, hash string) string { return EndpointCDNChannelIcons + StrID(cID) + "/" + hash + ".png" } EndpointChannelWebhooks = func(cID int64) string { return EndpointChannel(cID) + "/webhooks" } EndpointWebhook = func(wID int64) string { return EndpointWebhooks + StrID(wID) } EndpointWebhookToken = func(wID int64, token string) string { return EndpointWebhooks + StrID(wID) + "/" + token } EndpointDefaultUserAvatar = func(uDiscriminator string) string { uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator) return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png" } EndpointMessageReactionsAll = func(cID, mID int64) string { return EndpointChannelMessage(cID, mID) + "/reactions" } EndpointMessageReactions = func(cID, mID int64, emoji EmojiName) string { return EndpointChannelMessage(cID, mID) + "/reactions/" + emoji.String() } EndpointMessageReaction = func(cID, mID int64, emoji EmojiName, uID string) string { return EndpointMessageReactions(cID, mID, emoji) + "/" + uID } EndpointRelationships = func() string { return EndpointUsers + "@me" + "/relationships" } EndpointRelationship = func(uID int64) string { return EndpointRelationships() + "/" + StrID(uID) } EndpointRelationshipsMutual = func(uID int64) string { return EndpointUsers + StrID(uID) + "/relationships" } EndpointGuildCreate = EndpointAPI + "guilds" EndpointInvite = func(iID string) string { return EndpointAPI + "invite/" + iID } EndpointIntegrationsJoin = func(iID string) string { return EndpointAPI + "integrations/" + iID + "/join" } EndpointEmoji = func(eID int64) string { return EndpointAPI + "emojis/" + StrID(eID) + ".png" } EndpointEmojiAnimated = func(eID int64) string { return EndpointAPI + "emojis/" + StrID(eID) + ".gif" } EndpointOauth2 = EndpointAPI + "oauth2/" EndpointApplications = EndpointOauth2 + "applications" EndpointApplication = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) } EndpointApplicationsBot = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) + "/bot" } EndpointApplicationAssets = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) + "/assets" } )
Known Discord API Endpoints.
var ( ErrJSONUnmarshal = errors.New("json unmarshal") ErrStatusOffline = errors.New("You can't set your Status to offline") ErrVerificationLevelBounds = errors.New("VerificationLevel out of bounds, should be between 0 and 3") ErrPruneDaysBounds = errors.New("the number of days should be more than or equal to 1") ErrGuildNoIcon = errors.New("guild does not have an icon set") ErrGuildNoSplash = errors.New("guild does not have a splash set") )
All error constants
var APIVersion = "6"
APIVersion is the Discord API version used for the REST and Websocket API.
var (
ErrAlreadyOpen = errors.New("Connection already open")
)
var ErrFailedToken = errors.New("Unable to fetch discord authentication token")
var ErrMFA = errors.New("account has 2FA enabled, try calling Login")
ErrMFA will be risen by New when the user has 2FA.
var ErrNilState = errors.New("state not instantiated, please use discordgo.New() or assign Session.State")
ErrNilState is returned when the state is nil.
var ErrStateNotFound = errors.New("state cache not found")
ErrStateNotFound is returned when the state cache requested is not found
var ErrTimeoutWaitingForVoice = errors.New("timeout waiting for voice")
var Logger func(msgL, caller int, format string, a ...interface{})
Logger can be used to replace the standard logging for discordgo
Functions ¶
func CheckRetry ¶ added in v1.0.4
func GetEventInterface ¶ added in v1.0.4
func GetEventInterface(evtType string) interface{}
func MemberPermissions ¶ added in v1.2.0
Calculates the permissions for a member. https://support.discordapp.com/hc/en-us/articles/206141927-How-is-the-permission-hierarchy-structured-
func SnowflakeTimestamp ¶ added in v1.2.0
SnowflakeTimestamp returns the creation time of a Snowflake ID relative to the creation of Discord.
Types ¶
type APIErrorMessage ¶ added in v1.0.4
An APIErrorMessage is an api error message returned from discord
type Ack ¶ added in v1.0.4
type Ack struct {
Token string `json:"token"`
}
An Ack is used to ack messages
type Application ¶ added in v0.12.0
type Application struct { ID int64 `json:"id,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Icon string `json:"icon,omitempty"` Secret string `json:"secret,omitempty"` RedirectURIs *[]string `json:"redirect_uris,omitempty"` BotRequireCodeGrant bool `json:"bot_require_code_grant,omitempty"` BotPublic bool `json:"bot_public,omitempty"` RPCApplicationState int `json:"rpc_application_state,omitempty"` Flags int `json:"flags,omitempty"` Owner *User `json:"owner"` Bot *User `json:"bot"` }
An Application struct stores values for a Discord OAuth2 Application
type Assets ¶ added in v1.0.4
type Assets struct { LargeImageID string `json:"large_image,omitempty"` SmallImageID string `json:"small_image,omitempty"` LargeText string `json:"large_text,omitempty"` SmallText string `json:"small_text,omitempty"` }
An Assets struct contains assets and labels used in the rich presence "playing .." Game
type AuditLogEntry ¶ added in v1.0.4
type AuditLogEntry struct { TargetID int64 `json:"target_id,string"` Changes []struct { NewValue interface{} `json:"new_value"` OldValue interface{} `json:"old_value"` Key string `json:"key"` } `json:"changes,omitempty"` UserID int64 `json:"user_id,string"` ID int64 `json:"id,string"` ActionType int `json:"action_type"` Options struct { DeleteMembersDay string `json:"delete_member_days"` MembersRemoved string `json:"members_removed"` ChannelID int64 `json:"channel_id,string"` Count string `json:"count"` ID int64 `json:"id,string"` Type string `json:"type"` RoleName string `json:"role_name"` } `json:"options,omitempty"` Reason string `json:"reason"` }
type Bucket ¶ added in v1.0.4
type Bucket struct { sync.Mutex Key string Remaining int Userdata interface{} // contains filtered or unexported fields }
Bucket represents a ratelimit bucket, each bucket gets ratelimited individually (-global ratelimits)
type Channel ¶
type Channel struct { // The ID of the channel. ID int64 `json:"id,string"` // The ID of the guild to which the channel belongs, if it is in a guild. // Else, this ID is empty (e.g. DM channels). GuildID int64 `json:"guild_id,string"` // The name of the channel. Name string `json:"name"` // The topic of the channel. Topic string `json:"topic"` // The type of the channel. Type ChannelType `json:"type"` // The ID of the last message sent in the channel. This is not // guaranteed to be an ID of a valid message. LastMessageID int64 `json:"last_message_id,string"` // Whether the channel is marked as NSFW. NSFW bool `json:"nsfw"` // Icon of the group DM channel. Icon string `json:"icon"` // The position of the channel, used for sorting in client. Position int `json:"position"` // The bitrate of the channel, if it is a voice channel. Bitrate int `json:"bitrate"` // The recipients of the channel. This is only populated in DM channels. Recipients []*User `json:"recipients"` // The messages in the channel. This is only present in state-cached channels, // and State.MaxMessageCount must be non-zero. Messages []*Message `json:"-"` // A list of permission overwrites present for the channel. PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"` // The user limit of the voice channel. UserLimit int `json:"user_limit"` // The ID of the parent channel, if the channel is under a category ParentID int64 `json:"parent_id,string"` }
A Channel holds all data related to an individual Discord channel.
func (*Channel) GetChannelID ¶ added in v1.2.0
func (*Channel) GetGuildID ¶ added in v1.2.0
type ChannelCreate ¶ added in v0.11.0
type ChannelCreate struct {
*Channel
}
ChannelCreate is the data for a ChannelCreate event.
type ChannelDelete ¶ added in v0.11.0
type ChannelDelete struct {
*Channel
}
ChannelDelete is the data for a ChannelDelete event.
type ChannelEdit ¶ added in v1.0.4
type ChannelEdit struct { Name string `json:"name,omitempty"` Topic string `json:"topic,omitempty"` NSFW bool `json:"nsfw,omitempty"` Position *int `json:"position,omitempty"` Bitrate int `json:"bitrate,omitempty"` UserLimit int `json:"user_limit,omitempty"` PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"` ParentID string `json:"parent_id,omitempty"` }
A ChannelEdit holds Channel Feild data for a channel edit.
type ChannelEvent ¶ added in v1.2.0
type ChannelEvent interface {
GetChannelID() int64
}
type ChannelPinsUpdate ¶ added in v1.0.4
type ChannelPinsUpdate struct { LastPinTimestamp string `json:"last_pin_timestamp"` ChannelID int64 `json:"channel_id,string"` GuildID int64 `json:"guild_id,string,omitempty"` }
ChannelPinsUpdate stores data for a ChannelPinsUpdate event.
func (*ChannelPinsUpdate) GetChannelID ¶ added in v1.2.0
func (cp *ChannelPinsUpdate) GetChannelID() int64
func (*ChannelPinsUpdate) GetGuildID ¶ added in v1.2.0
func (cp *ChannelPinsUpdate) GetGuildID() int64
type ChannelType ¶ added in v1.0.4
type ChannelType int
ChannelType is the type of a Channel
const ( ChannelTypeGuildText ChannelType = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory )
Block contains known ChannelType values
type ChannelUpdate ¶ added in v0.11.0
type ChannelUpdate struct {
*Channel
}
ChannelUpdate is the data for a ChannelUpdate event.
type Connect ¶ added in v0.11.0
type Connect struct{}
Connect is the data for a Connect event. This is a sythetic event and is not dispatched by Discord.
type Disconnect ¶ added in v0.11.0
type Disconnect struct{}
Disconnect is the data for a Disconnect event. This is a sythetic event and is not dispatched by Discord.
type DiscordFloat ¶ added in v1.0.4
type DiscordFloat float64
Discord is super inconsistent with with types in some places (especially presence updates, might aswell change them to map[string]interface{} soon because there is 0 validation)
func (*DiscordFloat) UnmarshalJSON ¶ added in v1.0.4
func (df *DiscordFloat) UnmarshalJSON(data []byte) error
type DiscordInt64 ¶ added in v1.0.4
type DiscordInt64 int64
func (*DiscordInt64) UnmarshalJSON ¶ added in v1.0.4
func (di *DiscordInt64) UnmarshalJSON(data []byte) error
type Emoji ¶ added in v0.8.0
type Emoji struct { ID int64 `json:"id,string"` Name string `json:"name"` Roles IDSlice `json:"roles,string"` Managed bool `json:"managed"` RequireColons bool `json:"require_colons"` Animated bool `json:"animated"` }
Emoji struct holds data related to Emoji's
func (*Emoji) APIName ¶ added in v1.0.4
APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
func (*Emoji) MessageFormat ¶ added in v1.0.4
MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
type EmojiName ¶ added in v1.0.4
type EmojiName struct {
// contains filtered or unexported fields
}
type Event ¶
type Event struct { Operation GatewayOP `json:"op"` Sequence int64 `json:"s"` Type string `json:"t"` RawData gojay.EmbeddedJSON `json:"d"` // Struct contains one of the other types in this file. Struct interface{} `json:"-"` }
Event provides a basic initial struct for all websocket events.
type EventHandler ¶ added in v1.0.4
type EventHandler interface { // Type returns the type of event this handler belongs to. Type() string // Handle is called whenever an event of Type() happens. // It is the receivers responsibility to type assert that the interface // is the expected struct. Handle(*Session, interface{}) }
EventHandler is an interface for Discord events.
type EventInterfaceProvider ¶ added in v1.0.4
type EventInterfaceProvider interface { // Type is the type of event this handler belongs to. Type() string // New returns a new instance of the struct this event handler handles. // This is called once per event. // The struct is provided to all handlers of the same Type(). New() interface{} }
EventInterfaceProvider is an interface for providing empty interfaces for Discord events.
type ExplicitContentFilterLevel ¶ added in v1.0.4
type ExplicitContentFilterLevel int
ExplicitContentFilterLevel type definition
const ( ExplicitContentFilterDisabled ExplicitContentFilterLevel = iota ExplicitContentFilterMembersWithoutRoles ExplicitContentFilterAllMembers )
Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive
type FriendSourceFlags ¶ added in v1.0.4
type FriendSourceFlags struct { All bool `json:"all"` MutualGuilds bool `json:"mutual_guilds"` MutualFriends bool `json:"mutual_friends"` }
FriendSourceFlags stores ... TODO :)
type Game ¶ added in v0.7.0
type Game struct { Name string `json:"name"` Type GameType `json:"type"` URL string `json:"url,omitempty"` Details string `json:"details,omitempty"` State string `json:"state,omitempty"` TimeStamps TimeStamps `json:"timestamps,omitempty"` Assets Assets `json:"assets,omitempty"` ApplicationID string `json:"application_id,omitempty"` Instance int8 `json:"instance,omitempty"` }
A Game struct holds the name of the "playing .." game for a user
type GameType ¶ added in v1.0.4
type GameType int
GameType is the type of "game" (see GameType* consts) in the Game struct
type GatewayBotResponse ¶ added in v1.0.4
type GatewayBotResponse struct { URL string `json:"url"` Shards int `json:"shards"` SessionStartLimit SessionStartLimit `json:"session_start_limit"` }
GatewayBotResponse stores the data for the gateway/bot response
type GatewayConnection ¶ added in v1.0.4
type GatewayConnection struct {
// contains filtered or unexported fields
}
func NewGatewayConnection ¶ added in v1.0.4
func NewGatewayConnection(parent *GatewayConnectionManager, id int) *GatewayConnection
func (*GatewayConnection) Close ¶ added in v1.0.4
func (g *GatewayConnection) Close() error
Close closes the gateway connection
func (*GatewayConnection) Reconnect ¶ added in v1.0.4
func (g *GatewayConnection) Reconnect(forceReIdentify bool) error
Reconnect is a helper for Close() and Connect() and will attempt to resume if possible
func (*GatewayConnection) ReconnectUnlessClosed ¶ added in v1.0.4
func (g *GatewayConnection) ReconnectUnlessClosed(forceReIdentify bool) error
ReconnectUnlessStopped will not reconnect if close was called earlier
func (*GatewayConnection) RequestGuildMembers ¶ added in v1.0.4
func (g *GatewayConnection) RequestGuildMembers(guildID int64, query string, limit int)
func (*GatewayConnection) Status ¶ added in v1.0.4
func (g *GatewayConnection) Status() (st GatewayStatus)
Status returns the current status of the connection
func (*GatewayConnection) SubscribeGuild ¶ added in v1.0.4
func (g *GatewayConnection) SubscribeGuild(guildID int64, typing, activities bool)
func (*GatewayConnection) UpdateStatusComplex ¶ added in v1.0.4
func (g *GatewayConnection) UpdateStatusComplex(usd UpdateStatusData)
UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
type GatewayConnectionManager ¶ added in v1.0.4
type GatewayConnectionManager struct {
// contains filtered or unexported fields
}
GatewayConnectionManager is responsible for managing the gateway connections for a single shard We create a new GatewayConnection every time we reconnect to avoid a lot of synchronization needs and also to avoid having to manually reset the connection state, all the workers related to the old connection should eventually stop, and if they're late they will be working on a closed connection anyways so it dosen't matter
func (*GatewayConnectionManager) ChannelVoiceJoin ¶ added in v1.0.4
func (g *GatewayConnectionManager) ChannelVoiceJoin(gID, cID int64, mute, deaf bool) (voice *VoiceConnection, err error)
ChannelVoiceJoin joins the session user to a voice channel.
gID : Guild ID of the channel to join. cID : Channel ID of the channel to join. mute : If true, you will be set to muted upon joining. deaf : If true, you will be set to deafened upon joining.
func (*GatewayConnectionManager) ChannelVoiceLeave ¶ added in v1.0.4
func (g *GatewayConnectionManager) ChannelVoiceLeave(gID int64)
func (*GatewayConnectionManager) Close ¶ added in v1.0.4
func (g *GatewayConnectionManager) Close() (err error)
func (*GatewayConnectionManager) GetSessionInfo ¶ added in v1.0.4
func (s *GatewayConnectionManager) GetSessionInfo() (sessionID string, sequence int64)
func (*GatewayConnectionManager) HeartBeatStats ¶ added in v1.0.4
func (g *GatewayConnectionManager) HeartBeatStats() (lastSend time.Time, lastAck time.Time)
func (*GatewayConnectionManager) Open ¶ added in v1.0.4
func (g *GatewayConnectionManager) Open() error
func (*GatewayConnectionManager) Reconnect ¶ added in v1.0.4
func (g *GatewayConnectionManager) Reconnect(forceIdentify bool) error
func (*GatewayConnectionManager) RequestGuildMembers ¶ added in v1.0.4
func (g *GatewayConnectionManager) RequestGuildMembers(guildID int64, query string, limit int)
func (*GatewayConnectionManager) SetSessionInfo ¶ added in v1.0.4
func (s *GatewayConnectionManager) SetSessionInfo(sessionID string, sequence int64)
func (*GatewayConnectionManager) Status ¶ added in v1.0.4
func (g *GatewayConnectionManager) Status() GatewayStatus
Status returns the status of the current active connection
func (*GatewayConnectionManager) SubscribeGuild ¶ added in v1.0.4
func (g *GatewayConnectionManager) SubscribeGuild(guildID int64, typing, activities bool)
type GatewayIdentifyRatelimiter ¶ added in v1.0.4
type GatewayIdentifyRatelimiter interface {
RatelimitIdentify() // Called whenever an attempted identify is made, can be called from multiple goroutines at the same time
}
GatewayIdentifyRatelimiter is if you need some custom identify ratelimit logic (if you're running shards across processes for example)
var IdentifyRatelimiter GatewayIdentifyRatelimiter = &StdGatewayIdentifyRatleimiter{}
This is used at the package level because it can be used by multiple sessions !! Changing this after starting 1 or more gateway sessions will lead to undefined behaviour
type GatewayOP ¶ added in v1.0.4
type GatewayOP int
GatewayOP represents a gateway operation see https://discordapp.com/developers/docs/topics/gateway#gateway-opcodespayloads-gateway-opcodes
const ( GatewayOPDispatch GatewayOP = iota // (Receive) GatewayOPHeartbeat // (Send/Receive) GatewayOPIdentify // (Send) GatewayOPStatusUpdate // (Send) GatewayOPVoiceStateUpdate // (Send) GatewayOPVoiceServerPing // (Send) GatewayOPResume // (Send) GatewayOPReconnect // (Receive) GatewayOPRequestGuildMembers // (Send) GatewayOPInvalidSession // (Receive) GatewayOPHello // (Receive) GatewayOPHeartbeatACK // (Receive) )
type GatewayStatus ¶ added in v1.0.4
type GatewayStatus int
const ( GatewayStatusDisconnected GatewayStatus = iota GatewayStatusConnecting GatewayStatusIdentifying GatewayStatusResuming GatewayStatusReady )
func (GatewayStatus) String ¶ added in v1.0.4
func (gs GatewayStatus) String() string
type Guild ¶
type Guild struct { // The ID of the guild. ID int64 `json:"id,string"` // The name of the guild. (2–100 characters) Name string `json:"name"` // The hash of the guild's icon. Use Session.GuildIcon // to retrieve the icon itself. Icon string `json:"icon"` // The voice region of the guild. Region string `json:"region"` // The ID of the AFK voice channel. AfkChannelID int64 `json:"afk_channel_id,string"` // The ID of the embed channel ID, used for embed widgets. EmbedChannelID int64 `json:"embed_channel_id,string"` // The user ID of the owner of the guild. OwnerID int64 `json:"owner_id,string"` // The time at which the current user joined the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. JoinedAt Timestamp `json:"joined_at"` // The hash of the guild's splash. Splash string `json:"splash"` // The timeout, in seconds, before a user is considered AFK in voice. AfkTimeout int `json:"afk_timeout"` // The number of members in the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. MemberCount int `json:"member_count"` // The verification level required for the guild. VerificationLevel VerificationLevel `json:"verification_level"` // Whether the guild has embedding enabled. EmbedEnabled bool `json:"embed_enabled"` // Whether the guild is considered large. This is // determined by a member threshold in the identify packet, // and is currently hard-coded at 250 members in the library. Large bool `json:"large"` // The default message notification setting for the guild. // 0 == all messages, 1 == mentions only. DefaultMessageNotifications int `json:"default_message_notifications"` // A list of roles in the guild. Roles []*Role `json:"roles"` // A list of the custom emojis present in the guild. Emojis []*Emoji `json:"emojis"` // A list of the members in the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. Members []*Member `json:"members"` // A list of partial presence objects for members in the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. Presences []*Presence `json:"presences"` // A list of channels in the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. Channels []*Channel `json:"channels"` // A list of voice states for the guild. // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. VoiceStates []*VoiceState `json:"voice_states"` // This field is only present in GUILD_CREATE events and websocket // update events, and thus is only present in state-cached guilds. Unavailable bool `json:"unavailable"` // The explicit content filter level ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"` // The list of enabled guild features Features []string `json:"features"` // Required MFA level for the guild MfaLevel MfaLevel `json:"mfa_level"` // Whether or not the Server Widget is enabled WidgetEnabled bool `json:"widget_enabled"` // The Channel ID for the Server Widget WidgetChannelID string `json:"widget_channel_id"` // The Channel ID to which system messages are sent (eg join and leave messages) SystemChannelID string `json:"system_channel_id"` }
A Guild holds all data related to a specific Discord Guild. Guilds are also sometimes referred to as Servers in the Discord client.
func (*Guild) GetGuildID ¶ added in v1.2.0
type GuildAuditLog ¶ added in v1.0.4
type GuildAuditLog struct { Webhooks []struct { ChannelID int64 `json:"channel_id,string"` GuildID int64 `json:"guild_id,string"` ID string `json:"id"` Avatar string `json:"avatar"` Name string `json:"name"` } `json:"webhooks,omitempty"` Users []*User `json:"users,omitempty"` AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"` }
A GuildAuditLog stores data for a guild audit log.
type GuildBanAdd ¶ added in v0.11.0
GuildBanAdd is the data for a GuildBanAdd event.
func (*GuildBanAdd) GetGuildID ¶ added in v1.2.0
func (gba *GuildBanAdd) GetGuildID() int64
type GuildBanRemove ¶ added in v0.11.0
GuildBanRemove is the data for a GuildBanRemove event.
func (*GuildBanRemove) GetGuildID ¶ added in v1.2.0
func (e *GuildBanRemove) GetGuildID() int64
type GuildCreate ¶ added in v0.11.0
type GuildCreate struct {
*Guild
}
GuildCreate is the data for a GuildCreate event.
type GuildDelete ¶ added in v0.11.0
type GuildDelete struct {
*Guild
}
GuildDelete is the data for a GuildDelete event.
type GuildEmbed ¶ added in v1.0.4
A GuildEmbed stores data for a guild embed.
type GuildEmojisUpdate ¶ added in v0.8.0
type GuildEmojisUpdate struct { GuildID int64 `json:"guild_id,string"` Emojis []*Emoji `json:"emojis"` }
A GuildEmojisUpdate is the data for a guild emoji update event.
func (*GuildEmojisUpdate) GetGuildID ¶ added in v1.2.0
func (e *GuildEmojisUpdate) GetGuildID() int64
type GuildEvent ¶ added in v1.2.0
type GuildEvent interface {
GetGuildID() int64
}
type GuildIntegrationsUpdate ¶
type GuildIntegrationsUpdate struct {
GuildID int64 `json:"guild_id,string"`
}
GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event.
func (*GuildIntegrationsUpdate) GetGuildID ¶ added in v1.2.0
func (e *GuildIntegrationsUpdate) GetGuildID() int64
type GuildMemberAdd ¶ added in v0.11.0
type GuildMemberAdd struct {
*Member
}
GuildMemberAdd is the data for a GuildMemberAdd event.
type GuildMemberRemove ¶ added in v0.11.0
type GuildMemberRemove struct {
*Member
}
GuildMemberRemove is the data for a GuildMemberRemove event.
type GuildMemberUpdate ¶ added in v0.11.0
type GuildMemberUpdate struct {
*Member
}
GuildMemberUpdate is the data for a GuildMemberUpdate event.
type GuildMembersChunk ¶ added in v1.0.4
type GuildMembersChunk struct { GuildID int64 `json:"guild_id,string"` Members []*Member `json:"members"` }
A GuildMembersChunk is the data for a GuildMembersChunk event.
func (*GuildMembersChunk) GetGuildID ¶ added in v1.2.0
func (e *GuildMembersChunk) GetGuildID() int64
type GuildParams ¶ added in v0.12.0
type GuildParams struct { Name string `json:"name,omitempty"` Region string `json:"region,omitempty"` VerificationLevel *VerificationLevel `json:"verification_level,omitempty"` DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type? AfkChannelID int64 `json:"afk_channel_id,omitempty,string"` AfkTimeout int `json:"afk_timeout,omitempty"` Icon string `json:"icon,omitempty"` OwnerID int64 `json:"owner_id,omitempty,string"` Splash string `json:"splash,omitempty"` }
A GuildParams stores all the data needed to update discord guild settings
type GuildRole ¶
A GuildRole stores data for guild roles.
func (*GuildRole) GetGuildID ¶ added in v1.2.0
type GuildRoleCreate ¶ added in v0.11.0
type GuildRoleCreate struct {
*GuildRole
}
GuildRoleCreate is the data for a GuildRoleCreate event.
type GuildRoleDelete ¶
type GuildRoleDelete struct { RoleID int64 `json:"role_id,string"` GuildID int64 `json:"guild_id,string"` }
A GuildRoleDelete is the data for a GuildRoleDelete event.
func (*GuildRoleDelete) GetGuildID ¶ added in v1.2.0
func (e *GuildRoleDelete) GetGuildID() int64
type GuildRoleUpdate ¶ added in v0.11.0
type GuildRoleUpdate struct {
*GuildRole
}
GuildRoleUpdate is the data for a GuildRoleUpdate event.
type GuildUpdate ¶ added in v0.11.0
type GuildUpdate struct {
*Guild
}
GuildUpdate is the data for a GuildUpdate event.
type ICEServer ¶
type ICEServer struct { URL string `json:"url"` Username string `json:"username"` Credential string `json:"credential"` }
A ICEServer stores data for a specific voice ICE server.
type IDSlice ¶ added in v1.0.4
type IDSlice []int64
IDSlice Is a slice of snowflake id's that properly marshals and unmarshals the way discord expects them to They unmarshal from string arrays and marshals back to string arrays
func (IDSlice) MarshalJSON ¶ added in v1.0.4
func (*IDSlice) UnmarshalJSON ¶ added in v1.0.4
type Integration ¶ added in v1.0.4
type Integration struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` Enabled bool `json:"enabled"` Syncing bool `json:"syncing"` RoleID string `json:"role_id"` ExpireBehavior int `json:"expire_behavior"` ExpireGracePeriod int `json:"expire_grace_period"` User *User `json:"user"` Account IntegrationAccount `json:"account"` SyncedAt Timestamp `json:"synced_at"` }
Integration stores integration information
type IntegrationAccount ¶ added in v1.0.4
IntegrationAccount is integration account information sent by the UserConnections endpoint
type Invite ¶
type Invite struct { Guild *Guild `json:"guild"` Channel *Channel `json:"channel"` Inviter *User `json:"inviter"` Code string `json:"code"` CreatedAt Timestamp `json:"created_at"` MaxAge int `json:"max_age"` Uses int `json:"uses"` MaxUses int `json:"max_uses"` Revoked bool `json:"revoked"` Temporary bool `json:"temporary"` Unique bool `json:"unique"` // will only be filled when using InviteWithCounts ApproximatePresenceCount int `json:"approximate_presence_count"` ApproximateMemberCount int `json:"approximate_member_count"` }
A Invite stores all data related to a specific Discord Guild or Channel invite.
type LoginResponse ¶ added in v1.2.0
type Member ¶
type Member struct { // The guild ID on which the member exists. GuildID int64 `json:"guild_id,string"` // The time at which the member joined the guild, in ISO8601. JoinedAt Timestamp `json:"joined_at"` // The nickname of the member, if they have one. Nick string `json:"nick"` // Whether the member is deafened at a guild level. Deaf bool `json:"deaf"` // Whether the member is muted at a guild level. Mute bool `json:"mute"` // The underlying user on which the member is based. User *User `json:"user"` // A list of IDs of the roles which are possessed by the member. Roles IDSlice `json:"roles,string"` }
A Member stores user information for Guild members. A guild member represents a certain user's presence in a guild.
func (*Member) GetGuildID ¶ added in v1.2.0
type Message ¶
type Message struct { // The ID of the message. ID int64 `json:"id,string"` // The ID of the channel in which the message was sent. ChannelID int64 `json:"channel_id,string"` // The ID of the guild in which the message was sent. GuildID int64 `json:"guild_id,string,omitempty"` // The content of the message. Content string `json:"content"` // The time at which the messsage was sent. // CAUTION: this field may be removed in a // future API version; it is safer to calculate // the creation time via the ID. Timestamp Timestamp `json:"timestamp"` // The time at which the last edit of the message // occurred, if it has been edited. EditedTimestamp Timestamp `json:"edited_timestamp"` // The roles mentioned in the message. MentionRoles IDSlice `json:"mention_roles,string"` // Whether the message is text-to-speech. Tts bool `json:"tts"` // Whether the message mentions everyone. MentionEveryone bool `json:"mention_everyone"` // The author of the message. This is not guaranteed to be a // valid user (webhook-sent messages do not possess a full author). Author *User `json:"author"` // A list of attachments present in the message. Attachments []*MessageAttachment `json:"attachments"` // A list of embeds present in the message. Multiple // embeds can currently only be sent by webhooks. Embeds []*MessageEmbed `json:"embeds"` // A list of users mentioned in the message. Mentions []*User `json:"mentions"` // A list of reactions to the message. Reactions []*MessageReactions `json:"reactions"` // The type of the message. Type MessageType `json:"type"` // Whether the message is pinned or not. Pinned bool `json:"pinned"` WebhookID int64 `json:"webhook_id,string"` }
A Message stores all data related to a specific Discord message.
func (*Message) ContentWithMentionsReplaced ¶ added in v0.8.0
ContentWithMentionsReplaced will replace all @<id> mentions with the username of the mention.
func (*Message) ContentWithMoreMentionsReplaced ¶ added in v1.0.4
ContentWithMoreMentionsReplaced will replace all @<id> mentions with the username of the mention, but also role IDs and more.
func (*Message) GetChannelID ¶ added in v1.2.0
func (*Message) GetGuildID ¶ added in v1.2.0
type MessageAck ¶
type MessageAck struct { MessageID int64 `json:"message_id,string"` ChannelID int64 `json:"channel_id,string"` }
MessageAck is the data for a MessageAck event.
type MessageAttachment ¶ added in v1.0.4
type MessageAttachment struct { ID string `json:"id"` URL string `json:"url"` ProxyURL string `json:"proxy_url"` Filename string `json:"filename"` Width int `json:"width"` Height int `json:"height"` Size int `json:"size"` }
A MessageAttachment stores data for message attachments.
type MessageCreate ¶ added in v0.11.0
type MessageCreate struct {
*Message
}
MessageCreate is the data for a MessageCreate event.
type MessageDelete ¶
type MessageDelete struct {
*Message
}
MessageDelete is the data for a MessageDelete event.
type MessageDeleteBulk ¶ added in v1.0.4
type MessageDeleteBulk struct { Messages IDSlice `json:"ids,string"` ChannelID int64 `json:"channel_id,string"` GuildID int64 `json:"guild_id,string"` }
MessageDeleteBulk is the data for a MessageDeleteBulk event
func (*MessageDeleteBulk) GetChannelID ¶ added in v1.2.0
func (e *MessageDeleteBulk) GetChannelID() int64
func (*MessageDeleteBulk) GetGuildID ¶ added in v1.2.0
func (e *MessageDeleteBulk) GetGuildID() int64
type MessageEdit ¶ added in v1.0.4
type MessageEdit struct { Content *string `json:"content,omitempty"` Embed *MessageEmbed `json:"embed,omitempty"` ID int64 Channel int64 }
MessageEdit is used to chain parameters via ChannelMessageEditComplex, which is also where you should get the instance from.
func NewMessageEdit ¶ added in v1.0.4
func NewMessageEdit(channelID int64, messageID int64) *MessageEdit
NewMessageEdit returns a MessageEdit struct, initialized with the Channel and ID.
func (*MessageEdit) SetContent ¶ added in v1.0.4
func (m *MessageEdit) SetContent(str string) *MessageEdit
SetContent is the same as setting the variable Content, except it doesn't take a pointer.
func (*MessageEdit) SetEmbed ¶ added in v1.0.4
func (m *MessageEdit) SetEmbed(embed *MessageEmbed) *MessageEdit
SetEmbed is a convenience function for setting the embed, so you can chain commands.
type MessageEmbed ¶ added in v1.0.4
type MessageEmbed struct { URL string `json:"url,omitempty"` Type string `json:"type,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Timestamp string `json:"timestamp,omitempty"` Color int `json:"color,omitempty"` Image *MessageEmbedImage `json:"image,omitempty"` Thumbnail *MessageEmbedThumbnail `json:"thumbnail,omitempty"` Video *MessageEmbedVideo `json:"video,omitempty"` Provider *MessageEmbedProvider `json:"provider,omitempty"` Author *MessageEmbedAuthor `json:"author,omitempty"` Fields []*MessageEmbedField `json:"fields,omitempty"` }
An MessageEmbed stores data for message embeds.
type MessageEmbedAuthor ¶ added in v1.0.4
type MessageEmbedAuthor struct { URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` IconURL string `json:"icon_url,omitempty"` ProxyIconURL string `json:"proxy_icon_url,omitempty"` }
MessageEmbedAuthor is a part of a MessageEmbed struct.
type MessageEmbedField ¶ added in v1.0.4
type MessageEmbedField struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` Inline bool `json:"inline,omitempty"` }
MessageEmbedField is a part of a MessageEmbed struct.
type MessageEmbedFooter ¶ added in v1.0.4
type MessageEmbedFooter struct {}
MessageEmbedFooter is a part of a MessageEmbed struct.
type MessageEmbedImage ¶ added in v1.0.4
type MessageEmbedImage struct { URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` }
MessageEmbedImage is a part of a MessageEmbed struct.
type MessageEmbedProvider ¶ added in v1.0.4
type MessageEmbedProvider struct { URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` }
MessageEmbedProvider is a part of a MessageEmbed struct.
type MessageEmbedThumbnail ¶ added in v1.0.4
type MessageEmbedThumbnail struct { URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` }
MessageEmbedThumbnail is a part of a MessageEmbed struct.
type MessageEmbedVideo ¶ added in v1.0.4
type MessageEmbedVideo struct { URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` }
MessageEmbedVideo is a part of a MessageEmbed struct.
type MessageReaction ¶ added in v1.0.4
type MessageReaction struct { UserID int64 `json:"user_id,string"` MessageID int64 `json:"message_id,string"` Emoji Emoji `json:"emoji"` ChannelID int64 `json:"channel_id,string"` GuildID int64 `json:"guild_id,string,omitempty"` }
MessageReaction stores the data for a message reaction.
func (*MessageReaction) GetChannelID ¶ added in v1.2.0
func (mr *MessageReaction) GetChannelID() int64
func (*MessageReaction) GetGuildID ¶ added in v1.2.0
func (mr *MessageReaction) GetGuildID() int64
type MessageReactionAdd ¶ added in v1.0.4
type MessageReactionAdd struct {
*MessageReaction
}
MessageReactionAdd is the data for a MessageReactionAdd event.
type MessageReactionRemove ¶ added in v1.0.4
type MessageReactionRemove struct {
*MessageReaction
}
MessageReactionRemove is the data for a MessageReactionRemove event.
type MessageReactionRemoveAll ¶ added in v1.0.4
type MessageReactionRemoveAll struct {
*MessageReaction
}
MessageReactionRemoveAll is the data for a MessageReactionRemoveAll event.
type MessageReactions ¶ added in v1.0.4
type MessageReactions struct { Count int `json:"count"` Me bool `json:"me"` Emoji *Emoji `json:"emoji"` }
MessageReactions holds a reactions object for a message.
type MessageSend ¶ added in v1.0.4
type MessageSend struct { Content string `json:"content,omitempty"` Embed *MessageEmbed `json:"embed,omitempty"` Tts bool `json:"tts"` Files []*File `json:"-"` // TODO: Remove this when compatibility is not required. File *File `json:"-"` }
MessageSend stores all parameters you can send with ChannelMessageSendComplex.
type MessageType ¶ added in v1.0.4
type MessageType int
MessageType is the type of Message
const ( MessageTypeDefault MessageType = iota MessageTypeRecipientAdd MessageTypeRecipientRemove MessageTypeCall MessageTypeChannelNameChange MessageTypeChannelIconChange MessageTypeChannelPinnedMessage MessageTypeGuildMemberJoin )
Block contains the valid known MessageType values
type MessageUpdate ¶ added in v0.11.0
type MessageUpdate struct {
*Message
}
MessageUpdate is the data for a MessageUpdate event.
type OptionalRequestHeaders ¶ added in v1.2.0
type OptionalRequestHeaders struct {
AuditLogReason string
}
type Packet ¶ added in v0.11.0
type Packet struct { SSRC uint32 Sequence uint16 Timestamp uint32 Type []byte Opus []byte PCM []int16 }
A Packet contains the headers and content of a received voice packet.
type PermissionOverwrite ¶
type PermissionOverwrite struct { ID int64 `json:"id,string"` Type string `json:"type"` Deny int `json:"deny"` Allow int `json:"allow"` }
A PermissionOverwrite holds permission overwrite data for a Channel
type PremiumType ¶ added in v1.2.0
type PremiumType int
const ( NotPremium PremiumType = iota NitroClassic Nitro )
type Presence ¶
type Presence struct { User *User `json:"user"` Status Status `json:"status"` Game *Game `json:"game"` Nick string `json:"nick"` Roles IDSlice `json:"roles,string"` Since *DiscordInt64 `json:"since"` }
A Presence stores the online, offline, or idle and game status of Guild members.
type PresenceUpdate ¶
PresenceUpdate is the data for a PresenceUpdate event.
func (*PresenceUpdate) GetGuildID ¶ added in v1.2.0
func (e *PresenceUpdate) GetGuildID() int64
type PresencesReplace ¶ added in v0.12.0
type PresencesReplace []*Presence
PresencesReplace is the data for a PresencesReplace event.
type RESTError ¶ added in v1.0.4
type RESTError struct { Request *http.Request Response *http.Response ResponseBody []byte Message *APIErrorMessage // Message may be nil. }
RESTError stores error information about a request with a bad response code. Message is not always present, there are cases where api calls can fail without returning a json message.
type RateLimit ¶ added in v0.9.0
type RateLimit struct { *TooManyRequests URL string }
RateLimit is the data for a RateLimit event. This is a sythetic event and is not dispatched by Discord.
type RateLimiter ¶ added in v1.0.4
type RateLimiter struct { sync.Mutex MaxConcurrentRequests int // contains filtered or unexported fields }
RateLimiter holds all ratelimit buckets
func NewRatelimiter ¶ added in v1.0.4
func NewRatelimiter() *RateLimiter
NewRatelimiter returns a new RateLimiter
func (*RateLimiter) CurrentConcurrentLocks ¶ added in v1.0.4
func (r *RateLimiter) CurrentConcurrentLocks() int
func (*RateLimiter) GetBucket ¶ added in v1.0.4
func (r *RateLimiter) GetBucket(key string) *Bucket
GetBucket retrieves or creates a bucket
func (*RateLimiter) GetWaitTime ¶ added in v1.0.4
func (r *RateLimiter) GetWaitTime(b *Bucket, minRemaining int) time.Duration
GetWaitTime returns the duration you should wait for a Bucket
func (*RateLimiter) LockBucket ¶ added in v1.0.4
func (r *RateLimiter) LockBucket(bucketID string) *Bucket
LockBucket Locks until a request can be made
func (*RateLimiter) LockBucketObject ¶ added in v1.0.4
func (r *RateLimiter) LockBucketObject(b *Bucket) *Bucket
LockBucketObject Locks an already resolved bucket until a request can be made
type ReadState ¶
type ReadState struct { MentionCount int `json:"mention_count"` LastMessageID int64 `json:"last_message_id,string"` ID int64 `json:"id,string"` }
A ReadState stores data on the read state of channels.
type ReaderWithMockClose ¶ added in v1.0.4
func (*ReaderWithMockClose) Close ¶ added in v1.0.4
func (rwmc *ReaderWithMockClose) Close() error
type Ready ¶
type Ready struct { Version int `json:"v"` SessionID string `json:"session_id"` User *SelfUser `json:"user"` ReadState []*ReadState `json:"read_state"` PrivateChannels []*Channel `json:"private_channels"` Guilds []*Guild `json:"guilds"` // Undocumented fields Settings *Settings `json:"user_settings"` UserGuildSettings []*UserGuildSettings `json:"user_guild_settings"` Relationships []*Relationship `json:"relationships"` Presences []*Presence `json:"presences"` Notes map[string]string `json:"notes"` }
A Ready stores all data for the websocket READY event.
type Relationship ¶ added in v1.0.4
type Relationship struct { User *User `json:"user"` Type int `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req ID string `json:"id"` }
A Relationship between the logged in user and Relationship.User
type RelationshipAdd ¶ added in v1.0.4
type RelationshipAdd struct {
*Relationship
}
RelationshipAdd is the data for a RelationshipAdd event.
type RelationshipRemove ¶ added in v1.0.4
type RelationshipRemove struct {
*Relationship
}
RelationshipRemove is the data for a RelationshipRemove event.
type Resumed ¶ added in v1.0.4
type Resumed struct {
Trace []string `json:"_trace"`
}
Resumed is the data for a Resumed event.
type Role ¶
type Role struct { // The ID of the role. ID int64 `json:"id,string"` // The name of the role. Name string `json:"name"` // Whether this role is managed by an integration, and // thus cannot be manually added to, or taken from, members. Managed bool `json:"managed"` // Whether this role is mentionable. Mentionable bool `json:"mentionable"` // Whether this role is hoisted (shows up separately in member list). Hoist bool `json:"hoist"` // The hex color of this role. Color int `json:"color"` // The position of this role in the guild's role hierarchy. Position int `json:"position"` // The permissions of the role on the guild (doesn't include channel overrides). // This is a combination of bit masks; the presence of a certain permission can // be checked by performing a bitwise AND between this int and the permission. Permissions int `json:"permissions"` }
A Role stores information about Discord guild member roles.
type SelfUser ¶ added in v1.0.4
A SelfUser stores user data about the token owner. Includes a few extra fields than a normal user struct.
type Session ¶
type Session struct { // Authentication token for this session Token string MFA bool // Debug for printing JSON request/responses Debug bool // Deprecated, will be removed. LogLevel int // Should the session reconnect the websocket on errors. ShouldReconnectOnError bool // Should the session request compressed websocket data. Compress bool // Sharding ShardID int ShardCount int // Should state tracking be enabled. // State tracking is the best way for getting the the users // active guilds and the members of the guilds. StateEnabled bool // Whether or not to call event handlers synchronously. // e.g false = launch event handlers in their own goroutines. SyncEvents bool // Max number of REST API retries MaxRestRetries int // Managed state object, updated internally with events when // StateEnabled is true. State *State // The http client used for REST requests Client *retryablehttp.Client // Stores the last HeartbeatAck that was recieved (in UTC) LastHeartbeatAck time.Time // used to deal with rate limits Ratelimiter *RateLimiter // The gateway websocket connection GatewayManager *GatewayConnectionManager // User agent to use in REST requests UserAgent string // Request headers to use for the very next request, should be set right before it fires OptionalNextRequestHeaders OptionalRequestHeaders // contains filtered or unexported fields }
A Session represents a connection to the Discord API.
func New ¶
New creates a new Discord session and will automate some startup tasks if given enough information to do so. Currently you can pass zero arguments and it will return an empty Discord session. There are 3 ways to call New:
With a single auth token - All requests will use the token blindly, no verification of the token will be done and requests may fail. IF THE TOKEN IS FOR A BOT, IT MUST BE PREFIXED WITH `BOT ` eg: `"Bot <token>"` With an email and password - Discord will sign in with the provided credentials. With an email, password and auth token - Discord will verify the auth token, if it is invalid it will sign in with the provided credentials. This is the Discord recommended way to sign in.
NOTE: While email/pass authentication is supported by DiscordGo it is HIGHLY DISCOURAGED by Discord. Please only use email/pass to obtain a token and then use that authentication token for all future connections. Also, doing any form of automation with a user (non Bot) account may result in that account being permanently banned from Discord.
func (*Session) AddHandler ¶ added in v0.11.0
func (s *Session) AddHandler(handler interface{}) func()
AddHandler allows you to add an event handler that will be fired anytime the Discord WSAPI event that matches the function fires. The first parameter is a *Session, and the second parameter is a pointer to a struct corresponding to the event for which you want to listen.
eg:
Session.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) { })
or:
Session.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) { })
List of events can be found at this page, with corresponding names in the library for each event: https://discordapp.com/developers/docs/topics/gateway#event-names There are also synthetic events fired by the library internally which are available for handling, like Connect, Disconnect, and RateLimit. events.go contains all of the Discord WSAPI and synthetic events that can be handled.
The return value of this method is a function, that when called will remove the event handler.
func (*Session) AddHandlerOnce ¶ added in v1.0.4
func (s *Session) AddHandlerOnce(handler interface{}) func()
AddHandlerOnce allows you to add an event handler that will be fired the next time the Discord WSAPI event that matches the function fires. See AddHandler for more details.
func (*Session) Application ¶ added in v0.12.0
func (s *Session) Application(appID int64) (st *Application, err error)
Application returns an Application structure of a specific Application
appID : The ID of an Application
func (*Session) ApplicationAssets ¶ added in v1.2.0
ApplicationAssets returns an application's assets
func (*Session) ApplicationBotCreate ¶ added in v0.12.0
ApplicationBotCreate creates an Application Bot Account
appID : The ID of an Application
NOTE: func name may change, if I can think up something better.
func (*Session) ApplicationCreate ¶ added in v0.12.0
func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error)
ApplicationCreate creates a new Application
name : Name of Application / Bot uris : Redirect URIs (Not required)
func (*Session) ApplicationDelete ¶ added in v0.12.0
ApplicationDelete deletes an existing Application
appID : The ID of an Application
func (*Session) ApplicationUpdate ¶ added in v0.12.0
func (s *Session) ApplicationUpdate(appID int64, ap *Application) (st *Application, err error)
ApplicationUpdate updates an existing Application
var : desc
func (*Session) Applications ¶ added in v0.12.0
func (s *Session) Applications() (st []*Application, err error)
Applications returns all applications for the authenticated user
func (*Session) Channel ¶
Channel returns a Channel structure of a specific Channel. channelID : The ID of the Channel you want returned.
func (*Session) ChannelDelete ¶
ChannelDelete deletes the given channel channelID : The ID of a Channel
func (*Session) ChannelEdit ¶
ChannelEdit edits the given channel channelID : The ID of a Channel name : The new name to assign the channel.
func (*Session) ChannelEditComplex ¶ added in v1.0.4
func (s *Session) ChannelEditComplex(channelID int64, data *ChannelEdit) (st *Channel, err error)
ChannelEditComplex edits an existing channel, replacing the parameters entirely with ChannelEdit struct channelID : The ID of a Channel data : The channel struct to send
func (*Session) ChannelFileSend ¶ added in v0.11.0
ChannelFileSend sends a file to the given channel. channelID : The ID of a Channel. name: The name of the file. io.Reader : A reader for the file contents.
func (*Session) ChannelFileSendWithMessage ¶ added in v1.0.4
func (s *Session) ChannelFileSendWithMessage(channelID int64, content string, name string, r io.Reader) (*Message, error)
ChannelFileSendWithMessage sends a file to the given channel with an message. DEPRECATED. Use ChannelMessageSendComplex instead. channelID : The ID of a Channel. content: Optional Message content. name: The name of the file. io.Reader : A reader for the file contents.
func (*Session) ChannelInviteCreate ¶
ChannelInviteCreate creates a new invite for the given channel. channelID : The ID of a Channel i : An Invite struct with the values MaxAge, MaxUses and Temporary defined.
func (*Session) ChannelInvites ¶
ChannelInvites returns an array of Invite structures for the given channel channelID : The ID of a Channel
func (*Session) ChannelMessage ¶ added in v1.0.4
ChannelMessage gets a single message by ID from a given channel. channeld : The ID of a Channel messageID : the ID of a Message
func (*Session) ChannelMessageAck ¶
func (s *Session) ChannelMessageAck(channelID, messageID int64, lastToken string) (st *Ack, err error)
ChannelMessageAck acknowledges and marks the given message as read channeld : The ID of a Channel messageID : the ID of a Message lastToken : token returned by last ack
func (*Session) ChannelMessageDelete ¶
ChannelMessageDelete deletes a message from the Channel.
func (*Session) ChannelMessageEdit ¶
ChannelMessageEdit edits an existing message, replacing it entirely with the given content. channelID : The ID of a Channel messageID : The ID of a Message content : The contents of the message
func (*Session) ChannelMessageEditComplex ¶ added in v1.0.4
func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err error)
ChannelMessageEditComplex edits an existing message, replacing it entirely with the given MessageEdit struct
func (*Session) ChannelMessageEditEmbed ¶ added in v1.0.4
func (s *Session) ChannelMessageEditEmbed(channelID, messageID int64, embed *MessageEmbed) (*Message, error)
ChannelMessageEditEmbed edits an existing message with embedded data. channelID : The ID of a Channel messageID : The ID of a Message embed : The embed data to send
func (*Session) ChannelMessagePin ¶ added in v1.0.4
ChannelMessagePin pins a message within a given channel. channelID: The ID of a channel. messageID: The ID of a message.
func (*Session) ChannelMessageSend ¶
ChannelMessageSend sends a message to the given channel. channelID : The ID of a Channel. content : The message to send.
func (*Session) ChannelMessageSendComplex ¶ added in v1.0.4
func (s *Session) ChannelMessageSendComplex(channelID int64, data *MessageSend) (st *Message, err error)
ChannelMessageSendComplex sends a message to the given channel. channelID : The ID of a Channel. data : The message struct to send.
func (*Session) ChannelMessageSendEmbed ¶ added in v1.0.4
func (s *Session) ChannelMessageSendEmbed(channelID int64, embed *MessageEmbed) (*Message, error)
ChannelMessageSendEmbed sends a message to the given channel with embedded data. channelID : The ID of a Channel. embed : The embed data to send.
func (*Session) ChannelMessageSendTTS ¶ added in v0.11.0
ChannelMessageSendTTS sends a message to the given channel with Text to Speech. channelID : The ID of a Channel. content : The message to send.
func (*Session) ChannelMessageUnpin ¶ added in v1.0.4
ChannelMessageUnpin unpins a message within a given channel. channelID: The ID of a channel. messageID: The ID of a message.
func (*Session) ChannelMessages ¶
func (s *Session) ChannelMessages(channelID int64, limit int, beforeID, afterID, aroundID int64) (st []*Message, err error)
ChannelMessages returns an array of Message structures for messages within a given channel. channelID : The ID of a Channel. limit : The number messages that can be returned. (max 100) beforeID : If provided all messages returned will be before given ID. afterID : If provided all messages returned will be after given ID. aroundID : If provided all messages returned will be around given ID.
func (*Session) ChannelMessagesBulkDelete ¶ added in v1.0.4
ChannelMessagesBulkDelete bulk deletes the messages from the channel for the provided messageIDs. If only one messageID is in the slice call channelMessageDelete function. If the slice is empty do nothing. channelID : The ID of the channel for the messages to delete. messages : The IDs of the messages to be deleted. A slice of message IDs. A maximum of 100 messages.
func (*Session) ChannelMessagesPinned ¶ added in v1.0.4
ChannelMessagesPinned returns an array of Message structures for pinned messages within a given channel channelID : The ID of a Channel.
func (*Session) ChannelPermissionDelete ¶ added in v0.7.0
ChannelPermissionDelete deletes a specific permission override for the given channel. NOTE: Name of this func may change.
func (*Session) ChannelPermissionSet ¶ added in v0.7.0
func (s *Session) ChannelPermissionSet(channelID, targetID int64, targetType string, allow, deny int) (err error)
ChannelPermissionSet creates a Permission Override for the given channel. NOTE: This func name may changed. Using Set instead of Create because you can both create a new override or update an override with this function.
func (*Session) ChannelTyping ¶
ChannelTyping broadcasts to all members that authenticated user is typing in the given channel. channelID : The ID of a Channel
func (*Session) ChannelWebhooks ¶ added in v1.0.4
ChannelWebhooks returns all webhooks for a given channel. channelID: The ID of a channel.
func (*Session) Close ¶
Close maintains backwards compatibility with old discordgo versions It's the same as s.GatewayManager.Close()
func (*Session) GatewayBot ¶ added in v1.0.4
func (s *Session) GatewayBot() (st *GatewayBotResponse, err error)
GatewayBot returns the websocket Gateway address and the recommended number of shards
func (*Session) Guild ¶
Guild returns a Guild structure of a specific Guild. guildID : The ID of a Guild
func (*Session) GuildAuditLog ¶ added in v1.0.4
func (s *Session) GuildAuditLog(guildID, userID, beforeID int64, actionType, limit int) (st *GuildAuditLog, err error)
GuildAuditLog returns the audit log for a Guild. guildID : The ID of a Guild. userID : If provided the log will be filtered for the given ID. beforeID : If provided all log entries returned will be before the given ID. actionType : If provided the log will be filtered for the given Action Type. limit : The number messages that can be returned. (default 50, min 1, max 100)
func (*Session) GuildBanCreate ¶ added in v0.7.0
GuildBanCreate bans the given user from the given guild. guildID : The ID of a Guild. userID : The ID of a User days : The number of days of previous comments to delete.
func (*Session) GuildBanCreateWithReason ¶ added in v1.0.4
func (s *Session) GuildBanCreateWithReason(guildID, userID int64, reason string, days int) (err error)
GuildBanCreateWithReason bans the given user from the given guild also providing a reaso. guildID : The ID of a Guild. userID : The ID of a User reason : The reason for this ban days : The number of days of previous comments to delete.
func (*Session) GuildBanDelete ¶
GuildBanDelete removes the given user from the guild bans guildID : The ID of a Guild. userID : The ID of a User
func (*Session) GuildBans ¶
GuildBans returns an array of GuildBan structures for all bans of a given guild. guildID : The ID of a Guild.
func (*Session) GuildChannelCreate ¶
func (s *Session) GuildChannelCreate(guildID int64, name string, ctype ChannelType) (st *Channel, err error)
GuildChannelCreate creates a new channel in the given guild guildID : The ID of a Guild. name : Name of the channel (2-100 chars length) ctype : Type of the channel
func (*Session) GuildChannelCreateWithOverwrites ¶ added in v1.2.0
func (s *Session) GuildChannelCreateWithOverwrites(guildID int64, name string, ctype ChannelType, parentID int64, overwrites []*PermissionOverwrite) (st *Channel, err error)
GuildChannelCreateWithOverwrites creates a new channel in the given guild guildID : The ID of a Guild. name : Name of the channel (2-100 chars length) ctype : Type of the channel overwrites : slice of permission overwrites
func (*Session) GuildChannels ¶
GuildChannels returns an array of Channel structures for all channels of a given guild. guildID : The ID of a Guild.
func (*Session) GuildChannelsReorder ¶ added in v1.0.4
GuildChannelsReorder updates the order of channels in a guild guildID : The ID of a Guild. channels : Updated channels.
func (*Session) GuildCreate ¶
GuildCreate creates a new Guild name : A name for the Guild (2-100 characters)
func (*Session) GuildDelete ¶
GuildDelete deletes a Guild. guildID : The ID of a Guild
func (*Session) GuildEdit ¶
func (s *Session) GuildEdit(guildID int64, g GuildParams) (st *Guild, err error)
GuildEdit edits a new Guild guildID : The ID of a Guild g : A GuildParams struct with the values Name, Region and VerificationLevel defined.
func (*Session) GuildEmbed ¶ added in v1.0.4
func (s *Session) GuildEmbed(guildID int64) (st *GuildEmbed, err error)
GuildEmbed returns the embed for a Guild. guildID : The ID of a Guild.
func (*Session) GuildEmbedEdit ¶ added in v1.0.4
GuildEmbedEdit returns the embed for a Guild. guildID : The ID of a Guild.
func (*Session) GuildEmojiCreate ¶ added in v1.0.4
func (s *Session) GuildEmojiCreate(guildID int64, name, image string, roles []int64) (emoji *Emoji, err error)
GuildEmojiCreate creates a new emoji guildID : The ID of a Guild. name : The Name of the Emoji. image : The base64 encoded emoji image, has to be smaller than 256KB. roles : The roles for which this emoji will be whitelisted, can be nil.
func (*Session) GuildEmojiDelete ¶ added in v1.0.4
GuildEmojiDelete deletes an Emoji. guildID : The ID of a Guild. emojiID : The ID of an Emoji.
func (*Session) GuildEmojiEdit ¶ added in v1.0.4
func (s *Session) GuildEmojiEdit(guildID, emojiID int64, name string, roles []int64) (emoji *Emoji, err error)
GuildEmojiEdit modifies an emoji guildID : The ID of a Guild. emojiID : The ID of an Emoji. name : The Name of the Emoji. roles : The roles for which this emoji will be whitelisted, can be nil.
func (*Session) GuildIcon ¶ added in v0.10.0
GuildIcon returns an image.Image of a guild icon. guildID : The ID of a Guild.
func (*Session) GuildIntegrationCreate ¶ added in v1.0.4
func (s *Session) GuildIntegrationCreate(guildID int64, integrationType string, integrationID int64) (err error)
GuildIntegrationCreate creates a Guild Integration. guildID : The ID of a Guild. integrationType : The Integration type. integrationID : The ID of an integration.
func (*Session) GuildIntegrationDelete ¶ added in v1.0.4
GuildIntegrationDelete removes the given integration from the Guild. guildID : The ID of a Guild. integrationID : The ID of an integration.
func (*Session) GuildIntegrationEdit ¶ added in v1.0.4
func (s *Session) GuildIntegrationEdit(guildID, integrationID int64, expireBehavior, expireGracePeriod int, enableEmoticons bool) (err error)
GuildIntegrationEdit edits a Guild Integration. guildID : The ID of a Guild. integrationType : The Integration type. integrationID : The ID of an integration. expireBehavior : The behavior when an integration subscription lapses (see the integration object documentation). expireGracePeriod : Period (in seconds) where the integration will ignore lapsed subscriptions. enableEmoticons : Whether emoticons should be synced for this integration (twitch only currently).
func (*Session) GuildIntegrationSync ¶ added in v1.0.4
GuildIntegrationSync syncs an integration. guildID : The ID of a Guild. integrationID : The ID of an integration.
func (*Session) GuildIntegrations ¶ added in v1.0.4
func (s *Session) GuildIntegrations(guildID int64) (st []*Integration, err error)
GuildIntegrations returns an array of Integrations for a guild. guildID : The ID of a Guild.
func (*Session) GuildInvites ¶
GuildInvites returns an array of Invite structures for the given guild guildID : The ID of a Guild.
func (*Session) GuildLeave ¶ added in v0.11.0
GuildLeave leaves a Guild. guildID : The ID of a Guild
func (*Session) GuildMember ¶ added in v0.11.0
GuildMember returns a member of a guild.
guildID : The ID of a Guild. userID : The ID of a User
func (*Session) GuildMemberAdd ¶ added in v1.0.4
func (s *Session) GuildMemberAdd(accessToken string, guildID, userID int64, nick string, roles []int64, mute, deaf bool) (err error)
GuildMemberAdd force joins a user to the guild.
accessToken : Valid access_token for the user. guildID : The ID of a Guild. userID : The ID of a User. nick : Value to set users nickname to roles : A list of role ID's to set on the member. mute : If the user is muted. deaf : If the user is deafened.
func (*Session) GuildMemberDelete ¶
GuildMemberDelete removes the given user from the given guild. guildID : The ID of a Guild. userID : The ID of a User
func (*Session) GuildMemberDeleteWithReason ¶ added in v1.0.4
GuildMemberDeleteWithReason removes the given user from the given guild. guildID : The ID of a Guild. userID : The ID of a User reason : The reason for the kick
func (*Session) GuildMemberEdit ¶ added in v0.11.0
GuildMemberEdit edits the roles of a member. guildID : The ID of a Guild. userID : The ID of a User. roles : A list of role ID's to set on the member.
func (*Session) GuildMemberMove ¶ added in v0.11.0
GuildMemberMove moves a guild member from one voice channel to another/none
guildID : The ID of a Guild. userID : The ID of a User. channelID : The ID of a channel to move user to, or null?
NOTE : I am not entirely set on the name of this function and it may change prior to the final 1.0.0 release of Discordgo
func (*Session) GuildMemberNickname ¶ added in v1.0.4
GuildMemberNickname updates the nickname of a guild member guildID : The ID of a guild userID : The ID of a user or "@me" which is a shortcut of the current user ID nickname : The new nickname
func (*Session) GuildMemberNicknameMe ¶ added in v1.0.4
GuildMemberNicknameMe updates the nickname the current user guildID : The ID of a guild nickname : The new nickname
func (*Session) GuildMemberRoleAdd ¶ added in v1.0.4
GuildMemberRoleAdd adds the specified role to a given member
guildID : The ID of a Guild. userID : The ID of a User. roleID : The ID of a Role to be assigned to the user.
func (*Session) GuildMemberRoleRemove ¶ added in v1.0.4
GuildMemberRoleRemove removes the specified role to a given member
guildID : The ID of a Guild. userID : The ID of a User. roleID : The ID of a Role to be removed from the user.
func (*Session) GuildMembers ¶
GuildMembers returns a list of members for a guild.
guildID : The ID of a Guild. after : The id of the member to return members after limit : max number of members to return (max 1000)
func (*Session) GuildPrune ¶ added in v1.0.4
GuildPrune Begin as prune operation. Requires the 'KICK_MEMBERS' permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. guildID : The ID of a Guild. days : The number of days to count prune for (1 or more).
func (*Session) GuildPruneCount ¶ added in v1.0.4
GuildPruneCount Returns the number of members that would be removed in a prune operation. Requires 'KICK_MEMBER' permission. guildID : The ID of a Guild. days : The number of days to count prune for (1 or more).
func (*Session) GuildRoleCreate ¶ added in v0.7.0
GuildRoleCreate returns a new Guild Role. guildID: The ID of a Guild.
func (*Session) GuildRoleDelete ¶ added in v0.7.0
GuildRoleDelete deletes an existing role. guildID : The ID of a Guild. roleID : The ID of a Role.
func (*Session) GuildRoleEdit ¶ added in v0.7.0
func (s *Session) GuildRoleEdit(guildID, roleID int64, name string, color int, hoist bool, perm int, mention bool) (st *Role, err error)
GuildRoleEdit updates an existing Guild Role with new values guildID : The ID of a Guild. roleID : The ID of a Role. name : The name of the Role. color : The color of the role (decimal, not hex). hoist : Whether to display the role's users separately. perm : The permissions for the role. mention : Whether this role is mentionable
func (*Session) GuildRoleReorder ¶ added in v0.7.0
GuildRoleReorder reoders guild roles guildID : The ID of a Guild. roles : A list of ordered roles.
func (*Session) GuildRoles ¶ added in v0.7.0
GuildRoles returns all roles for a given guild. guildID : The ID of a Guild.
func (*Session) GuildSplash ¶ added in v0.10.0
GuildSplash returns an image.Image of a guild splash image. guildID : The ID of a Guild.
func (*Session) GuildWebhooks ¶ added in v1.0.4
GuildWebhooks returns all webhooks for a given guild. guildID: The ID of a Guild.
func (*Session) Invite ¶
Invite returns an Invite structure of the given invite inviteID : The invite code
func (*Session) InviteAccept ¶
InviteAccept accepts an Invite to a Guild or Channel inviteID : The invite code
func (*Session) InviteDelete ¶
InviteDelete deletes an existing invite inviteID : the code of an invite
func (*Session) InviteWithCounts ¶ added in v1.0.4
InviteWithCounts returns an Invite structure of the given invite including approximate member counts inviteID : The invite code
func (*Session) Login ¶
Login asks the Discord server for an authentication token.
NOTE: While email/pass authentication is supported by DiscordGo it is HIGHLY DISCOURAGED by Discord. Please only use email/pass to obtain a token and then use that authentication token for all future connections. Also, doing any form of automation with a user (non Bot) account may result in that account being permanently banned from Discord.
func (*Session) Logout ¶
Logout sends a logout request to Discord. This does not seem to actually invalidate the token. So you can still make API calls even after a Logout. So, it seems almost pointless to even use.
func (*Session) MessageReactionAdd ¶ added in v1.0.4
MessageReactionAdd creates an emoji reaction to a message. channelID : The channel ID. messageID : The message ID. emoji : Either the unicode emoji for the reaction, or a guild emoji identifier.
func (*Session) MessageReactionRemove ¶ added in v1.0.4
func (s *Session) MessageReactionRemove(channelID, messageID int64, emoji string, userID int64) error
MessageReactionRemove deletes an emoji reaction to a message. channelID : The channel ID. messageID : The message ID. emoji : Either the unicode emoji for the reaction, or a guild emoji identifier. userID : The ID of the user to delete the reaction for.
func (*Session) MessageReactionRemoveMe ¶ added in v1.0.4
MessageReactionRemoveMe deletes an emoji reaction to a message the current user made. channelID : The channel ID. messageID : The message ID. emoji : Either the unicode emoji for the reaction, or a guild emoji identifier.
func (*Session) MessageReactions ¶ added in v1.0.4
func (s *Session) MessageReactions(channelID, messageID int64, emoji string, limit int, before, after int64) (st []*User, err error)
MessageReactions gets all the users reactions for a specific emoji. channelID : The channel ID. messageID : The message ID. emoji : Either the unicode emoji for the reaction, or a guild emoji identifier. limit : max number of users to return (max 100)
func (*Session) MessageReactionsRemoveAll ¶ added in v1.0.4
MessageReactionsRemoveAll deletes all reactions from a message channelID : The channel ID messageID : The message ID.
func (*Session) Register ¶ added in v0.9.0
Register sends a Register request to Discord, and returns the authentication token Note that this account is temporary and should be verified for future use. Another option is to save the authentication token external, but this isn't recommended.
func (*Session) RelationshipDelete ¶ added in v1.0.4
RelationshipDelete removes the relationship with a user. userID: ID of the user.
func (*Session) RelationshipFriendRequestAccept ¶ added in v1.0.4
RelationshipFriendRequestAccept accepts a friend request from a user. userID: ID of the user.
func (*Session) RelationshipFriendRequestSend ¶ added in v1.0.4
RelationshipFriendRequestSend sends a friend request to a user. userID: ID of the user.
func (*Session) RelationshipUserBlock ¶ added in v1.0.4
RelationshipUserBlock blocks a user. userID: ID of the user.
func (*Session) RelationshipsGet ¶ added in v1.0.4
func (s *Session) RelationshipsGet() (r []*Relationship, err error)
RelationshipsGet returns an array of all the relationships of the user.
func (*Session) RelationshipsMutualGet ¶ added in v1.0.4
RelationshipsMutualGet returns an array of all the users both @me and the given user is friends with. userID: ID of the user.
func (*Session) Request ¶
Request is the same as RequestWithBucketID but the bucket id is the same as the urlStr
func (*Session) RequestWithBucketID ¶ added in v1.0.4
func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, bucketID string) (response []byte, err error)
RequestWithBucketID makes a (GET/POST/...) Requests to Discord REST API with JSON data.
func (*Session) RequestWithLockedBucket ¶ added in v1.0.4
func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b []byte, bucket *Bucket) (response []byte, err error)
RequestWithLockedBucket makes a request using a bucket that's already been locked
func (*Session) SetNextRequestHeaders ¶ added in v1.2.0
func (s *Session) SetNextRequestHeaders(headers OptionalRequestHeaders)
func (*Session) TOTP ¶ added in v1.2.0
func (s *Session) TOTP(ticket, code string) (*LoginResponse, error)
func (*Session) UpdateListeningStatus ¶ added in v1.0.4
UpdateListeningStatus is used to set the user to "Listening to..." If game!="" then set to what user is listening to Else, set user to active and no game.
func (*Session) UpdateStatus ¶
UpdateStatus is used to update the user's status. If idle>0 then set status to idle. If game!="" then set game. if otherwise, set status to active, and no game.
func (*Session) UpdateStatusComplex ¶ added in v1.0.4
func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error)
func (*Session) UpdateStreamingStatus ¶ added in v1.0.4
UpdateStreamingStatus is used to update the user's streaming status. If idle>0 then set status to idle. If game!="" then set game. If game!="" and url!="" then set the status type to streaming with the URL set. if otherwise, set status to active, and no game.
func (*Session) UserAvatar ¶
UserAvatar is deprecated. Please use UserAvatarDecode userID : A user ID or "@me" which is a shortcut of current user ID
func (*Session) UserAvatarDecode ¶ added in v1.0.4
UserAvatarDecode returns an image.Image of a user's Avatar user : The user which avatar should be retrieved
func (*Session) UserChannelCreate ¶
UserChannelCreate creates a new User (Private) Channel with another User recipientID : A user ID for the user to which this channel is opened with.
func (*Session) UserChannelPermissions ¶ added in v0.12.0
UserChannelPermissions returns the permission of a user in a channel. userID : The ID of the user to calculate permissions for. channelID : The ID of the channel to calculate permission for.
NOTE: This function is now deprecated and will be removed in the future. Please see the same function inside state.go
func (*Session) UserChannels ¶
UserChannels returns an array of Channel structures for all private channels.
func (*Session) UserConnections ¶ added in v1.0.4
func (s *Session) UserConnections() (conn []*UserConnection, err error)
UserConnections returns the user's connections
func (*Session) UserGuildSettingsEdit ¶ added in v1.0.4
func (s *Session) UserGuildSettingsEdit(guildID int64, settings *UserGuildSettingsEdit) (st *UserGuildSettings, err error)
UserGuildSettingsEdit Edits the users notification settings for a guild guildID : The ID of the guild to edit the settings on settings : The settings to update
func (*Session) UserGuilds ¶
UserGuilds returns an array of UserGuild structures for all guilds. limit : The number guilds that can be returned. (max 100) beforeID : If provided all guilds returned will be before given ID. afterID : If provided all guilds returned will be after given ID.
func (*Session) UserNoteSet ¶ added in v1.0.4
UserNoteSet sets the note for a specific user.
func (*Session) UserSettings ¶
UserSettings returns the settings for a given user
func (*Session) UserUpdate ¶ added in v0.6.0
func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error)
UserUpdate updates a users settings.
func (*Session) UserUpdateStatus ¶ added in v1.0.4
UserUpdateStatus update the user status status : The new status (Actual valid status are 'online','idle','dnd','invisible')
func (*Session) VoiceRegions ¶
func (s *Session) VoiceRegions() (st []*VoiceRegion, err error)
VoiceRegions returns the voice server regions
func (*Session) Webhook ¶ added in v1.0.4
Webhook returns a webhook for a given ID webhookID: The ID of a webhook.
func (*Session) WebhookCreate ¶ added in v1.0.4
WebhookCreate returns a new Webhook. channelID: The ID of a Channel. name : The name of the webhook. avatar : The avatar of the webhook.
func (*Session) WebhookDelete ¶ added in v1.0.4
WebhookDelete deletes a webhook for a given ID webhookID: The ID of a webhook.
func (*Session) WebhookDeleteWithToken ¶ added in v1.0.4
WebhookDeleteWithToken deletes a webhook for a given ID with an auth token. webhookID: The ID of a webhook. token : The auth token for the webhook.
func (*Session) WebhookEdit ¶ added in v1.0.4
func (s *Session) WebhookEdit(webhookID int64, name, avatar string, channelID int64) (st *Role, err error)
WebhookEdit updates an existing Webhook. webhookID: The ID of a webhook. name : The name of the webhook. avatar : The avatar of the webhook.
func (*Session) WebhookEditWithToken ¶ added in v1.0.4
func (s *Session) WebhookEditWithToken(webhookID int64, token, name, avatar string) (st *Role, err error)
WebhookEditWithToken updates an existing Webhook with an auth token. webhookID: The ID of a webhook. token : The auth token for the webhook. name : The name of the webhook. avatar : The avatar of the webhook.
func (*Session) WebhookExecute ¶ added in v1.0.4
func (s *Session) WebhookExecute(webhookID int64, token string, wait bool, data *WebhookParams) (err error)
WebhookExecute executes a webhook. webhookID: The ID of a webhook. token : The auth token for the webhook
type SessionStartLimit ¶ added in v1.2.0
type Settings ¶
type Settings struct { RenderEmbeds bool `json:"render_embeds"` InlineEmbedMedia bool `json:"inline_embed_media"` InlineAttachmentMedia bool `json:"inline_attachment_media"` EnableTtsCommand bool `json:"enable_tts_command"` MessageDisplayCompact bool `json:"message_display_compact"` ShowCurrentGame bool `json:"show_current_game"` ConvertEmoticons bool `json:"convert_emoticons"` Locale string `json:"locale"` Theme string `json:"theme"` GuildPositions IDSlice `json:"guild_positions,string"` RestrictedGuilds IDSlice `json:"restricted_guilds,string"` FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"` Status Status `json:"status"` DetectPlatformAccounts bool `json:"detect_platform_accounts"` DeveloperMode bool `json:"developer_mode"` }
A Settings stores data for a specific users Discord client settings.
type State ¶ added in v0.8.0
type State struct { sync.RWMutex Ready // MaxMessageCount represents how many messages per channel the state will store. MaxMessageCount int TrackChannels bool TrackEmojis bool TrackMembers bool TrackRoles bool TrackVoice bool TrackPresences bool // contains filtered or unexported fields }
A State contains the current known state. As discord sends this in a READY blob, it seems reasonable to simply use that struct as the data store.
func (*State) Channel ¶ added in v0.8.0
Channel gets a channel by ID, it will look in all guilds and private channels.
func (*State) ChannelAdd ¶ added in v0.8.0
ChannelAdd adds a channel to the current world state, or updates it if it already exists. Channels may exist either as PrivateChannels or inside a guild.
func (*State) ChannelRemove ¶ added in v0.8.0
ChannelRemove removes a channel from current world state.
func (*State) Guild ¶ added in v0.8.0
Guild gets a guild by ID. Useful for querying if @me is in a guild:
_, err := discordgo.Session.State.Guild(guildID) isInGuild := err == nil
func (*State) GuildAdd ¶ added in v0.8.0
GuildAdd adds a guild to the current world state, or updates it if it already exists.
func (*State) GuildChannel ¶ added in v0.8.0
GuildChannel gets a channel by ID from a guild. This method is Deprecated, use Channel(channelID)
func (*State) GuildRemove ¶ added in v0.8.0
GuildRemove removes a guild from current world state.
func (*State) MemberAdd ¶ added in v0.8.0
MemberAdd adds a member to the current world state, or updates it if it already exists.
func (*State) MemberRemove ¶ added in v0.8.0
MemberRemove removes a member from current world state.
func (*State) MessageAdd ¶ added in v0.10.0
MessageAdd adds a message to the current world state, or updates it if it exists. If the channel cannot be found, the message is discarded. Messages are kept in state up to s.MaxMessageCount per channel.
func (*State) MessageRemove ¶ added in v0.10.0
MessageRemove removes a message from the world state.
func (*State) OnInterface ¶ added in v1.0.4
OnInterface handles all events related to states.
func (*State) PresenceAdd ¶ added in v1.0.4
PresenceAdd adds a presence to the current world state, or updates it if it already exists.
func (*State) PresenceRemove ¶ added in v1.0.4
PresenceRemove removes a presence from the current world state.
func (*State) PrivateChannel ¶ added in v0.8.0
PrivateChannel gets a private channel by ID. This method is Deprecated, use Channel(channelID)
func (*State) RoleAdd ¶ added in v1.0.4
RoleAdd adds a role to the current world state, or updates it if it already exists.
func (*State) RoleRemove ¶ added in v1.0.4
RoleRemove removes a role from current world state by ID.
func (*State) UserChannelPermissions ¶ added in v1.0.4
UserChannelPermissions returns the permission of a user in a channel. userID : The ID of the user to calculate permissions for. channelID : The ID of the channel to calculate permission for.
func (*State) UserColor ¶ added in v1.0.4
UserColor returns the color of a user in a channel. While colors are defined at a Guild level, determining for a channel is more useful in message handlers. 0 is returned in cases of error, which is the color of @everyone. userID : The ID of the user to calculate the color for. channelID : The ID of the channel to calculate the color for.
type StdGatewayIdentifyRatleimiter ¶ added in v1.0.4
type StdGatewayIdentifyRatleimiter struct {
// contains filtered or unexported fields
}
Standard implementation of the GatewayIdentifyRatelimiter
func (*StdGatewayIdentifyRatleimiter) RatelimitIdentify ¶ added in v1.0.4
func (rl *StdGatewayIdentifyRatleimiter) RatelimitIdentify()
type TimeStamps ¶ added in v1.0.4
type TimeStamps struct { EndTimestamp int64 `json:"end,omitempty"` StartTimestamp int64 `json:"start,omitempty"` }
A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
func (*TimeStamps) UnmarshalJSON ¶ added in v1.0.4
func (t *TimeStamps) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals JSON into TimeStamps struct
type Timestamp ¶ added in v1.0.4
type Timestamp string
Timestamp stores a timestamp, as sent by the Discord API.
type TooManyRequests ¶ added in v1.0.4
type TooManyRequests struct { Bucket string `json:"bucket"` Message string `json:"message"` RetryAfter time.Duration `json:"retry_after"` }
A TooManyRequests struct holds information received from Discord when receiving a HTTP 429 response.
type TypingStart ¶
type TypingStart struct { UserID int64 `json:"user_id,string"` ChannelID int64 `json:"channel_id,string"` Timestamp int `json:"timestamp"` GuildID int64 `json:"guild_id,string,omitempty"` }
TypingStart is the data for a TypingStart event.
func (*TypingStart) GetChannelID ¶ added in v1.2.0
func (e *TypingStart) GetChannelID() int64
func (*TypingStart) GetGuildID ¶ added in v1.2.0
func (e *TypingStart) GetGuildID() int64
type UpdateStatusData ¶ added in v1.0.4
type User ¶
type User struct { // The ID of the user. ID int64 `json:"id,string"` // The user's username. Username string `json:"username"` // The hash of the user's avatar. Use Session.UserAvatar // to retrieve the avatar itself. Avatar string `json:"avatar"` // The user's chosen language option. Locale string `json:"locale"` // The discriminator of the user (4 numbers after name). Discriminator string `json:"discriminator"` // Whether the user is a bot. Bot bool `json:"bot"` // An user's Nitro status PremiumType PremiumType `json:"premium_type"` }
A User stores all data for an individual Discord user.
func (*User) AvatarURL ¶ added in v1.0.4
AvatarURL returns a URL to the user's avatar.
size: The size of the user's avatar as a power of two if size is an empty string, no size parameter will be added to the URL.
type UserConnection ¶ added in v1.0.4
type UserConnection struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` Revoked bool `json:"revoked"` Integrations []*Integration `json:"integrations"` }
UserConnection is a Connection returned from the UserConnections endpoint
type UserGuild ¶ added in v1.0.4
type UserGuild struct { ID int64 `json:"id,string"` Name string `json:"name"` Icon string `json:"icon"` Owner bool `json:"owner"` Permissions int `json:"permissions"` }
A UserGuild holds a brief version of a Guild
type UserGuildSettings ¶ added in v0.12.0
type UserGuildSettings struct { SupressEveryone bool `json:"suppress_everyone"` Muted bool `json:"muted"` MobilePush bool `json:"mobile_push"` MessageNotifications int `json:"message_notifications"` GuildID int64 `json:"guild_id,string"` ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"` }
A UserGuildSettings stores data for a users guild settings.
type UserGuildSettingsChannelOverride ¶ added in v0.12.0
type UserGuildSettingsChannelOverride struct { Muted bool `json:"muted"` MessageNotifications int `json:"message_notifications"` ChannelID int64 `json:"channel_id,string"` }
A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
type UserGuildSettingsEdit ¶ added in v1.0.4
type UserGuildSettingsEdit struct { SupressEveryone bool `json:"suppress_everyone"` Muted bool `json:"muted"` MobilePush bool `json:"mobile_push"` MessageNotifications int `json:"message_notifications"` ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"` }
A UserGuildSettingsEdit stores data for editing UserGuildSettings
type UserGuildSettingsUpdate ¶ added in v0.12.0
type UserGuildSettingsUpdate struct {
*UserGuildSettings
}
UserGuildSettingsUpdate is the data for a UserGuildSettingsUpdate event.
type UserNoteUpdate ¶ added in v1.0.4
UserNoteUpdate is the data for a UserNoteUpdate event.
type UserSettingsUpdate ¶ added in v0.11.0
type UserSettingsUpdate map[string]interface{}
UserSettingsUpdate is the data for a UserSettingsUpdate event.
type UserUpdate ¶ added in v0.11.0
type UserUpdate struct {
*User
}
UserUpdate is the data for a UserUpdate event.
type VerificationLevel ¶ added in v0.12.0
type VerificationLevel int
VerificationLevel type definition
const ( VerificationLevelNone VerificationLevel = iota VerificationLevelLow VerificationLevelMedium VerificationLevelHigh )
Constants for VerificationLevel levels from 0 to 3 inclusive
type VoiceConnection ¶ added in v0.12.0
type VoiceConnection struct { sync.RWMutex Debug bool // If true, print extra logging -- DEPRECATED LogLevel int Ready bool // If true, voice is ready to send/receive audio UserID int64 GuildID int64 ChannelID int64 OpusSend chan []byte // Chan for sending opus audio OpusRecv chan *Packet // Chan for receiving opus audio // Used to allow blocking until connected Connected chan bool // contains filtered or unexported fields }
A VoiceConnection struct holds all the data and functions related to a Discord Voice Connection.
func (*VoiceConnection) AddHandler ¶ added in v0.12.0
func (v *VoiceConnection) AddHandler(h VoiceSpeakingUpdateHandler)
AddHandler adds a Handler for VoiceSpeakingUpdate events.
func (*VoiceConnection) ChangeChannel ¶ added in v0.12.0
func (v *VoiceConnection) ChangeChannel(channelID int64, mute, deaf bool) (err error)
ChangeChannel sends Discord a request to change channels within a Guild !!! NOTE !!! This function may be removed in favour of just using ChannelVoiceJoin
func (*VoiceConnection) Close ¶ added in v0.12.0
func (v *VoiceConnection) Close()
Close closes the voice ws and udp connections
func (*VoiceConnection) Disconnect ¶ added in v0.12.0
func (v *VoiceConnection) Disconnect() (err error)
Disconnect disconnects from this voice channel and closes the websocket and udp connections to Discord. !!! NOTE !!! this function may be removed in favour of ChannelVoiceLeave
func (*VoiceConnection) Speaking ¶ added in v0.12.0
func (v *VoiceConnection) Speaking(b bool) (err error)
Speaking sends a speaking notification to Discord over the voice websocket. This must be sent as true prior to sending audio and should be set to false once finished sending audio.
b : Send true if speaking, false if not.
type VoiceRegion ¶
type VoiceRegion struct { ID string `json:"id"` Name string `json:"name"` Hostname string `json:"sample_hostname"` Port int `json:"sample_port"` }
A VoiceRegion stores data for a specific voice region server.
type VoiceServerUpdate ¶
type VoiceServerUpdate struct { Token string `json:"token"` GuildID int64 `json:"guild_id,string"` Endpoint string `json:"endpoint"` }
VoiceServerUpdate is the data for a VoiceServerUpdate event.
func (*VoiceServerUpdate) GetGuildID ¶ added in v1.2.0
func (e *VoiceServerUpdate) GetGuildID() int64
type VoiceSpeakingUpdate ¶ added in v0.12.0
type VoiceSpeakingUpdate struct { UserID string `json:"user_id"` SSRC int `json:"ssrc"` Speaking bool `json:"speaking"` }
VoiceSpeakingUpdate is a struct for a VoiceSpeakingUpdate event.
type VoiceSpeakingUpdateHandler ¶ added in v0.12.0
type VoiceSpeakingUpdateHandler func(vc *VoiceConnection, vs *VoiceSpeakingUpdate)
VoiceSpeakingUpdateHandler type provides a function definition for the VoiceSpeakingUpdate event
type VoiceState ¶
type VoiceState struct { UserID int64 `json:"user_id,string"` SessionID string `json:"session_id"` ChannelID int64 `json:"channel_id,string"` GuildID int64 `json:"guild_id,string"` Suppress bool `json:"suppress"` SelfMute bool `json:"self_mute"` SelfDeaf bool `json:"self_deaf"` Mute bool `json:"mute"` Deaf bool `json:"deaf"` }
A VoiceState stores the voice states of Guilds
type VoiceStateUpdate ¶ added in v0.11.0
type VoiceStateUpdate struct {
*VoiceState
}
VoiceStateUpdate is the data for a VoiceStateUpdate event.
type Webhook ¶ added in v1.0.4
type Webhook struct { ID int64 `json:"id,string"` GuildID int64 `json:"guild_id,string"` ChannelID int64 `json:"channel_id,string"` User *User `json:"user"` Name string `json:"name"` Avatar string `json:"avatar"` Token string `json:"token"` }
Webhook stores the data for a webhook.
type WebhookParams ¶ added in v1.0.4
type WebhookParams struct { Content string `json:"content,omitempty"` Username string `json:"username,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` TTS bool `json:"tts,omitempty"` File string `json:"file,omitempty"` Embeds []*MessageEmbed `json:"embeds,omitempty"` }
WebhookParams is a struct for webhook params, used in the WebhookExecute command.
type WebhooksUpdate ¶ added in v1.0.4
type WebhooksUpdate struct { GuildID int64 `json:"guild_id,string"` ChannelID int64 `json:"channel_id,string"` }
WebhooksUpdate is the data for a WebhooksUpdate event
func (*WebhooksUpdate) GetChannelID ¶ added in v1.2.0
func (e *WebhooksUpdate) GetChannelID() int64
func (*WebhooksUpdate) GetGuildID ¶ added in v1.2.0
func (e *WebhooksUpdate) GetGuildID() int64