discordgo: github.com/bwmarrin/discordgo Index | Examples | Files | Directories

package discordgo

import "github.com/bwmarrin/discordgo"

Package discordgo provides Discord binding for Go

Index

Examples

Package Files

discord.go endpoints.go event.go eventhandlers.go events.go logging.go message.go oauth2.go ratelimit.go restapi.go state.go structs.go types.go user.go util.go voice.go wsapi.go

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 (
    MessageActivityTypeJoin = iota + 1
    MessageActivityTypeSpectate
    MessageActivityTypeListen
    MessageActivityTypeJoinRequest
)

Constants for the different types of Message Activity

const (
    // This message has been published to subscribed channels (via Channel Following)
    MessageFlagCrossposted = 1 << iota
    // This message originated from a message in another channel (via Channel Following)
    MessageFlagIsCrosspost
    // Do not include any embeds when serializing this message
    MessageFlagSuppressEmbeds
)

Constants for the different bit offsets of Message Flags

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
    PermissionAll = PermissionAllChannel |
        PermissionKickMembers |
        PermissionBanMembers |
        PermissionManageServer |
        PermissionAdministrator |
        PermissionManageWebhooks |
        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

    ErrCodeUnauthorized = 40001

    ErrCodeMissingAccess                             = 50001
    ErrCodeInvalidAccountType                        = 50002
    ErrCodeCannotExecuteActionOnDMChannel            = 50003
    ErrCodeEmbedDisabled                             = 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 FailedHeartbeatAcks time.Duration = 5 * time.Millisecond

FailedHeartbeatAcks is the Number of heartbeat intervals to wait until forcing a connection restart.

const VERSION = "0.20.1"

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/"
    EndpointCDNBanners      = EndpointCDN + "banners/"

    EndpointAuth           = EndpointAPI + "auth/"
    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, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".png" }
    EndpointUserAvatarAnimated = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".gif" }
    EndpointDefaultUserAvatar  = func(uDiscriminator string) string {
        uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator)
        return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png"
    }
    EndpointUserSettings      = func(uID string) string { return EndpointUsers + uID + "/settings" }
    EndpointUserGuilds        = func(uID string) string { return EndpointUsers + uID + "/guilds" }
    EndpointUserGuild         = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
    EndpointUserGuildSettings = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + 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 string) string { return EndpointUsers + "@me/notes/" + uID }

    EndpointGuild                = func(gID string) string { return EndpointGuilds + gID }
    EndpointGuildChannels        = func(gID string) string { return EndpointGuilds + gID + "/channels" }
    EndpointGuildMembers         = func(gID string) string { return EndpointGuilds + gID + "/members" }
    EndpointGuildMember          = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
    EndpointGuildMemberRole      = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
    EndpointGuildBans            = func(gID string) string { return EndpointGuilds + gID + "/bans" }
    EndpointGuildBan             = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
    EndpointGuildIntegrations    = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
    EndpointGuildIntegration     = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
    EndpointGuildIntegrationSync = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID + "/sync" }
    EndpointGuildRoles           = func(gID string) string { return EndpointGuilds + gID + "/roles" }
    EndpointGuildRole            = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
    EndpointGuildInvites         = func(gID string) string { return EndpointGuilds + gID + "/invites" }
    EndpointGuildEmbed           = func(gID string) string { return EndpointGuilds + gID + "/embed" }
    EndpointGuildPrune           = func(gID string) string { return EndpointGuilds + gID + "/prune" }
    EndpointGuildIcon            = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
    EndpointGuildIconAnimated    = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
    EndpointGuildSplash          = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
    EndpointGuildWebhooks        = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
    EndpointGuildAuditLogs       = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
    EndpointGuildEmojis          = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
    EndpointGuildEmoji           = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
    EndpointGuildBanner          = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }

    EndpointChannel                   = func(cID string) string { return EndpointChannels + cID }
    EndpointChannelPermissions        = func(cID string) string { return EndpointChannels + cID + "/permissions" }
    EndpointChannelPermission         = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
    EndpointChannelInvites            = func(cID string) string { return EndpointChannels + cID + "/invites" }
    EndpointChannelTyping             = func(cID string) string { return EndpointChannels + cID + "/typing" }
    EndpointChannelMessages           = func(cID string) string { return EndpointChannels + cID + "/messages" }
    EndpointChannelMessage            = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
    EndpointChannelMessageAck         = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID + "/ack" }
    EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
    EndpointChannelMessagesPins       = func(cID string) string { return EndpointChannel(cID) + "/pins" }
    EndpointChannelMessagePin         = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }

    EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }

    EndpointChannelWebhooks = func(cID string) string { return EndpointChannel(cID) + "/webhooks" }
    EndpointWebhook         = func(wID string) string { return EndpointWebhooks + wID }
    EndpointWebhookToken    = func(wID, token string) string { return EndpointWebhooks + wID + "/" + token }

    EndpointMessageReactionsAll = func(cID, mID string) string {
        return EndpointChannelMessage(cID, mID) + "/reactions"
    }
    EndpointMessageReactions = func(cID, mID, eID string) string {
        return EndpointChannelMessage(cID, mID) + "/reactions/" + eID
    }
    EndpointMessageReaction = func(cID, mID, eID, uID string) string {
        return EndpointMessageReactions(cID, mID, eID) + "/" + uID
    }

    EndpointRelationships       = func() string { return EndpointUsers + "@me" + "/relationships" }
    EndpointRelationship        = func(uID string) string { return EndpointRelationships() + "/" + uID }
    EndpointRelationshipsMutual = func(uID string) string { return EndpointUsers + 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 string) string { return EndpointAPI + "emojis/" + eID + ".png" }
    EndpointEmojiAnimated = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".gif" }

    EndpointOauth2            = EndpointAPI + "oauth2/"
    EndpointApplications      = EndpointOauth2 + "applications"
    EndpointApplication       = func(aID string) string { return EndpointApplications + "/" + aID }
    EndpointApplicationsBot   = func(aID string) string { return EndpointApplications + "/" + aID + "/bot" }
    EndpointApplicationAssets = func(aID string) string { return EndpointApplications + "/" + 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")
    ErrUnauthorized            = errors.New("" /* 245 byte string literal not displayed */)
)

All error constants

var APIVersion = "6"

APIVersion is the Discord API version used for the REST and Websocket API.

var ErrMFA = errors.New("account has 2FA enabled")

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 ErrWSAlreadyOpen = errors.New("web socket already opened")

ErrWSAlreadyOpen is thrown when you attempt to open a websocket that already is open.

var ErrWSNotFound = errors.New("no websocket connection exists")

ErrWSNotFound is thrown when you attempt to use a websocket that doesn't exist

var ErrWSShardBounds = errors.New("ShardID must be less than ShardCount")

ErrWSShardBounds is thrown when you try to use a shard ID that is less than the total shard count

var Logger func(msgL, caller int, format string, a ...interface{})

Logger can be used to replace the standard logging for discordgo

func SnowflakeTimestamp Uses

func SnowflakeTimestamp(ID string) (t time.Time, err error)

SnowflakeTimestamp returns the creation time of a Snowflake ID relative to the creation of Discord.

type APIErrorMessage Uses

type APIErrorMessage struct {
    Code    int    `json:"code"`
    Message string `json:"message"`
}

An APIErrorMessage is an api error message returned from discord

type Ack Uses

type Ack struct {
    Token string `json:"token"`
}

An Ack is used to ack messages

type Application Uses

type Application struct {
    ID                  string    `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

Code:


// Authentication Token pulled from environment variable DGU_TOKEN
Token := os.Getenv("DGU_TOKEN")
if Token == "" {
    return
}

// Create a new Discordgo session
dg, err := discordgo.New(Token)
if err != nil {
    log.Println(err)
    return
}

// Create an new Application
ap := &discordgo.Application{}
ap.Name = "TestApp"
ap.Description = "TestDesc"
ap, err = dg.ApplicationCreate(ap)
log.Printf("ApplicationCreate: err: %+v, app: %+v\n", err, ap)

// Get a specific Application by it's ID
ap, err = dg.Application(ap.ID)
log.Printf("Application: err: %+v, app: %+v\n", err, ap)

// Update an existing Application with new values
ap.Description = "Whooooa"
ap, err = dg.ApplicationUpdate(ap.ID, ap)
log.Printf("ApplicationUpdate: err: %+v, app: %+v\n", err, ap)

// create a new bot account for this application
bot, err := dg.ApplicationBotCreate(ap.ID)
log.Printf("BotCreate: err: %+v, bot: %+v\n", err, bot)

// Get a list of all applications for the authenticated user
apps, err := dg.Applications()
log.Printf("Applications: err: %+v, apps : %+v\n", err, apps)
for k, v := range apps {
    log.Printf("Applications: %d : %+v\n", k, v)
}

// Delete the application we created.
err = dg.ApplicationDelete(ap.ID)
log.Printf("Delete: err: %+v\n", err)

return

type Asset Uses

type Asset struct {
    Type int    `json:"type"`
    ID   string `json:"id"`
    Name string `json:"name"`
}

Asset struct stores values for an asset of an application

type Assets Uses

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

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)

func (*Bucket) Release Uses

func (b *Bucket) Release(headers http.Header) error

Release unlocks the bucket and reads the headers to update the buckets ratelimit info and locks up the whole thing in case if there's a global ratelimit.

type Channel Uses

type Channel struct {
    // The ID of the channel.
    ID  string `json:"id"`

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

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

    // The timestamp of the last pinned message in the channel.
    // Empty if the channel has no pinned messages.
    LastPinTimestamp Timestamp `json:"last_pin_timestamp"`

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

    // Amount of seconds a user has to wait before sending another message (0-21600)
    // bots, as well as users with the permission manage_messages or manage_channel, are unaffected
    RateLimitPerUser int `json:"rate_limit_per_user"`
}

A Channel holds all data related to an individual Discord channel.

func (*Channel) Mention Uses

func (c *Channel) Mention() string

Mention returns a string which mentions the channel

type ChannelCreate Uses

type ChannelCreate struct {
    *Channel
}

ChannelCreate is the data for a ChannelCreate event.

type ChannelDelete Uses

type ChannelDelete struct {
    *Channel
}

ChannelDelete is the data for a ChannelDelete event.

type ChannelEdit Uses

type ChannelEdit struct {
    Name                 string                 `json:"name,omitempty"`
    Topic                string                 `json:"topic,omitempty"`
    NSFW                 bool                   `json:"nsfw,omitempty"`
    Position             int                    `json:"position"`
    Bitrate              int                    `json:"bitrate,omitempty"`
    UserLimit            int                    `json:"user_limit,omitempty"`
    PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
    ParentID             string                 `json:"parent_id,omitempty"`
    RateLimitPerUser     int                    `json:"rate_limit_per_user,omitempty"`
}

A ChannelEdit holds Channel Field data for a channel edit.

type ChannelPinsUpdate Uses

type ChannelPinsUpdate struct {
    LastPinTimestamp string `json:"last_pin_timestamp"`
    ChannelID        string `json:"channel_id"`
    GuildID          string `json:"guild_id,omitempty"`
}

ChannelPinsUpdate stores data for a ChannelPinsUpdate event.

type ChannelType Uses

type ChannelType int

ChannelType is the type of a Channel

const (
    ChannelTypeGuildText ChannelType = iota
    ChannelTypeDM
    ChannelTypeGuildVoice
    ChannelTypeGroupDM
    ChannelTypeGuildCategory
    ChannelTypeGuildNews
    ChannelTypeGuildStore
)

Block contains known ChannelType values

type ChannelUpdate Uses

type ChannelUpdate struct {
    *Channel
}

ChannelUpdate is the data for a ChannelUpdate event.

type Connect Uses

type Connect struct{}

Connect is the data for a Connect event. This is a synthetic event and is not dispatched by Discord.

type Disconnect Uses

type Disconnect struct{}

Disconnect is the data for a Disconnect event. This is a synthetic event and is not dispatched by Discord.

type Emoji Uses

type Emoji struct {
    ID            string   `json:"id"`
    Name          string   `json:"name"`
    Roles         []string `json:"roles"`
    Managed       bool     `json:"managed"`
    RequireColons bool     `json:"require_colons"`
    Animated      bool     `json:"animated"`
    Available     bool     `json:"available"`
}

Emoji struct holds data related to Emoji's

func (*Emoji) APIName Uses

func (e *Emoji) APIName() string

APIName returns an correctly formatted API name for use in the MessageReactions endpoints.

func (*Emoji) MessageFormat Uses

func (e *Emoji) MessageFormat() string

MessageFormat returns a correctly formatted Emoji for use in Message content and embeds

type Event Uses

type Event struct {
    Operation int             `json:"op"`
    Sequence  int64           `json:"s"`
    Type      string          `json:"t"`
    RawData   json.RawMessage `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 Uses

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 Uses

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 Uses

type ExplicitContentFilterLevel int

ExplicitContentFilterLevel type definition

const (
    ExplicitContentFilterDisabled ExplicitContentFilterLevel = iota
    ExplicitContentFilterMembersWithoutRoles
    ExplicitContentFilterAllMembers
)

Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive

type File Uses

type File struct {
    Name        string
    ContentType string
    Reader      io.Reader
}

File stores info about files you e.g. send in messages.

type FriendSourceFlags Uses

type FriendSourceFlags struct {
    All           bool `json:"all"`
    MutualGuilds  bool `json:"mutual_guilds"`
    MutualFriends bool `json:"mutual_friends"`
}

FriendSourceFlags stores ... TODO :)

type Game Uses

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 Uses

type GameType int

GameType is the type of "game" (see GameType* consts) in the Game struct

const (
    GameTypeGame GameType = iota
    GameTypeStreaming
    GameTypeListening
    GameTypeWatching
)

Valid GameType values

type GatewayBotResponse Uses

type GatewayBotResponse struct {
    URL    string `json:"url"`
    Shards int    `json:"shards"`
}

GatewayBotResponse stores the data for the gateway/bot response

type Guild Uses

type Guild struct {
    // The ID of the guild.
    ID  string `json:"id"`

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

    // The ID of the embed channel ID, used for embed widgets.
    EmbedChannelID string `json:"embed_channel_id"`

    // The user ID of the owner of the guild.
    OwnerID string `json:"owner_id"`

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

    // Whether this guild is currently unavailable (most likely due to outage).
    // 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"`

    // the vanity url code for the guild
    VanityURLCode string `json:"vanity_url_code"`

    // the description for the guild
    Description string `json:"description"`

    // The hash of the guild's banner
    Banner string `json:"banner"`

    // The premium tier of the guild
    PremiumTier PremiumTier `json:"premium_tier"`

    // The total number of users currently boosting this server
    PremiumSubscriptionCount int `json:"premium_subscription_count"`
}

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

func (g *Guild) IconURL() string

IconURL returns a URL to the guild's icon.

type GuildAuditLog Uses

type GuildAuditLog struct {
    Webhooks []struct {
        ChannelID string `json:"channel_id"`
        GuildID   string `json:"guild_id"`
        ID        string `json:"id"`
        Avatar    string `json:"avatar"`
        Name      string `json:"name"`
    }   `json:"webhooks,omitempty"`
    Users []struct {
        Username      string `json:"username"`
        Discriminator string `json:"discriminator"`
        Bot           bool   `json:"bot"`
        ID            string `json:"id"`
        Avatar        string `json:"avatar"`
    }   `json:"users,omitempty"`
    AuditLogEntries []struct {
        TargetID string `json:"target_id"`
        Changes  []struct {
            NewValue interface{} `json:"new_value"`
            OldValue interface{} `json:"old_value"`
            Key      string      `json:"key"`
        }   `json:"changes,omitempty"`
        UserID     string `json:"user_id"`
        ID         string `json:"id"`
        ActionType int    `json:"action_type"`
        Options    struct {
            DeleteMembersDay string `json:"delete_member_days"`
            MembersRemoved   string `json:"members_removed"`
            ChannelID        string `json:"channel_id"`
            Count            string `json:"count"`
            ID               string `json:"id"`
            Type             string `json:"type"`
            RoleName         string `json:"role_name"`
        }   `json:"options,omitempty"`
        Reason string `json:"reason"`
    }   `json:"audit_log_entries"`
}

A GuildAuditLog stores data for a guild audit log.

type GuildBan Uses

type GuildBan struct {
    Reason string `json:"reason"`
    User   *User  `json:"user"`
}

A GuildBan stores data for a guild ban.

type GuildBanAdd Uses

type GuildBanAdd struct {
    User    *User  `json:"user"`
    GuildID string `json:"guild_id"`
}

GuildBanAdd is the data for a GuildBanAdd event.

type GuildBanRemove Uses

type GuildBanRemove struct {
    User    *User  `json:"user"`
    GuildID string `json:"guild_id"`
}

GuildBanRemove is the data for a GuildBanRemove event.

type GuildChannelCreateData Uses

type GuildChannelCreateData struct {
    Name                 string                 `json:"name"`
    Type                 ChannelType            `json:"type"`
    Topic                string                 `json:"topic,omitempty"`
    Bitrate              int                    `json:"bitrate,omitempty"`
    UserLimit            int                    `json:"user_limit,omitempty"`
    PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
    ParentID             string                 `json:"parent_id,omitempty"`
    NSFW                 bool                   `json:"nsfw,omitempty"`
}

GuildChannelCreateData is provided to GuildChannelCreateComplex

type GuildCreate Uses

type GuildCreate struct {
    *Guild
}

GuildCreate is the data for a GuildCreate event.

type GuildDelete Uses

type GuildDelete struct {
    *Guild
}

GuildDelete is the data for a GuildDelete event.

type GuildEmbed Uses

type GuildEmbed struct {
    Enabled   bool   `json:"enabled"`
    ChannelID string `json:"channel_id"`
}

A GuildEmbed stores data for a guild embed.

type GuildEmojisUpdate Uses

type GuildEmojisUpdate struct {
    GuildID string   `json:"guild_id"`
    Emojis  []*Emoji `json:"emojis"`
}

A GuildEmojisUpdate is the data for a guild emoji update event.

type GuildIntegrationsUpdate Uses

type GuildIntegrationsUpdate struct {
    GuildID string `json:"guild_id"`
}

GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event.

type GuildMemberAdd Uses

type GuildMemberAdd struct {
    *Member
}

GuildMemberAdd is the data for a GuildMemberAdd event.

type GuildMemberRemove Uses

type GuildMemberRemove struct {
    *Member
}

GuildMemberRemove is the data for a GuildMemberRemove event.

type GuildMemberUpdate Uses

type GuildMemberUpdate struct {
    *Member
}

GuildMemberUpdate is the data for a GuildMemberUpdate event.

type GuildMembersChunk Uses

type GuildMembersChunk struct {
    GuildID string    `json:"guild_id"`
    Members []*Member `json:"members"`
}

A GuildMembersChunk is the data for a GuildMembersChunk event.

type GuildParams Uses

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                string             `json:"afk_channel_id,omitempty"`
    AfkTimeout                  int                `json:"afk_timeout,omitempty"`
    Icon                        string             `json:"icon,omitempty"`
    OwnerID                     string             `json:"owner_id,omitempty"`
    Splash                      string             `json:"splash,omitempty"`
}

A GuildParams stores all the data needed to update discord guild settings

type GuildRole Uses

type GuildRole struct {
    Role    *Role  `json:"role"`
    GuildID string `json:"guild_id"`
}

A GuildRole stores data for guild roles.

type GuildRoleCreate Uses

type GuildRoleCreate struct {
    *GuildRole
}

GuildRoleCreate is the data for a GuildRoleCreate event.

type GuildRoleDelete Uses

type GuildRoleDelete struct {
    RoleID  string `json:"role_id"`
    GuildID string `json:"guild_id"`
}

A GuildRoleDelete is the data for a GuildRoleDelete event.

type GuildRoleUpdate Uses

type GuildRoleUpdate struct {
    *GuildRole
}

GuildRoleUpdate is the data for a GuildRoleUpdate event.

type GuildUpdate Uses

type GuildUpdate struct {
    *Guild
}

GuildUpdate is the data for a GuildUpdate event.

type ICEServer Uses

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

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 Uses

type IntegrationAccount struct {
    ID   string `json:"id"`
    Name string `json:"name"`
}

IntegrationAccount is integration account information sent by the UserConnections endpoint

type Invite Uses

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

type Member struct {
    // The guild ID on which the member exists.
    GuildID string `json:"guild_id"`

    // 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 []string `json:"roles"`

    // When the user used their Nitro boost on the server
    PremiumSince Timestamp `json:"premium_since"`
}

A Member stores user information for Guild members. A guild member represents a certain user's presence in a guild.

func (*Member) Mention Uses

func (m *Member) Mention() string

Mention creates a member mention

type Message Uses

type Message struct {
    // The ID of the message.
    ID  string `json:"id"`

    // The ID of the channel in which the message was sent.
    ChannelID string `json:"channel_id"`

    // The ID of the guild in which the message was sent.
    GuildID string `json:"guild_id,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 []string `json:"mention_roles"`

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

    // Whether the message is pinned or not.
    Pinned bool `json:"pinned"`

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

    // The webhook ID of the message, if it was generated by a webhook
    WebhookID string `json:"webhook_id"`

    // Member properties for this message's author,
    // contains only partial information
    Member *Member `json:"member"`

    // Channels specifically mentioned in this message
    // Not all channel mentions in a message will appear in mention_channels.
    // Only textual channels that are visible to everyone in a lurkable guild will ever be included.
    // Only crossposted messages (via Channel Following) currently include mention_channels at all.
    // If no mentions in the message meet these requirements, this field will not be sent.
    MentionChannels []*Channel `json:"mention_channels"`

    // Is sent with Rich Presence-related chat embeds
    Activity *MessageActivity `json:"activity"`

    // Is sent with Rich Presence-related chat embeds
    Application *MessageApplication `json:"application"`

    // MessageReference contains reference data sent with crossposted messages
    MessageReference *MessageReference `json:"message_reference"`

    // The flags of the message, which describe extra features of a message.
    // 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 flag.
    Flags int `json:"flags"`
}

A Message stores all data related to a specific Discord message.

func (*Message) ContentWithMentionsReplaced Uses

func (m *Message) ContentWithMentionsReplaced() (content string)

ContentWithMentionsReplaced will replace all @<id> mentions with the username of the mention.

func (*Message) ContentWithMoreMentionsReplaced Uses

func (m *Message) ContentWithMoreMentionsReplaced(s *Session) (content string, err error)

ContentWithMoreMentionsReplaced will replace all @<id> mentions with the username of the mention, but also role IDs and more.

type MessageAck Uses

type MessageAck struct {
    MessageID string `json:"message_id"`
    ChannelID string `json:"channel_id"`
}

MessageAck is the data for a MessageAck event.

type MessageActivity Uses

type MessageActivity struct {
    Type    MessageActivityType `json:"type"`
    PartyID string              `json:"party_id"`
}

MessageActivity is sent with Rich Presence-related chat embeds

type MessageActivityType Uses

type MessageActivityType int

MessageActivityType is the type of message activity

type MessageApplication Uses

type MessageApplication struct {
    ID          string `json:"id"`
    CoverImage  string `json:"cover_image"`
    Description string `json:"description"`
    Icon        string `json:"icon"`
    Name        string `json:"name"`
}

MessageApplication is sent with Rich Presence-related chat embeds

type MessageAttachment Uses

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 Uses

type MessageCreate struct {
    *Message
}

MessageCreate is the data for a MessageCreate event.

type MessageDelete Uses

type MessageDelete struct {
    *Message
}

MessageDelete is the data for a MessageDelete event.

type MessageDeleteBulk Uses

type MessageDeleteBulk struct {
    Messages  []string `json:"ids"`
    ChannelID string   `json:"channel_id"`
    GuildID   string   `json:"guild_id"`
}

MessageDeleteBulk is the data for a MessageDeleteBulk event

type MessageEdit Uses

type MessageEdit struct {
    Content *string       `json:"content,omitempty"`
    Embed   *MessageEmbed `json:"embed,omitempty"`

    ID      string
    Channel string
}

MessageEdit is used to chain parameters via ChannelMessageEditComplex, which is also where you should get the instance from.

func NewMessageEdit Uses

func NewMessageEdit(channelID string, messageID string) *MessageEdit

NewMessageEdit returns a MessageEdit struct, initialized with the Channel and ID.

func (*MessageEdit) SetContent Uses

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 Uses

func (m *MessageEdit) SetEmbed(embed *MessageEmbed) *MessageEdit

SetEmbed is a convenience function for setting the embed, so you can chain commands.

type MessageEmbed Uses

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"`
    Footer      *MessageEmbedFooter    `json:"footer,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 Uses

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 Uses

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 Uses

type MessageEmbedFooter struct {
    Text         string `json:"text,omitempty"`
    IconURL      string `json:"icon_url,omitempty"`
    ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

MessageEmbedFooter is a part of a MessageEmbed struct.

type MessageEmbedImage Uses

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 Uses

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

MessageEmbedProvider is a part of a MessageEmbed struct.

type MessageEmbedThumbnail Uses

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 Uses

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

type MessageFlag int

MessageFlag describes an extra feature of the message

type MessageReaction Uses

type MessageReaction struct {
    UserID    string `json:"user_id"`
    MessageID string `json:"message_id"`
    Emoji     Emoji  `json:"emoji"`
    ChannelID string `json:"channel_id"`
    GuildID   string `json:"guild_id,omitempty"`
}

MessageReaction stores the data for a message reaction.

type MessageReactionAdd Uses

type MessageReactionAdd struct {
    *MessageReaction
}

MessageReactionAdd is the data for a MessageReactionAdd event.

type MessageReactionRemove Uses

type MessageReactionRemove struct {
    *MessageReaction
}

MessageReactionRemove is the data for a MessageReactionRemove event.

type MessageReactionRemoveAll Uses

type MessageReactionRemoveAll struct {
    *MessageReaction
}

MessageReactionRemoveAll is the data for a MessageReactionRemoveAll event.

type MessageReactions Uses

type MessageReactions struct {
    Count int    `json:"count"`
    Me    bool   `json:"me"`
    Emoji *Emoji `json:"emoji"`
}

MessageReactions holds a reactions object for a message.

type MessageReference Uses

type MessageReference struct {
    MessageID string `json:"message_id"`
    ChannelID string `json:"channel_id"`
    GuildID   string `json:"guild_id"`
}

MessageReference contains reference data sent with crossposted messages

type MessageSend Uses

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 Uses

type MessageType int

MessageType is the type of Message

const (
    MessageTypeDefault MessageType = iota
    MessageTypeRecipientAdd
    MessageTypeRecipientRemove
    MessageTypeCall
    MessageTypeChannelNameChange
    MessageTypeChannelIconChange
    MessageTypeChannelPinnedMessage
    MessageTypeGuildMemberJoin
    MessageTypeUserPremiumGuildSubscription
    MessageTypeUserPremiumGuildSubscriptionTierOne
    MessageTypeUserPremiumGuildSubscriptionTierTwo
    MessageTypeUserPremiumGuildSubscriptionTierThree
    MessageTypeChannelFollowAdd
)

Block contains the valid known MessageType values

type MessageUpdate Uses

type MessageUpdate struct {
    *Message
    // BeforeUpdate will be nil if the Message was not previously cached in the state cache.
    BeforeUpdate *Message `json:"-"`
}

MessageUpdate is the data for a MessageUpdate event.

type MfaLevel Uses

type MfaLevel int

MfaLevel type definition

const (
    MfaLevelNone MfaLevel = iota
    MfaLevelElevated
)

Constants for MfaLevel levels from 0 to 1 inclusive

type Packet Uses

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 Uses

type PermissionOverwrite struct {
    ID    string `json:"id"`
    Type  string `json:"type"`
    Deny  int    `json:"deny"`
    Allow int    `json:"allow"`
}

A PermissionOverwrite holds permission overwrite data for a Channel

type PremiumTier Uses

type PremiumTier int

PremiumTier type definition

const (
    PremiumTierNone PremiumTier = iota
    PremiumTier1
    PremiumTier2
    PremiumTier3
)

Constants for PremiumTier levels from 0 to 3 inclusive

type Presence Uses

type Presence struct {
    User   *User    `json:"user"`
    Status Status   `json:"status"`
    Game   *Game    `json:"game"`
    Nick   string   `json:"nick"`
    Roles  []string `json:"roles"`
    Since  *int     `json:"since"`
}

A Presence stores the online, offline, or idle and game status of Guild members.

type PresenceUpdate Uses

type PresenceUpdate struct {
    Presence
    GuildID string   `json:"guild_id"`
    Roles   []string `json:"roles"`
}

PresenceUpdate is the data for a PresenceUpdate event.

type PresencesReplace Uses

type PresencesReplace []*Presence

PresencesReplace is the data for a PresencesReplace event.

type RESTError Uses

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.

func (RESTError) Error Uses

func (r RESTError) Error() string

type RateLimit Uses

type RateLimit struct {
    *TooManyRequests
    URL string
}

RateLimit is the data for a RateLimit event. This is a synthetic event and is not dispatched by Discord.

type RateLimiter Uses

type RateLimiter struct {
    sync.Mutex
    // contains filtered or unexported fields
}

RateLimiter holds all ratelimit buckets

func NewRatelimiter Uses

func NewRatelimiter() *RateLimiter

NewRatelimiter returns a new RateLimiter

func (*RateLimiter) GetBucket Uses

func (r *RateLimiter) GetBucket(key string) *Bucket

GetBucket retrieves or creates a bucket

func (*RateLimiter) GetWaitTime Uses

func (r *RateLimiter) GetWaitTime(b *Bucket, minRemaining int) time.Duration

GetWaitTime returns the duration you should wait for a Bucket

func (*RateLimiter) LockBucket Uses

func (r *RateLimiter) LockBucket(bucketID string) *Bucket

LockBucket Locks until a request can be made

func (*RateLimiter) LockBucketObject Uses

func (r *RateLimiter) LockBucketObject(b *Bucket) *Bucket

LockBucketObject Locks an already resolved bucket until a request can be made

type ReadState Uses

type ReadState struct {
    MentionCount  int    `json:"mention_count"`
    LastMessageID string `json:"last_message_id"`
    ID            string `json:"id"`
}

A ReadState stores data on the read state of channels.

type Ready Uses

type Ready struct {
    Version         int          `json:"v"`
    SessionID       string       `json:"session_id"`
    User            *User        `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 Uses

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 Uses

type RelationshipAdd struct {
    *Relationship
}

RelationshipAdd is the data for a RelationshipAdd event.

type RelationshipRemove Uses

type RelationshipRemove struct {
    *Relationship
}

RelationshipRemove is the data for a RelationshipRemove event.

type Resumed Uses

type Resumed struct {
    Trace []string `json:"_trace"`
}

Resumed is the data for a Resumed event.

type Role Uses

type Role struct {
    // The ID of the role.
    ID  string `json:"id"`

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

func (*Role) Mention Uses

func (r *Role) Mention() string

Mention returns a string which mentions the role

type Roles Uses

type Roles []*Role

Roles are a collection of Role

func (Roles) Len Uses

func (r Roles) Len() int

func (Roles) Less Uses

func (r Roles) Less(i, j int) bool

func (Roles) Swap Uses

func (r Roles) Swap(i, j int)

type Session Uses

type Session struct {
    sync.RWMutex

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

    // Whether the Data Websocket is ready
    DataReady bool // NOTE: Maye be deprecated soon

    // Max number of REST API retries
    MaxRestRetries int

    // Whether the Voice Websocket is ready
    VoiceReady bool // NOTE: Deprecated.

    // Whether the UDP Connection is ready
    UDPReady bool // NOTE: Deprecated

    // Stores a mapping of guild id's to VoiceConnections
    VoiceConnections map[string]*VoiceConnection

    // Managed state object, updated internally with events when
    // StateEnabled is true.
    State *State

    // The http client used for REST requests
    Client *http.Client

    // The user agent used for REST APIs
    UserAgent string

    // Stores the last HeartbeatAck that was recieved (in UTC)
    LastHeartbeatAck time.Time

    // Stores the last Heartbeat sent (in UTC)
    LastHeartbeatSent time.Time

    // used to deal with rate limits
    Ratelimiter *RateLimiter
    // contains filtered or unexported fields
}

A Session represents a connection to the Discord API.

func New Uses

func New(args ...interface{}) (s *Session, err error)

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 Uses

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 Uses

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 Uses

func (s *Session) Application(appID string) (st *Application, err error)

Application returns an Application structure of a specific Application

appID : The ID of an Application

func (*Session) ApplicationAssets Uses

func (s *Session) ApplicationAssets(appID string) (ass []*Asset, err error)

ApplicationAssets returns an application's assets

func (*Session) ApplicationBotCreate Uses

func (s *Session) ApplicationBotCreate(appID string) (st *User, err error)

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 Uses

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 Uses

func (s *Session) ApplicationDelete(appID string) (err error)

ApplicationDelete deletes an existing Application

appID : The ID of an Application

func (*Session) ApplicationUpdate Uses

func (s *Session) ApplicationUpdate(appID string, ap *Application) (st *Application, err error)

ApplicationUpdate updates an existing Application

var : desc

func (*Session) Applications Uses

func (s *Session) Applications() (st []*Application, err error)

Applications returns all applications for the authenticated user

func (*Session) Channel Uses

func (s *Session) Channel(channelID string) (st *Channel, err error)

Channel returns a Channel structure of a specific Channel. channelID : The ID of the Channel you want returned.

func (*Session) ChannelDelete Uses

func (s *Session) ChannelDelete(channelID string) (st *Channel, err error)

ChannelDelete deletes the given channel channelID : The ID of a Channel

func (*Session) ChannelEdit Uses

func (s *Session) ChannelEdit(channelID, name string) (*Channel, error)

ChannelEdit edits the given channel channelID : The ID of a Channel name : The new name to assign the channel.

func (*Session) ChannelEditComplex Uses

func (s *Session) ChannelEditComplex(channelID string, 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 Uses

func (s *Session) ChannelFileSend(channelID, name string, r io.Reader) (*Message, error)

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 Uses

func (s *Session) ChannelFileSendWithMessage(channelID, 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 Uses

func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st *Invite, err error)

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 Uses

func (s *Session) ChannelInvites(channelID string) (st []*Invite, err error)

ChannelInvites returns an array of Invite structures for the given channel channelID : The ID of a Channel

func (*Session) ChannelMessage Uses

func (s *Session) ChannelMessage(channelID, messageID string) (st *Message, err error)

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 Uses

func (s *Session) ChannelMessageAck(channelID, messageID, 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 Uses

func (s *Session) ChannelMessageDelete(channelID, messageID string) (err error)

ChannelMessageDelete deletes a message from the Channel.

func (*Session) ChannelMessageEdit Uses

func (s *Session) ChannelMessageEdit(channelID, messageID, content string) (*Message, error)

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 Uses

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 Uses

func (s *Session) ChannelMessageEditEmbed(channelID, messageID string, 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 Uses

func (s *Session) ChannelMessagePin(channelID, messageID string) (err error)

ChannelMessagePin pins a message within a given channel. channelID: The ID of a channel. messageID: The ID of a message.

func (*Session) ChannelMessageSend Uses

func (s *Session) ChannelMessageSend(channelID string, content string) (*Message, error)

ChannelMessageSend sends a message to the given channel. channelID : The ID of a Channel. content : The message to send.

func (*Session) ChannelMessageSendComplex Uses

func (s *Session) ChannelMessageSendComplex(channelID string, 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 Uses

func (s *Session) ChannelMessageSendEmbed(channelID string, 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 Uses

func (s *Session) ChannelMessageSendTTS(channelID string, content string) (*Message, error)

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 Uses

func (s *Session) ChannelMessageUnpin(channelID, messageID string) (err error)

ChannelMessageUnpin unpins a message within a given channel. channelID: The ID of a channel. messageID: The ID of a message.

func (*Session) ChannelMessages Uses

func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) (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 Uses

func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) (err error)

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 string IDs. A maximum of 100 messages.

func (*Session) ChannelMessagesPinned Uses

func (s *Session) ChannelMessagesPinned(channelID string) (st []*Message, err error)

ChannelMessagesPinned returns an array of Message structures for pinned messages within a given channel channelID : The ID of a Channel.

func (*Session) ChannelPermissionDelete Uses

func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error)

ChannelPermissionDelete deletes a specific permission override for the given channel. NOTE: Name of this func may change.

func (*Session) ChannelPermissionSet Uses

func (s *Session) ChannelPermissionSet(channelID, targetID, 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 Uses

func (s *Session) ChannelTyping(channelID string) (err error)

ChannelTyping broadcasts to all members that authenticated user is typing in the given channel. channelID : The ID of a Channel

func (*Session) ChannelVoiceJoin Uses

func (s *Session) ChannelVoiceJoin(gID, cID string, 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 (*Session) ChannelVoiceJoinManual Uses

func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error)

ChannelVoiceJoinManual initiates a voice session to a voice channel, but does not complete it.

This should only be used when the VoiceServerUpdate will be intercepted and used elsewhere.

gID     : Guild ID of the channel to join.
cID     : Channel ID of the channel to join, leave empty to disconnect.
mute    : If true, you will be set to muted upon joining.
deaf    : If true, you will be set to deafened upon joining.

func (*Session) ChannelWebhooks Uses

func (s *Session) ChannelWebhooks(channelID string) (st []*Webhook, err error)

ChannelWebhooks returns all webhooks for a given channel. channelID: The ID of a channel.

func (*Session) Close Uses

func (s *Session) Close() (err error)

Close closes a websocket and stops all listening/heartbeat goroutines. TODO: Add support for Voice WS/UDP connections

func (*Session) Gateway Uses

func (s *Session) Gateway() (gateway string, err error)

Gateway returns the websocket Gateway address

func (*Session) GatewayBot Uses

func (s *Session) GatewayBot() (st *GatewayBotResponse, err error)

GatewayBot returns the websocket Gateway address and the recommended number of shards

func (*Session) Guild Uses

func (s *Session) Guild(guildID string) (st *Guild, err error)

Guild returns a Guild structure of a specific Guild. guildID : The ID of a Guild

func (*Session) GuildAuditLog Uses

func (s *Session) GuildAuditLog(guildID, userID, beforeID string, 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 Uses

func (s *Session) GuildBanCreate(guildID, userID string, days int) (err error)

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 Uses

func (s *Session) GuildBanCreateWithReason(guildID, userID, 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 Uses

func (s *Session) GuildBanDelete(guildID, userID string) (err error)

GuildBanDelete removes the given user from the guild bans guildID : The ID of a Guild. userID : The ID of a User

func (*Session) GuildBans Uses

func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error)

GuildBans returns an array of GuildBan structures for all bans of a given guild. guildID : The ID of a Guild.

func (*Session) GuildChannelCreate Uses

func (s *Session) GuildChannelCreate(guildID, 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) GuildChannelCreateComplex Uses

func (s *Session) GuildChannelCreateComplex(guildID string, data GuildChannelCreateData) (st *Channel, err error)

GuildChannelCreateComplex creates a new channel in the given guild guildID : The ID of a Guild data : A data struct describing the new Channel, Name and Type are mandatory, other fields depending on the type

func (*Session) GuildChannels Uses

func (s *Session) GuildChannels(guildID string) (st []*Channel, err error)

GuildChannels returns an array of Channel structures for all channels of a given guild. guildID : The ID of a Guild.

func (*Session) GuildChannelsReorder Uses

func (s *Session) GuildChannelsReorder(guildID string, channels []*Channel) (err error)

GuildChannelsReorder updates the order of channels in a guild guildID : The ID of a Guild. channels : Updated channels.

func (*Session) GuildCreate Uses

func (s *Session) GuildCreate(name string) (st *Guild, err error)

GuildCreate creates a new Guild name : A name for the Guild (2-100 characters)

func (*Session) GuildDelete Uses

func (s *Session) GuildDelete(guildID string) (st *Guild, err error)

GuildDelete deletes a Guild. guildID : The ID of a Guild

func (*Session) GuildEdit Uses

func (s *Session) GuildEdit(guildID string, 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 Uses

func (s *Session) GuildEmbed(guildID string) (st *GuildEmbed, err error)

GuildEmbed returns the embed for a Guild. guildID : The ID of a Guild.

func (*Session) GuildEmbedEdit Uses

func (s *Session) GuildEmbedEdit(guildID string, enabled bool, channelID string) (err error)

GuildEmbedEdit returns the embed for a Guild. guildID : The ID of a Guild.

func (*Session) GuildEmojiCreate Uses

func (s *Session) GuildEmojiCreate(guildID, name, image string, roles []string) (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 Uses

func (s *Session) GuildEmojiDelete(guildID, emojiID string) (err error)

GuildEmojiDelete deletes an Emoji. guildID : The ID of a Guild. emojiID : The ID of an Emoji.

func (*Session) GuildEmojiEdit Uses

func (s *Session) GuildEmojiEdit(guildID, emojiID, name string, roles []string) (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 Uses

func (s *Session) GuildIcon(guildID string) (img image.Image, err error)

GuildIcon returns an image.Image of a guild icon. guildID : The ID of a Guild.

func (*Session) GuildIntegrationCreate Uses

func (s *Session) GuildIntegrationCreate(guildID, integrationType, integrationID string) (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 Uses

func (s *Session) GuildIntegrationDelete(guildID, integrationID string) (err error)

GuildIntegrationDelete removes the given integration from the Guild. guildID : The ID of a Guild. integrationID : The ID of an integration.

func (*Session) GuildIntegrationEdit Uses

func (s *Session) GuildIntegrationEdit(guildID, integrationID string, 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 Uses

func (s *Session) GuildIntegrationSync(guildID, integrationID string) (err error)

GuildIntegrationSync syncs an integration. guildID : The ID of a Guild. integrationID : The ID of an integration.

func (*Session) GuildIntegrations Uses

func (s *Session) GuildIntegrations(guildID string) (st []*Integration, err error)

GuildIntegrations returns an array of Integrations for a guild. guildID : The ID of a Guild.

func (*Session) GuildInvites Uses

func (s *Session) GuildInvites(guildID string) (st []*Invite, err error)

GuildInvites returns an array of Invite structures for the given guild guildID : The ID of a Guild.

func (*Session) GuildLeave Uses

func (s *Session) GuildLeave(guildID string) (err error)

GuildLeave leaves a Guild. guildID : The ID of a Guild

func (*Session) GuildMember Uses

func (s *Session) GuildMember(guildID, userID string) (st *Member, err error)

GuildMember returns a member of a guild.

guildID   : The ID of a Guild.
userID    : The ID of a User

func (*Session) GuildMemberAdd Uses

func (s *Session) GuildMemberAdd(accessToken, guildID, userID, nick string, roles []string, 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 Uses

func (s *Session) GuildMemberDelete(guildID, userID string) (err error)

GuildMemberDelete removes the given user from the given guild. guildID : The ID of a Guild. userID : The ID of a User

func (*Session) GuildMemberDeleteWithReason Uses

func (s *Session) GuildMemberDeleteWithReason(guildID, userID, reason string) (err error)

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 Uses

func (s *Session) GuildMemberEdit(guildID, userID string, roles []string) (err error)

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 Uses

func (s *Session) GuildMemberMove(guildID, userID, channelID string) (err error)

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 Uses

func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err error)

GuildMemberNickname updates the nickname of a guild member guildID : The ID of a guild userID : The ID of a user userID : The ID of a user or "@me" which is a shortcut of the current user ID

func (*Session) GuildMemberRoleAdd Uses

func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID string) (err error)

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 Uses

func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string) (err error)

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 Uses

func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*Member, err error)

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 Uses

func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err error)

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 Uses

func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, err error)

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 Uses

func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error)

GuildRoleCreate returns a new Guild Role. guildID: The ID of a Guild.

func (*Session) GuildRoleDelete Uses

func (s *Session) GuildRoleDelete(guildID, roleID string) (err error)

GuildRoleDelete deletes an existing role. guildID : The ID of a Guild. roleID : The ID of a Role.

func (*Session) GuildRoleEdit Uses

func (s *Session) GuildRoleEdit(guildID, roleID, 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 Uses

func (s *Session) GuildRoleReorder(guildID string, roles []*Role) (st []*Role, err error)

GuildRoleReorder reoders guild roles guildID : The ID of a Guild. roles : A list of ordered roles.

func (*Session) GuildRoles Uses

func (s *Session) GuildRoles(guildID string) (st []*Role, err error)

GuildRoles returns all roles for a given guild. guildID : The ID of a Guild.

func (*Session) GuildSplash Uses

func (s *Session) GuildSplash(guildID string) (img image.Image, err error)

GuildSplash returns an image.Image of a guild splash image. guildID : The ID of a Guild.

func (*Session) GuildWebhooks Uses

func (s *Session) GuildWebhooks(guildID string) (st []*Webhook, err error)

GuildWebhooks returns all webhooks for a given guild. guildID: The ID of a Guild.

func (*Session) HeartbeatLatency Uses

func (s *Session) HeartbeatLatency() time.Duration

HeartbeatLatency returns the latency between heartbeat acknowledgement and heartbeat send.

func (*Session) Invite Uses

func (s *Session) Invite(inviteID string) (st *Invite, err error)

Invite returns an Invite structure of the given invite inviteID : The invite code

func (*Session) InviteAccept Uses

func (s *Session) InviteAccept(inviteID string) (st *Invite, err error)

InviteAccept accepts an Invite to a Guild or Channel inviteID : The invite code

func (*Session) InviteDelete Uses

func (s *Session) InviteDelete(inviteID string) (st *Invite, err error)

InviteDelete deletes an existing invite inviteID : the code of an invite

func (*Session) InviteWithCounts Uses

func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error)

InviteWithCounts returns an Invite structure of the given invite including approximate member counts inviteID : The invite code

func (*Session) Login Uses

func (s *Session) Login(email, password string) (err error)

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 Uses

func (s *Session) Logout() (err error)

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 Uses

func (s *Session) MessageReactionAdd(channelID, messageID, emojiID string) error

MessageReactionAdd creates an emoji reaction to a message. channelID : The channel ID. messageID : The message ID. emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier.

func (*Session) MessageReactionRemove Uses

func (s *Session) MessageReactionRemove(channelID, messageID, emojiID, userID string) error

MessageReactionRemove deletes an emoji reaction to a message. channelID : The channel ID. messageID : The message ID. emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier. userID : @me or ID of the user to delete the reaction for.

func (*Session) MessageReactions Uses

func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit int) (st []*User, err error)

MessageReactions gets all the users reactions for a specific emoji. channelID : The channel ID. messageID : The message ID. emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier. limit : max number of users to return (max 100)

func (*Session) MessageReactionsRemoveAll Uses

func (s *Session) MessageReactionsRemoveAll(channelID, messageID string) error

MessageReactionsRemoveAll deletes all reactions from a message channelID : The channel ID messageID : The message ID.

func (*Session) Open Uses

func (s *Session) Open() error

Open creates a websocket connection to Discord. See: https://discordapp.com/developers/docs/topics/gateway#connecting

func (*Session) Register Uses

func (s *Session) Register(username string) (token string, err error)

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 Uses

func (s *Session) RelationshipDelete(userID string) (err error)

RelationshipDelete removes the relationship with a user. userID: ID of the user.

func (*Session) RelationshipFriendRequestAccept Uses

func (s *Session) RelationshipFriendRequestAccept(userID string) (err error)

RelationshipFriendRequestAccept accepts a friend request from a user. userID: ID of the user.

func (*Session) RelationshipFriendRequestSend Uses

func (s *Session) RelationshipFriendRequestSend(userID string) (err error)

RelationshipFriendRequestSend sends a friend request to a user. userID: ID of the user.

func (*Session) RelationshipUserBlock Uses

func (s *Session) RelationshipUserBlock(userID string) (err error)

RelationshipUserBlock blocks a user. userID: ID of the user.

func (*Session) RelationshipsGet Uses

func (s *Session) RelationshipsGet() (r []*Relationship, err error)

RelationshipsGet returns an array of all the relationships of the user.

func (*Session) RelationshipsMutualGet Uses

func (s *Session) RelationshipsMutualGet(userID string) (mf []*User, err error)

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 Uses

func (s *Session) Request(method, urlStr string, data interface{}) (response []byte, err error)

Request is the same as RequestWithBucketID but the bucket id is the same as the urlStr

func (*Session) RequestGuildMembers Uses

func (s *Session) RequestGuildMembers(guildID, query string, limit int) (err error)

RequestGuildMembers requests guild members from the gateway The gateway responds with GuildMembersChunk events guildID : The ID of the guild to request members of query : String that username starts with, leave empty to return all members limit : Max number of items to return, or 0 to request all members matched

func (*Session) RequestWithBucketID Uses

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 Uses

func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b []byte, bucket *Bucket, sequence int) (response []byte, err error)

RequestWithLockedBucket makes a request using a bucket that's already been locked

func (*Session) UpdateListeningStatus Uses

func (s *Session) UpdateListeningStatus(game string) (err error)

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 Uses

func (s *Session) UpdateStatus(idle int, game string) (err error)

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 Uses

func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error)

UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.

func (*Session) UpdateStreamingStatus Uses

func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error)

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

func (s *Session) User(userID string) (st *User, err error)

User returns the user details of the given userID userID : A user ID or "@me" which is a shortcut of current user ID

func (*Session) UserAvatar Uses

func (s *Session) UserAvatar(userID string) (img image.Image, err error)

UserAvatar is deprecated. Please use UserAvatarDecode userID : A user ID or "@me" which is a shortcut of current user ID

func (*Session) UserAvatarDecode Uses

func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error)

UserAvatarDecode returns an image.Image of a user's Avatar user : The user which avatar should be retrieved

func (*Session) UserChannelCreate Uses

func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error)

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 Uses

func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions int, err error)

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 Uses

func (s *Session) UserChannels() (st []*Channel, err error)

UserChannels returns an array of Channel structures for all private channels.

func (*Session) UserConnections Uses

func (s *Session) UserConnections() (conn []*UserConnection, err error)

UserConnections returns the user's connections

func (*Session) UserGuildSettingsEdit Uses

func (s *Session) UserGuildSettingsEdit(guildID string, 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 Uses

func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGuild, err error)

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 Uses

func (s *Session) UserNoteSet(userID string, message string) (err error)

UserNoteSet sets the note for a specific user.

func (*Session) UserSettings Uses

func (s *Session) UserSettings() (st *Settings, err error)

UserSettings returns the settings for a given user

func (*Session) UserUpdate Uses

func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error)

UserUpdate updates a users settings.

func (*Session) UserUpdateStatus Uses

func (s *Session) UserUpdateStatus(status Status) (st *Settings, err error)

UserUpdateStatus update the user status status : The new status (Actual valid status are 'online','idle','dnd','invisible')

func (*Session) VoiceICE Uses

func (s *Session) VoiceICE() (st *VoiceICE, err error)

VoiceICE returns the voice server ICE information

func (*Session) VoiceRegions Uses

func (s *Session) VoiceRegions() (st []*VoiceRegion, err error)

VoiceRegions returns the voice server regions

func (*Session) Webhook Uses

func (s *Session) Webhook(webhookID string) (st *Webhook, err error)

Webhook returns a webhook for a given ID webhookID: The ID of a webhook.

func (*Session) WebhookCreate Uses

func (s *Session) WebhookCreate(channelID, name, avatar string) (st *Webhook, err error)

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 Uses

func (s *Session) WebhookDelete(webhookID string) (err error)

WebhookDelete deletes a webhook for a given ID webhookID: The ID of a webhook.

func (*Session) WebhookDeleteWithToken Uses

func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook, err error)

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 Uses

func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string) (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 Uses

func (s *Session) WebhookEditWithToken(webhookID, 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 Uses

func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (st *Message, err error)

WebhookExecute executes a webhook. webhookID: The ID of a webhook. token : The auth token for the webhook wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise)

func (*Session) WebhookWithToken Uses

func (s *Session) WebhookWithToken(webhookID, token string) (st *Webhook, err error)

WebhookWithToken returns a webhook for a given ID webhookID: The ID of a webhook. token : The auth token for the webhook.

type Settings Uses

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         []string           `json:"guild_positions"`
    RestrictedGuilds       []string           `json:"restricted_guilds"`
    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 Uses

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

func NewState() *State

NewState creates an empty state.

func (*State) Channel Uses

func (s *State) Channel(channelID string) (*Channel, error)

Channel gets a channel by ID, it will look in all guilds and private channels.

func (*State) ChannelAdd Uses

func (s *State) ChannelAdd(channel *Channel) error

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 Uses

func (s *State) ChannelRemove(channel *Channel) error

ChannelRemove removes a channel from current world state.

func (*State) Emoji Uses

func (s *State) Emoji(guildID, emojiID string) (*Emoji, error)

Emoji returns an emoji for a guild and emoji id.

func (*State) EmojiAdd Uses

func (s *State) EmojiAdd(guildID string, emoji *Emoji) error

EmojiAdd adds an emoji to the current world state.

func (*State) EmojisAdd Uses

func (s *State) EmojisAdd(guildID string, emojis []*Emoji) error

EmojisAdd adds multiple emojis to the world state.

func (*State) Guild Uses

func (s *State) Guild(guildID string) (*Guild, error)

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 Uses

func (s *State) GuildAdd(guild *Guild) error

GuildAdd adds a guild to the current world state, or updates it if it already exists.

func (*State) GuildChannel Uses

func (s *State) GuildChannel(guildID, channelID string) (*Channel, error)

GuildChannel gets a channel by ID from a guild. This method is Deprecated, use Channel(channelID)

func (*State) GuildRemove Uses

func (s *State) GuildRemove(guild *Guild) error

GuildRemove removes a guild from current world state.

func (*State) Member Uses

func (s *State) Member(guildID, userID string) (*Member, error)

Member gets a member by ID from a guild.

func (*State) MemberAdd Uses

func (s *State) MemberAdd(member *Member) error

MemberAdd adds a member to the current world state, or updates it if it already exists.

func (*State) MemberRemove Uses

func (s *State) MemberRemove(member *Member) error

MemberRemove removes a member from current world state.

func (*State) Message Uses

func (s *State) Message(channelID, messageID string) (*Message, error)

Message gets a message by channel and message ID.

func (*State) MessageAdd Uses

func (s *State) MessageAdd(message *Message) error

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 Uses

func (s *State) MessageRemove(message *Message) error

MessageRemove removes a message from the world state.

func (*State) OnInterface Uses

func (s *State) OnInterface(se *Session, i interface{}) (err error)

OnInterface handles all events related to states.

func (*State) Presence Uses

func (s *State) Presence(guildID, userID string) (*Presence, error)

Presence gets a presence by ID from a guild.

func (*State) PresenceAdd Uses

func (s *State) PresenceAdd(guildID string, presence *Presence) error

PresenceAdd adds a presence to the current world state, or updates it if it already exists.

func (*State) PresenceRemove Uses

func (s *State) PresenceRemove(guildID string, presence *Presence) error

PresenceRemove removes a presence from the current world state.

func (*State) PrivateChannel Uses

func (s *State) PrivateChannel(channelID string) (*Channel, error)

PrivateChannel gets a private channel by ID. This method is Deprecated, use Channel(channelID)

func (*State) Role Uses

func (s *State) Role(guildID, roleID string) (*Role, error)

Role gets a role by ID from a guild.

func (*State) RoleAdd Uses

func (s *State) RoleAdd(guildID string, role *Role) error

RoleAdd adds a role to the current world state, or updates it if it already exists.

func (*State) RoleRemove Uses

func (s *State) RoleRemove(guildID, roleID string) error

RoleRemove removes a role from current world state by ID.

func (*State) UserChannelPermissions Uses

func (s *State) UserChannelPermissions(userID, channelID string) (apermissions int, err error)

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 Uses

func (s *State) UserColor(userID, channelID string) int

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

type Status string

Status type definition

const (
    StatusOnline       Status = "online"
    StatusIdle         Status = "idle"
    StatusDoNotDisturb Status = "dnd"
    StatusInvisible    Status = "invisible"
    StatusOffline      Status = "offline"
)

Constants for Status with the different current available status

type TimeStamps Uses

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 Uses

func (t *TimeStamps) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON into TimeStamps struct

type Timestamp Uses

type Timestamp string

Timestamp stores a timestamp, as sent by the Discord API.

func (Timestamp) Parse Uses

func (t Timestamp) Parse() (time.Time, error)

Parse parses a timestamp string into a time.Time object. The only time this can fail is if Discord changes their timestamp format.

type TooManyRequests Uses

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 Uses

type TypingStart struct {
    UserID    string `json:"user_id"`
    ChannelID string `json:"channel_id"`
    GuildID   string `json:"guild_id,omitempty"`
    Timestamp int    `json:"timestamp"`
}

TypingStart is the data for a TypingStart event.

type UpdateStatusData Uses

type UpdateStatusData struct {
    IdleSince *int   `json:"since"`
    Game      *Game  `json:"game"`
    AFK       bool   `json:"afk"`
    Status    string `json:"status"`
}

UpdateStatusData ia provided to UpdateStatusComplex()

type User Uses

type User struct {
    // The ID of the user.
    ID  string `json:"id"`

    // The email of the user. This is only present when
    // the application possesses the email scope for the user.
    Email string `json:"email"`

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

    // The token of the user. This is only present for
    // the user represented by the current session.
    Token string `json:"token"`

    // Whether the user's email is verified.
    Verified bool `json:"verified"`

    // Whether the user has multi-factor authentication enabled.
    MFAEnabled bool `json:"mfa_enabled"`

    // Whether the user is a bot.
    Bot bool `json:"bot"`
}

A User stores all data for an individual Discord user.

func (*User) AvatarURL Uses

func (u *User) AvatarURL(size string) string

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.

func (*User) Mention Uses

func (u *User) Mention() string

Mention return a string which mentions the user

func (*User) String Uses

func (u *User) String() string

String returns a unique identifier of the form username#discriminator

type UserConnection Uses

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 Uses

type UserGuild struct {
    ID          string `json:"id"`
    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 Uses

type UserGuildSettings struct {
    SupressEveryone      bool                                `json:"suppress_everyone"`
    Muted                bool                                `json:"muted"`
    MobilePush           bool                                `json:"mobile_push"`
    MessageNotifications int                                 `json:"message_notifications"`
    GuildID              string                              `json:"guild_id"`
    ChannelOverrides     []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
}

A UserGuildSettings stores data for a users guild settings.

type UserGuildSettingsChannelOverride Uses

type UserGuildSettingsChannelOverride struct {
    Muted                bool   `json:"muted"`
    MessageNotifications int    `json:"message_notifications"`
    ChannelID            string `json:"channel_id"`
}

A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.

type UserGuildSettingsEdit Uses

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 Uses

type UserGuildSettingsUpdate struct {
    *UserGuildSettings
}

UserGuildSettingsUpdate is the data for a UserGuildSettingsUpdate event.

type UserNoteUpdate Uses

type UserNoteUpdate struct {
    ID   string `json:"id"`
    Note string `json:"note"`
}

UserNoteUpdate is the data for a UserNoteUpdate event.

type UserSettingsUpdate Uses

type UserSettingsUpdate map[string]interface{}

UserSettingsUpdate is the data for a UserSettingsUpdate event.

type UserUpdate Uses

type UserUpdate struct {
    *User
}

UserUpdate is the data for a UserUpdate event.

type VerificationLevel Uses

type VerificationLevel int

VerificationLevel type definition

const (
    VerificationLevelNone VerificationLevel = iota
    VerificationLevelLow
    VerificationLevelMedium
    VerificationLevelHigh
    VerificationLevelVeryHigh
)

Constants for VerificationLevel levels from 0 to 4 inclusive

type VoiceConnection Uses

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    string
    GuildID   string
    ChannelID string

    OpusSend chan []byte  // Chan for sending opus audio
    OpusRecv chan *Packet // Chan for receiving opus audio
    // contains filtered or unexported fields
}

A VoiceConnection struct holds all the data and functions related to a Discord Voice Connection.

func (*VoiceConnection) AddHandler Uses

func (v *VoiceConnection) AddHandler(h VoiceSpeakingUpdateHandler)

AddHandler adds a Handler for VoiceSpeakingUpdate events.

func (*VoiceConnection) ChangeChannel Uses

func (v *VoiceConnection) ChangeChannel(channelID string, 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 Uses

func (v *VoiceConnection) Close()

Close closes the voice ws and udp connections

func (*VoiceConnection) Disconnect Uses

func (v *VoiceConnection) Disconnect() (err error)

Disconnect disconnects from this voice channel and closes the websocket and udp connections to Discord.

func (*VoiceConnection) Speaking Uses

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

type VoiceICE struct {
    TTL     string       `json:"ttl"`
    Servers []*ICEServer `json:"servers"`
}

A VoiceICE stores data for voice ICE servers.

type VoiceRegion Uses

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 Uses

type VoiceServerUpdate struct {
    Token    string `json:"token"`
    GuildID  string `json:"guild_id"`
    Endpoint string `json:"endpoint"`
}

VoiceServerUpdate is the data for a VoiceServerUpdate event.

type VoiceSpeakingUpdate Uses

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 Uses

type VoiceSpeakingUpdateHandler func(vc *VoiceConnection, vs *VoiceSpeakingUpdate)

VoiceSpeakingUpdateHandler type provides a function definition for the VoiceSpeakingUpdate event

type VoiceState Uses

type VoiceState struct {
    UserID    string `json:"user_id"`
    SessionID string `json:"session_id"`
    ChannelID string `json:"channel_id"`
    GuildID   string `json:"guild_id"`
    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 Uses

type VoiceStateUpdate struct {
    *VoiceState
}

VoiceStateUpdate is the data for a VoiceStateUpdate event.

type Webhook Uses

type Webhook struct {
    ID        string `json:"id"`
    GuildID   string `json:"guild_id"`
    ChannelID string `json:"channel_id"`
    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 Uses

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 Uses

type WebhooksUpdate struct {
    GuildID   string `json:"guild_id"`
    ChannelID string `json:"channel_id"`
}

WebhooksUpdate is the data for a WebhooksUpdate event

Directories

PathSynopsis
examples/airhorn
examples/appmaker
examples/avatar
examples/mytoken
examples/pingpong
tools/cmd/eventhandlers

Package discordgo imports 27 packages (graph) and is imported by 590 packages. Updated 2019-11-10. Refresh now. Tools for package owners.