Documentation ¶
Overview ¶
Package disgord provides Go bindings for the documented Discord API. And allows for a stateful client using the Session interface, with the option of a configurable caching system or bypass the built-in caching logic all together.
Getting started ¶
Create a DisGord session to get access to the REST API and socket functionality. In the following example, we listen for new messages and write a "hello" message when our handler function gets fired.
Session interface: https://godoc.org/github.com/andersfylling/disgord/#Session
discord, err := disgord.NewClient(&disgord.Config{ BotToken: "my-secret-bot-token", }) if err != nil { panic(err) } // listen for incoming messages and reply with a "hello" discord.On(event.MessageCreate, func(session disgord.Session, evt *disgord.MessageCreate) { evt.Message.RespondString("hello") }) // connect to the socket API to receive events err = discord.Connect() if err != nil { panic(err) } discord.DisconnectOnInterrupt()
If you want some logic to fire when the bot is ready (all shards has received their ready event), please use the Ready method.
// ... discord.Ready(func() { fmt.Println("READY NOW!") }) // ...
Listen for events using channels ¶
Disgord also provides the option to listen for events using a channel, instead of registering a handler. However, before using the event channel, you must notify disgord that you care about the event (this is done automatically in the event handler registration).
session.AcceptEvent(event.MessageCreate) // alternative: disgord.EventMessageCreate session.AcceptEvent(event.MessageUpdate) for { var message *disgord.Message var status string select { case evt, alive := <- session.EventChannels().MessageCreate() if !alive { return } message = evt.Message status = "created" case evt, alive := <- session.EventChannels().MessageUpdate() if !alive { return } message = evt.Message status = "updated" } fmt.Printf("A message from %s was %s\n", message.Author.Mention(), status) // output example: "A message from @Anders was created" }
Optimizing your cache logic ¶
> Note: if you create a CacheConfig you don't have to set every field. All the CacheAlgorithms are default to LFU when left blank.
A part of Disgord is the control you have; while this can be a good detail for advanced users, we recommend beginners to utilise the default configurations (by simply not editing the configuration). Here we pass the cache config when creating the session to access to the different cache replacement algorithms, lifetime settings, and the option to disable different cache systems.
discord, err := disgord.NewClient(&disgord.Config{ BotToken: "my-secret-bot-token", Cache: &disgord.CacheConfig{ Mutable: false, // everything going in and out of the cache is deep copied // setting Mutable to true, might break your program as this is experimental. DisableUserCaching: false, // activates caching for users UserCacheLifetime: time.Duration(4) * time.Hour, // removed from cache after 9 hours, unless updated UserCacheAlgorithm: disgord.CacheAlgLFU, DisableVoiceStateCaching: true, // don't cache voice states // VoiceStateCacheLifetime time.Duration // VoiceStateCacheAlgorithm string DisableChannelCaching: false, ChannelCacheLifetime: 0, // lives forever ChannelCacheAlgorithm: disgord.CacheAlgLFU, // lfu (Least Frequently Used) GuildCacheAlgorithm: disgord.CacheAlgLFU, // no limit set, so the strategy to replace entries is not used }, })
If you just want to change a specific field, you can do so. By either calling the disgord.DefaultCacheConfig which gives you a Cache configuration designed by DisGord. Or you can set specific fields in a new CacheConfig since the different Cache Strategies are automatically set to LFU if missing.
&disgord.Config{}
Will automatically become
&disgord.Config{ UserCacheAlgorithm: disgord.CacheAlgLFU, VoiceStateCacheAlgorithm disgord.CacheAlgLFU, ChannelCacheAlgorithm: disgord.CacheAlgLFU, GuildCacheAlgorithm: disgord.CacheAlgLFU, }
And writing
&disgord.Config{ UserCacheAlgorithm: disgord.CacheAlgLRU, VoiceStateCacheAlgorithm disgord.CacheAlgLRU, }
Becomes
&disgord.Config{ UserCacheAlgorithm: disgord.CacheAlgLRU, // unchanged VoiceStateCacheAlgorithm disgord.CacheAlgLRU, // unchanged ChannelCacheAlgorithm: disgord.CacheAlgLFU, GuildCacheAlgorithm: disgord.CacheAlgLFU, }
> Note: Disabling caching for some types while activating it for others (eg. disabling channels, but activating guild caching), can cause items extracted from the cache to not reflect the true discord state.
Example, activated guild but disabled channel caching: The guild is stored to the cache, but it's channels are discarded. Guild channels are dismantled from the guild object and otherwise stored in the channel cache to improve performance and reduce memory use. So when you extract the cached guild object, all of the channel will only hold their channel ID, and nothing more.
Immutable and concurrent accessible cache ¶
The option CacheConfig.Immutable can greatly improve performance or break your system. If you utilize channels or you need concurrent access, the safest bet is to set immutable to `true`. While this is slower (as you create deep copies and don't share the same memory space with variables outside the cache), it increases reliability that the cache always reflects the last known Discord state. If you are uncertain, just set it to `true`. The default setting is `true` if `disgord.Cache.CacheConfig` is `nil`.
Bypass the built-in REST cache ¶
Whenever you call a REST method from the Session interface; the cache is always checked first. Upon a cache hit, no REST request is executed and you get the data from the cache in return. However, if this is problematic for you or there exist a bug which gives you bad/outdated data, you can bypass it by using the REST functions directly. Remember that this will not update the cache for you, and this needs to be done manually if you depend on the cache.
// get a user using the Session implementation (checks cache, and updates the cache on cache miss) user, err := session.GetUser(userID) // bypass the cache checking. Same function name, but is found in the disgord package, not the session interface. user, err := disgord.GetUser(userID)
Manually updating the cache ¶
If required, you can access the cache and update it by hand. Note that this should not be required when you use the Session interface.
user, err := disgord.GetUser(userID) if err != nil { return err } // update the cache cache := discord.Cache() err = cache.Update(disgord.UserCache, user) if err != nil { return err }
Build tags ¶
`disgord_diagnosews` will store all the incoming and outgoing json data as files in the directory "diagnose-report/packets". The file format is as follows: unix_clientType_direction_shardID_operationCode_sequenceNumber[_eventName].json
`json-std` switches out jsoniter with the json package from the std libs.
`disgord_removeDiscordMutex` replaces mutexes in discord structures with a empty mutex; removes locking behaviour and any mutex code when compiled.
`disgord_parallelism` activates built-in locking in discord structure methods. Eg. Guild.AddChannel(*Channel) does not do locking by default. But if you find yourself using these discord data structures in parallel environment, you can activate the internal locking to reduce race conditions. Note that activating `disgord_parallelism` and `disgord_removeDiscordMutex` at the same time, will cause you to have no locking as `disgord_removeDiscordMutex` affects the same mutexes.
Saving and Deleting Discord data ¶
> Note: when using SaveToDiscord(...) make sure the object reflects the Discord state. Calling Save on default values might overwrite or reset the object at Discord, causing literally.. Hell.
You might have seen the two methods in the session interface: SaveToDiscord(...) and DeleteFromDiscord(...). This are as straight forward as they sound. Passing a discord data structure into one of them executes their obvious behavior; to either save it to Discord, or delete it.
// create a new role and give it certain permissions role := disgord.Role{} role.Name = "Giraffes" role.GuildID = guild.ID // required, for an obvious reason role.Permissions = disgord.ManageChannelsPermission | disgord.ViewAuditLogsPermission err := session.SaveToDiscord(&role)
You know what.. Let's just remove the role
err := session.DeleteFromDiscord(&role)
Index ¶
- Constants
- func AddGuildMemberRole(client httd.Puter, guildID, userID, roleID Snowflake) (err error)
- func AddPinnedChannelMessage(client httd.Puter, channelID, msgID Snowflake) (err error)
- func BulkDeleteMessages(client httd.Poster, chanID Snowflake, params *BulkDeleteMessagesParams) (err error)
- func CreateGuildBan(client httd.Puter, guildID, userID Snowflake, params *CreateGuildBanParams) (err error)
- func CreateGuildIntegration(client httd.Poster, guildID Snowflake, params *CreateGuildIntegrationParams) (err error)
- func CreateReaction(client httd.Puter, channelID, messageID Snowflake, emoji interface{}) (err error)
- func DefaultLogger(debug bool) *logger.LoggerZap
- func DefaultLoggerWithInstance(log *zap.Logger) *logger.LoggerZap
- func DeleteAllReactions(client httd.Deleter, channelID, messageID Snowflake) (err error)
- func DeleteChannelPermission(client httd.Deleter, channelID, overwriteID Snowflake) (err error)
- func DeleteGuild(client httd.Deleter, id Snowflake) (err error)
- func DeleteGuildEmoji(client httd.Deleter, guildID, emojiID Snowflake) (err error)
- func DeleteGuildIntegration(client httd.Deleter, guildID, integrationID Snowflake) (err error)
- func DeleteGuildRole(client httd.Deleter, guildID, roleID Snowflake) (err error)
- func DeleteMessage(client httd.Deleter, channelID, msgID Snowflake) (err error)
- func DeleteOwnReaction(client httd.Deleter, channelID, messageID Snowflake, emoji interface{}) (err error)
- func DeletePinnedChannelMessage(client httd.Deleter, channelID, msgID Snowflake) (err error)
- func DeleteUserReaction(client httd.Deleter, channelID, messageID, userID Snowflake, emoji interface{}) (err error)
- func DeleteWebhook(client httd.Deleter, webhookID Snowflake) (err error)
- func DeleteWebhookWithToken(client httd.Deleter, id Snowflake, token string) (err error)
- func EditChannelPermissions(client httd.Puter, chanID, overwriteID Snowflake, ...) (err error)
- func ExecuteGitHubWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)
- func ExecuteSlackWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)
- func ExecuteWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error)
- func GetShardForGuildID(guildID Snowflake, shardCount uint) (shardID uint)
- func GroupDMAddRecipient(client httd.Puter, channelID, userID Snowflake, ...) (err error)
- func GroupDMRemoveRecipient(client httd.Deleter, channelID, userID Snowflake) (err error)
- func LeaveGuild(client httd.Deleter, id Snowflake) (err error)
- func LibraryInfo() string
- func ModifyCurrentUserNick(client httd.Patcher, id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error)
- func ModifyGuildIntegration(client httd.Patcher, guildID, integrationID Snowflake, ...) (err error)
- func ModifyGuildMember(client httd.Patcher, guildID, userID Snowflake, ...) (err error)
- func New(conf *Config) (c *client)
- func NewClient(conf *Config) (c *client, err error)
- func NewRESTClient(conf *Config) (*httd.Client, error)
- func RemoveGuildBan(client httd.Deleter, guildID, userID Snowflake) (err error)
- func RemoveGuildMember(client httd.Deleter, guildID, userID Snowflake) (err error)
- func RemoveGuildMemberRole(client httd.Deleter, guildID, userID, roleID Snowflake) (err error)
- func SyncGuildIntegration(client httd.Poster, guildID, integrationID Snowflake) (err error)
- func TriggerTypingIndicator(client httd.Poster, channelID Snowflake) (err error)
- func ValidateUsername(name string) (err error)
- type Activity
- type ActivityAssets
- type ActivityParty
- type ActivitySecrets
- type ActivityTimestamp
- type AddGuildMemberParams
- type Attachment
- type AuditLog
- type AuditLogChange
- type AuditLogEntry
- type AuditLogOption
- type AuditLogsRESTer
- type AvatarParamHolder
- type Ban
- type BodyUserCreateDM
- type BulkDeleteMessagesParams
- type Cache
- func (c *Cache) AddGuildChannel(guildID snowflake.ID, channelID snowflake.ID)
- func (c *Cache) AddGuildMember(guildID snowflake.ID, member *Member)
- func (c *Cache) AddGuildRole(guildID Snowflake, role *Role)
- func (c *Cache) DeleteChannel(id Snowflake)
- func (c *Cache) DeleteGuild(id Snowflake)
- func (c *Cache) DeleteGuildChannel(guildID, channelID Snowflake)
- func (c *Cache) DeleteGuildRole(guildID, roleID Snowflake)
- func (c *Cache) DirectUpdate(registry cacheRegistry, id snowflake.ID, changes []byte) error
- func (c *Cache) Get(key cacheRegistry, id Snowflake, args ...interface{}) (v interface{}, err error)
- func (c *Cache) GetChannel(id Snowflake) (channel *Channel, err error)
- func (c *Cache) GetGuild(id Snowflake) (guild *Guild, err error)
- func (c *Cache) GetGuildEmojis(id Snowflake) (emojis []*Emoji, err error)
- func (c *Cache) GetGuildMember(guildID, userID Snowflake) (member *Member, err error)
- func (c *Cache) GetGuildMembersAfter(guildID, after Snowflake, limit int) (members []*Member, err error)
- func (c *Cache) GetGuildRoles(id Snowflake) (roles []*Role, err error)
- func (c *Cache) GetUser(id Snowflake) (user *User, err error)
- func (c *Cache) GetVoiceState(guildID Snowflake, params *guildVoiceStateCacheParams) (state *VoiceState, err error)
- func (c *Cache) PeekGuild(id snowflake.ID) (guild *Guild, err error)
- func (c *Cache) PeekUser(id snowflake.ID) (*User, error)
- func (c *Cache) RemoveGuildMember(guildID snowflake.ID, memberID snowflake.ID)
- func (c *Cache) SetChannel(new *Channel)
- func (c *Cache) SetGuild(guild *Guild)
- func (c *Cache) SetGuildEmojis(guildID Snowflake, emojis []*Emoji)
- func (c *Cache) SetGuildMember(guildID Snowflake, member *Member)
- func (c *Cache) SetGuildMembers(guildID Snowflake, members []*Member)
- func (c *Cache) SetGuildRoles(guildID Snowflake, roles []*Role)
- func (c *Cache) SetUser(new *User)
- func (c *Cache) SetVoiceState(state *VoiceState)
- func (c *Cache) Update(key cacheRegistry, v interface{}) (err error)
- func (c *Cache) UpdateChannelLastMessageID(channelID Snowflake, messageID Snowflake)
- func (c *Cache) UpdateChannelPin(id Snowflake, timestamp Timestamp)
- func (c *Cache) UpdateGuildRole(guildID snowflake.ID, role *Role, data json.RawMessage) bool
- func (c *Cache) UpdateMemberAndUser(guildID, userID snowflake.ID, data json.RawMessage)
- func (c *Cache) UpdateOrAddGuildMembers(guildID Snowflake, members []*Member)
- func (c *Cache) Updates(key cacheRegistry, vs []interface{}) (err error)
- type CacheConfig
- type Cacher
- type Channel
- func CreateDM(client httd.Poster, recipientID Snowflake) (ret *Channel, err error)
- func CreateGroupDM(client httd.Poster, params *CreateGroupDMParams) (ret *Channel, err error)
- func CreateGuildChannel(client httd.Poster, id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error)
- func DeleteChannel(client httd.Deleter, id Snowflake) (channel *Channel, err error)
- func GetChannel(client httd.Getter, id Snowflake) (ret *Channel, err error)
- func GetGuildChannels(client httd.Getter, id Snowflake) (ret []*Channel, err error)
- func GetUserDMs(client httd.Getter) (ret []*Channel, err error)
- func ModifyChannel(client httd.Patcher, id Snowflake, changes *ModifyChannelParams) (ret *Channel, err error)
- func NewChannel() *Channel
- func (c *Channel) Compare(other *Channel) bool
- func (c *Channel) CopyOverTo(other interface{}) (err error)
- func (c *Channel) DeepCopy() (copy interface{})
- func (c *Channel) Mention() string
- func (c *Channel) SendMsg(client MessageSender, message *Message) (msg *Message, err error)
- func (c *Channel) SendMsgString(client MessageSender, content string) (msg *Message, err error)
- type ChannelCreate
- type ChannelCreateHandler
- type ChannelDelete
- type ChannelDeleteHandler
- type ChannelEmbed
- type ChannelEmbedAuthor
- type ChannelEmbedField
- type ChannelEmbedFooter
- type ChannelEmbedImage
- type ChannelEmbedProvider
- type ChannelEmbedThumbnail
- type ChannelEmbedVideo
- type ChannelFetcher
- type ChannelPinsUpdate
- type ChannelPinsUpdateHandler
- type ChannelRESTer
- type ChannelUpdate
- type ChannelUpdateHandler
- type Config
- type Copier
- type CreateChannelInvitesParams
- type CreateChannelMessageFileParamsdeprecated
- type CreateChannelMessageParamsdeprecated
- type CreateGroupDMParams
- type CreateGuildBanParams
- type CreateGuildChannelParams
- type CreateGuildEmojiParams
- type CreateGuildIntegrationParams
- type CreateGuildParams
- type CreateGuildRoleParams
- type CreateMessageFileParams
- type CreateMessageParams
- type CreateWebhookParams
- type DeepCopier
- type DefaultMessageNotificationLvl
- type Discriminator
- type EditChannelPermissionsParams
- type EditMessageParams
- type Emitter
- type Emoji
- func CreateGuildEmoji(client httd.Poster, guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error)
- func GetGuildEmoji(client httd.Getter, guildID, emojiID Snowflake) (ret *Emoji, err error)
- func ModifyGuildEmoji(client httd.Patcher, guildID, emojiID Snowflake, ...) (ret *Emoji, err error)
- type EmojiRESTer
- type ErrRest
- type ErrorCacheItemNotFound
- type ErrorEmptyValue
- type ErrorMissingSnowflake
- type ErrorUnsupportedType
- type ErrorUsingDeactivatedCache
- type EventChannels
- type ExecuteWebhookParams
- type ExplicitContentFilterLvl
- type Gateway
- type GatewayBot
- type GetChannelMessagesParamsdeprecated
- type GetCurrentUserGuildsParams
- type GetMessagesParams
- type GetReactionURLParams
- type GroupDMAddRecipientParams
- type Guild
- func CreateGuild(client httd.Poster, params *CreateGuildParams) (ret *Guild, err error)
- func GetCurrentUserGuilds(client httd.Getter, params *GetCurrentUserGuildsParams) (ret []*Guild, err error)
- func GetGuild(client httd.Getter, id Snowflake) (ret *Guild, err error)
- func ModifyGuild(client httd.Patcher, id Snowflake, params *ModifyGuildParams) (ret *Guild, err error)
- func ModifyGuildChannelPositions(client httd.Patcher, id Snowflake, params []ModifyGuildChannelPositionsParams) (ret *Guild, err error)
- func NewGuild() *Guild
- func NewGuildFromJSON(data []byte) (guild *Guild)
- func NewGuildFromUnavailable(gu *GuildUnavailable) *Guild
- func NewPartialGuild(ID Snowflake) (guild *Guild)
- func (g *Guild) AddChannel(c *Channel) error
- func (g *Guild) AddMember(member *Member) error
- func (g *Guild) AddMembers(members []*Member)
- func (g *Guild) AddRole(role *Role) error
- func (g *Guild) Channel(id Snowflake) (*Channel, error)
- func (g *Guild) CopyOverTo(other interface{}) (err error)
- func (g *Guild) DeepCopy() (copy interface{})
- func (g *Guild) DeleteChannel(c *Channel) error
- func (g *Guild) DeleteChannelByID(ID Snowflake) error
- func (g *Guild) DeleteRoleByID(ID Snowflake)
- func (g *Guild) Emoji(id Snowflake) (emoji *Emoji, err error)
- func (g *Guild) GetMemberWithHighestSnowflake() *Member
- func (g *Guild) LoadAllMembers(session Session) (err error)
- func (g *Guild) MarshalJSON() ([]byte, error)
- func (g *Guild) Member(id Snowflake) (*Member, error)
- func (g *Guild) MembersByName(name string) (members []*Member)
- func (g *Guild) Role(id Snowflake) (role *Role, err error)
- func (g *Guild) RoleByName(name string) ([]*Role, error)
- type GuildBanAdd
- type GuildBanAddHandler
- type GuildBanRemove
- type GuildBanRemoveHandler
- type GuildCreate
- type GuildCreateHandler
- type GuildDelete
- type GuildDeleteHandler
- type GuildEmbed
- type GuildEmojisUpdate
- type GuildEmojisUpdateHandler
- type GuildIntegrationsUpdate
- type GuildIntegrationsUpdateHandler
- type GuildMemberAdd
- type GuildMemberAddHandler
- type GuildMemberRemove
- type GuildMemberRemoveHandler
- type GuildMemberUpdate
- type GuildMemberUpdateHandler
- type GuildMembersChunk
- type GuildMembersChunkHandler
- type GuildPruneCount
- type GuildPruneParams
- type GuildRESTer
- type GuildRoleCreate
- type GuildRoleCreateHandler
- type GuildRoleDelete
- type GuildRoleDeleteHandler
- type GuildRoleUpdate
- type GuildRoleUpdateHandler
- type GuildUnavailable
- type GuildUpdate
- type GuildUpdateHandler
- type Handler
- type HandlerCtrl
- type Integration
- type IntegrationAccount
- type Invite
- type InviteMetadata
- type InviteRESTer
- type Link
- type Lockable
- type Logger
- type MFALvl
- type Member
- func AddGuildMember(client httd.Puter, guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error)
- func GetGuildMember(client httd.Getter, guildID, userID Snowflake) (ret *Member, err error)
- func GetGuildMembers(client httd.Getter, guildID, after Snowflake, limit int) (ret []*Member, err error)
- type Message
- func CreateChannelMessage(client httd.Poster, channelID Snowflake, params *CreateMessageParams) (ret *Message, err error)deprecated
- func CreateMessage(client httd.Poster, channelID Snowflake, params *CreateMessageParams) (ret *Message, err error)
- func EditMessage(client httd.Patcher, chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error)
- func GetChannelMessage(client httd.Getter, channelID, messageID Snowflake) (ret *Message, err error)deprecated
- func GetChannelMessages(client httd.Getter, channelID Snowflake, params URLParameters) (ret []*Message, err error)deprecated
- func GetMessage(client httd.Getter, channelID, messageID Snowflake) (ret *Message, err error)
- func GetMessages(client httd.Getter, channelID Snowflake, params URLParameters) (ret []*Message, err error)
- func GetPinnedMessages(client httd.Getter, channelID Snowflake) (ret []*Message, err error)
- func NewMessage() *Message
- func (m *Message) CopyOverTo(other interface{}) (err error)
- func (m *Message) DeepCopy() (copy interface{})
- func (m *Message) Respond(client MessageSender, message *Message) (msg *Message, err error)
- func (m *Message) RespondString(client MessageSender, content string) (msg *Message, err error)
- func (m *Message) Send(client MessageSender) (msg *Message, err error)
- type MessageActivity
- type MessageApplication
- type MessageCreate
- type MessageCreateHandler
- type MessageDelete
- type MessageDeleteBulk
- type MessageDeleteBulkHandler
- type MessageDeleteHandler
- type MessageReactionAdd
- type MessageReactionAddHandler
- type MessageReactionRemove
- type MessageReactionRemoveAll
- type MessageReactionRemoveAllHandler
- type MessageReactionRemoveHandler
- type MessageSender
- type MessageUpdate
- type MessageUpdateHandler
- type MessageUpdater
- type Middleware
- type ModifyChannelParams
- func (m *ModifyChannelParams) AddPermissionOverwrite(permission PermissionOverwrite)
- func (m *ModifyChannelParams) AddPermissionOverwrites(permissions []PermissionOverwrite)
- func (m *ModifyChannelParams) MarshalJSON() ([]byte, error)
- func (m *ModifyChannelParams) RemoveParentID() error
- func (m *ModifyChannelParams) SetBitrate(bitrate uint) error
- func (m *ModifyChannelParams) SetNSFW(yes bool) error
- func (m *ModifyChannelParams) SetName(name string) error
- func (m *ModifyChannelParams) SetParentID(id Snowflake) error
- func (m *ModifyChannelParams) SetPermissionOverwrites(permissions []PermissionOverwrite)
- func (m *ModifyChannelParams) SetPosition(pos uint)
- func (m *ModifyChannelParams) SetRateLimitPerUser(seconds uint) error
- func (m *ModifyChannelParams) SetTopic(topic string) error
- func (m *ModifyChannelParams) SetUserLimit(limit uint) error
- type ModifyCurrentUserNickParams
- type ModifyCurrentUserParams
- type ModifyGuildChannelPositionsParams
- type ModifyGuildEmojiParams
- type ModifyGuildIntegrationParams
- type ModifyGuildMemberParams
- func (m *ModifyGuildMemberParams) MarshalJSON() ([]byte, error)
- func (m *ModifyGuildMemberParams) RemoveNick()
- func (m *ModifyGuildMemberParams) SetChannelID(id Snowflake) error
- func (m *ModifyGuildMemberParams) SetDeaf(yes bool)
- func (m *ModifyGuildMemberParams) SetMute(yes bool)
- func (m *ModifyGuildMemberParams) SetNick(name string) error
- func (m *ModifyGuildMemberParams) SetRoles(roles []Snowflake)
- type ModifyGuildParams
- type ModifyGuildRoleParams
- func (p *ModifyGuildRoleParams) MarshalJSON() ([]byte, error)
- func (p *ModifyGuildRoleParams) SetColor(color uint)
- func (p *ModifyGuildRoleParams) SetHoist(hoist bool)
- func (p *ModifyGuildRoleParams) SetMentionable(mentionable bool)
- func (p *ModifyGuildRoleParams) SetName(name string)
- func (p *ModifyGuildRoleParams) SetPermissions(permissions uint64)
- type ModifyGuildRolePositionsParams
- type ModifyWebhookParams
- func (m *ModifyWebhookParams) Empty() bool
- func (m *ModifyWebhookParams) MarshalJSON() ([]byte, error)
- func (m *ModifyWebhookParams) SetAvatar(avatar string)
- func (m *ModifyWebhookParams) SetChannelID(channelID Snowflake)
- func (m *ModifyWebhookParams) SetName(name string)
- func (m *ModifyWebhookParams) UseDefaultAvatar()
- type PartialChannel
- type PartialEmoji
- type PartialGuild
- type PartialInvite
- type PermissionOverwrite
- type PremiumType
- type Presence
- type PresenceUpdate
- type PresenceUpdateHandler
- type PresencesReplace
- type PresencesReplaceHandler
- type RESTBuilder
- type RESTer
- type Reaction
- type Ready
- type ReadyHandler
- type RequestGuildMembersCommand
- type Resumed
- type ResumedHandler
- type Role
- func CreateGuildRole(client httd.Poster, id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error)
- func GetGuildRoles(client httd.Getter, guildID Snowflake) (ret []*Role, err error)
- func ModifyGuildRole(client httd.Patcher, guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret *Role, err error)
- func ModifyGuildRolePositions(client httd.Patcher, guildID Snowflake, ...) (ret []*Role, err error)
- func NewRole() *Role
- type Session
- type SessionMock
- type SetChannelPermissionsParams
- type SimpleHandler
- type SimplestHandler
- type Snowflake
- type SocketCommand
- type SocketHandler
- type Timestamp
- type TypingStart
- type TypingStartHandler
- type URLParameters
- type UpdateStatusCommand
- type UpdateVoiceStateCommand
- type User
- func (u *User) CopyOverTo(other interface{}) (err error)
- func (u *User) DeepCopy() (copy interface{})
- func (u *User) MarshalJSON() ([]byte, error)
- func (u *User) Mention() string
- func (u *User) MentionNickname() string
- func (u *User) SendMsg(session Session, message *Message) (channel *Channel, msg *Message, err error)
- func (u *User) SendMsgString(session Session, content string) (channel *Channel, msg *Message, err error)
- func (u *User) String() string
- func (u *User) UnmarshalJSON(data []byte) (err error)
- func (u *User) Valid() bool
- type UserConnection
- type UserPresence
- type UserRESTer
- type UserUpdate
- type UserUpdateHandler
- type VerificationLvl
- type VoiceConnection
- type VoiceHandler
- type VoiceRESTer
- type VoiceRegion
- type VoiceServerUpdate
- type VoiceServerUpdateHandler
- type VoiceState
- type VoiceStateUpdate
- type VoiceStateUpdateHandler
- type WSShard
- type WSShardManager
- func (s *WSShardManager) Connect() (err error)
- func (s *WSShardManager) Disconnect() (err error)
- func (s *WSShardManager) Emit(cmd SocketCommand, data interface{}) (err error)
- func (s *WSShardManager) GetAvgHeartbeatLatency() (latency time.Duration, err error)
- func (s *WSShardManager) GetConnectionDetails(c httd.Getter) (url string, shardCount uint, err error)
- func (s *WSShardManager) GetShard(guildID snowflake.ID) (*WSShard, error)
- func (s *WSShardManager) InitialReadyReceived() bool
- func (s *WSShardManager) Prepare(conf *Config) error
- type WSShardManagerConfig
- type Webhook
- func CreateWebhook(client httd.Poster, channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error)
- func GetChannelWebhooks(client httd.Getter, channelID Snowflake) (ret []*Webhook, err error)
- func GetGuildWebhooks(client httd.Getter, guildID Snowflake) (ret []*Webhook, err error)
- func GetWebhook(client httd.Getter, id Snowflake) (ret *Webhook, err error)
- func GetWebhookWithToken(client httd.Getter, id Snowflake, token string) (ret *Webhook, err error)
- func ModifyWebhook(client httd.Patcher, id Snowflake, params *ModifyWebhookParams) (ret *Webhook, err error)
- func ModifyWebhookWithToken(client httd.Patcher, newWebhook *Webhook) (ret *Webhook, err error)
- type WebhookRESTer
- type WebhooksUpdate
- type WebhooksUpdateHandler
Constants ¶
const ( AuditLogEvtGuildUpdate = 1 AuditLogEvtChannelCreate = 10 AuditLogEvtChannelUpdate = 11 AuditLogEvtChannelDelete = 12 AuditLogEvtOverwriteCreate = 13 AuditLogEvtOverwriteUpdate = 14 AuditLogEvtOverwriteDelete = 15 AuditLogEvtMemberKick = 20 AuditLogEvtMemberPrune = 21 AuditLogEvtMemberBanAdd = 22 AuditLogEvtMemberBanRemove = 23 AuditLogEvtMemberUpdate = 24 AuditLogEvtMemberRoleUpdate = 25 AuditLogEvtRoleCreate = 30 AuditLogEvtRoleUpdate = 31 AuditLogEvtRoleDelete = 32 AuditLogEvtInviteCreate = 40 AuditLogEvtInviteUpdate = 41 AuditLogEvtInviteDelete = 42 AuditLogEvtWebhookCreate = 50 AuditLogEvtWebhookUpdate = 51 AuditLogEvtWebhookDelete = 52 AuditLogEvtEmojiCreate = 60 AuditLogEvtEmojiUpdate = 61 AuditLogEvtEmojiDelete = 62 AuditLogEvtMessageDelete = 72 )
Audit-log event types
const ( // key name, identifier changed, type, description AuditLogChangeKeyName = "name" // guild string name changed AuditLogChangeKeyIconHash = "icon_hash" // guild string icon changed AuditLogChangeKeySplashHash = "splash_hash" // guild string invite splash page artwork changed AuditLogChangeKeyOwnerID = "owner_id" // guild snowflake owner changed AuditLogChangeKeyRegion = "region" // guild string region changed AuditLogChangeKeyAFKChannelID = "afk_channel_id" // guild snowflake afk channel changed AuditLogChangeKeyAFKTimeout = "afk_timeout" // guild integer afk timeout duration changed AuditLogChangeKeyMFALevel = "mfa_level" // guild integer two-factor auth requirement changed AuditLogChangeKeyVerificationLevel = "verification_level" // guild integer required verification level changed AuditLogChangeKeyExplicitContentFilter = "explicit_content_filter" // guild integer change in whose messages are scanned and deleted for explicit content in the server AuditLogChangeKeyDefaultMessageNotifications = "default_message_notifications" // guild integer default message notification level changed AuditLogChangeKeyVanityURLCode = "vanity_url_code" // guild string guild invite vanity url changed AuditLogChangeKeyAdd = "$add" // add guild array of role objects new role added AuditLogChangeKeyRemove = "$remove" // remove guild array of role objects role removed AuditLogChangeKeyPruneDeleteDays = "prune_delete_days" // guild integer change in number of days after which inactive and role-unassigned members are kicked AuditLogChangeKeyWidgetEnabled = "widget_enabled" // guild bool server widget enabled/disable AuditLogChangeKeyWidgetChannelID = "widget_channel_id" // guild snowflake channel id of the server widget changed AuditLogChangeKeyPosition = "position" // channel integer text or voice channel position changed AuditLogChangeKeyTopic = "topic" // channel string text channel topic changed AuditLogChangeKeyBitrate = "bitrate" // channel integer voice channel bitrate changed AuditLogChangeKeyPermissionOverwrites = "permission_overwrites" // channel array of channel overwrite objects permissions on a channel changed AuditLogChangeKeyNSFW = "nsfw" // channel bool channel nsfw restriction changed AuditLogChangeKeyApplicationID = "application_id" // channel snowflake application id of the added or removed webhook or bot AuditLogChangeKeyPermissions = "permissions" // role integer permissions for a role changed AuditLogChangeKeyColor = "color" // role integer role color changed AuditLogChangeKeyHoist = "hoist" // role bool role is now displayed/no longer displayed separate from online users AuditLogChangeKeyMentionable = "mentionable" // role bool role is now mentionable/unmentionable AuditLogChangeKeyAllow = "allow" // role integer a permission on a text or voice channel was allowed for a role AuditLogChangeKeyDeny = "deny" // role integer a permission on a text or voice channel was denied for a role AuditLogChangeKeyCode = "code" // invite string invite code changed AuditLogChangeKeyChannelID = "channel_id" // invite snowflake channel for invite code changed AuditLogChangeKeyInviterID = "inviter_id" // invite snowflake person who created invite code changed AuditLogChangeKeyMaxUses = "max_uses" // invite integer change to max number of times invite code can be used AuditLogChangeKeyUses = "uses" // invite integer number of times invite code used changed AuditLogChangeKeyMaxAge = "max_age" // invite integer how long invite code lasts changed AuditLogChangeKeyTemporary = "temporary" // invite bool invite code is temporary/never expires AuditLogChangeKeyDeaf = "deaf" // user bool user server deafened/undeafened AuditLogChangeKeyMute = "mute" // user bool user server muted/unmuteds AuditLogChangeKeyNick = "nick" // user string user nickname changed AuditLogChangeKeyAvatarHash = "avatar_hash" // user string user avatar changed AuditLogChangeKeyID = "id" // any snowflake the id of the changed entity - sometimes used in conjunction with other keys AuditLogChangeKeyType = "type" // any integer (channel type) or string type of entity created )
all the different keys for an audit log change
const ( NoCacheSpecified cacheRegistry = iota UserCache ChannelCache GuildCache GuildEmojiCache VoiceStateCache GuildMembersCache )
cacheLink keys to redirect to the related cacheLink system
const ( CacheAlgLRU = "lru" CacheAlgLFU = "lfu" CacheAlgTLRU = "tlru" )
the different cacheLink replacement algorithms
const ( ChannelTypeGuildText uint = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory )
Channel types https://discordapp.com/developers/docs/resources/channel#channel-object-channel-types
const ( MessageActivityTypeJoin MessageActivityTypeSpectate MessageActivityTypeListen MessageActivityTypeJoinRequest )
different message acticity types
const ( MessageTypeDefault = iota MessageTypeRecipientAdd MessageTypeRecipientRemove MessageTypeCall MessageTypeChannelNameChange MessageTypeChannelIconChange MessageTypeChannelPinnedMessage MessageTypeGuildMemberJoin )
The different message types usually generated by Discord. eg. "a new user joined"
const ( ReadMessagesPermission = 1 << (iota + 10) SendMessagesPermission SendTTSMessagesPermission ManageMessagesPermission EmbedLinksPermission AttachFilesPermission ReadMessageHistoryPermission MentionEveryonePermission UseExternalEmojisPermission )
Constants for the different bit offsets of text channel permissions
const ( VoiceConnectPermission = 1 << (iota + 20) VoiceSpeakPermission VoiceMuteMembersPermission VoiceDeafenMembersPermission VoiceMoveMembersPermission VoiceUseVADPermission )
Constants for the different bit offsets of voice permissions
const ( ChangeNicknamePermission = 1 << (iota + 26) ManageNicknamesPermission ManageRolesPermission ManageWebhooksPermission ManageEmojisPermission )
Constants for general management.
const ( CreateInstantInvitePermission = 1 << iota KickMembersPermission BanMembersPermission AdministratorPermission ManageChannelsPermission ManageServerPermission AddReactionsPermission ViewAuditLogsPermission AllTextPermission = ReadMessagesPermission | SendMessagesPermission | SendTTSMessagesPermission | ManageMessagesPermission | EmbedLinksPermission | AttachFilesPermission | ReadMessageHistoryPermission | MentionEveryonePermission AllVoicePermission = VoiceConnectPermission | VoiceSpeakPermission | VoiceMuteMembersPermission | VoiceDeafenMembersPermission | VoiceMoveMembersPermission | VoiceUseVADPermission AllChannelPermission = AllTextPermission | AllVoicePermission | CreateInstantInvitePermission | ManageRolesPermission | ManageChannelsPermission | AddReactionsPermission | ViewAuditLogsPermission AllPermission = AllChannelPermission | KickMembersPermission | BanMembersPermission | ManageServerPermission | AdministratorPermission )
Constants for the different bit offsets of general permissions
const ( // StatusIdle presence status for idle StatusIdle = "idle" // StatusDnd presence status for dnd StatusDnd = "dnd" // StatusOnline presence status for online StatusOnline = "online" // StatusOffline presence status for offline StatusOffline = "offline" )
const ( ActivityFlagInstance = 1 << 0 ActivityFlagJoin = 1 << 1 ActivityFlagSpectate = 1 << 2 ActivityFlagJoinRequest = 1 << 3 ActivityFlagSync = 1 << 4 ActivityFlagPlay = 1 << 5 )
flags for the Activity object to signify the type of action taken place
const (
AttachmentSpoilerPrefix = "SPOILER_"
)
const DefaultShardRateLimit float64 = 5.5 // seconds
const EventChannelCreate = event.ChannelCreate
EventChannelCreate Sent when a new channel is created, relevant to the current user. The inner payload is a DM channel or guild channel object.
const EventChannelDelete = event.ChannelDelete
EventChannelDelete Sent when a channel relevant to the current user is deleted. The inner payload is a DM or Guild channel object.
const EventChannelPinsUpdate = event.ChannelPinsUpdate
EventChannelPinsUpdate Sent when a message is pinned or unpinned in a text channel. This is not sent when a pinned message is deleted.
Fields: - ChannelID int64 or Snowflake - LastPinTimestamp time.Now().UTC().Format(time.RFC3339)
TODO fix.
const EventChannelUpdate = event.ChannelUpdate
EventChannelUpdate Sent when a channel is updated. The inner payload is a guild channel object.
const EventGuildBanAdd = event.GuildBanAdd
EventGuildBanAdd Sent when a user is banned from a guild. The inner payload is a user object, with an extra guild_id key.
const EventGuildBanRemove = event.GuildBanRemove
EventGuildBanRemove Sent when a user is unbanned from a guild. The inner payload is a user object, with an extra guild_id key.
const EventGuildCreate = event.GuildCreate
EventGuildCreate This event can be sent in three different scenarios:
- When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the Ready event.
- When a Guild becomes available again to the client.
- When the current user joins a new Guild.
const EventGuildDelete = event.GuildDelete
EventGuildDelete Sent when a guild becomes unavailable during a guild outage, or when the user leaves or is removed from a guild. The inner payload is an unavailable guild object. If the unavailable field is not set, the user was removed from the guild.
const EventGuildEmojisUpdate = event.GuildEmojisUpdate
EventGuildEmojisUpdate Sent when a guild's emojis have been updated.
Fields: - GuildID Snowflake - Emojis []*Emoji
const EventGuildIntegrationsUpdate = event.GuildIntegrationsUpdate
EventGuildIntegrationsUpdate Sent when a guild integration is updated.
Fields: - GuildID Snowflake
const EventGuildMemberAdd = event.GuildMemberAdd
EventGuildMemberAdd Sent when a new user joins a guild. The inner payload is a guild member object with these extra fields:
GuildID Snowflake
Fields:
Member *Member
const EventGuildMemberRemove = event.GuildMemberRemove
EventGuildMemberRemove Sent when a user is removed from a guild (leave/kick/ban).
Fields: - GuildID Snowflake - User *User
const EventGuildMemberUpdate = event.GuildMemberUpdate
EventGuildMemberUpdate Sent when a guild member is updated.
Fields: - GuildID Snowflake - Roles []Snowflake - User *User - Nick string
const EventGuildMembersChunk = event.GuildMembersChunk
EventGuildMembersChunk Sent in response to Gateway Request Guild Members.
Fields: - GuildID Snowflake - Members []*Member
const EventGuildRoleCreate = event.GuildRoleCreate
EventGuildRoleCreate Sent when a guild role is created.
Fields: - GuildID Snowflake - Role *Role
const EventGuildRoleDelete = event.GuildRoleDelete
EventGuildRoleDelete Sent when a guild role is created.
Fields: - GuildID Snowflake - RoleID Snowflake
const EventGuildRoleUpdate = event.GuildRoleUpdate
EventGuildRoleUpdate Sent when a guild role is created.
Fields: - GuildID Snowflake - Role *Role
const EventGuildUpdate = event.GuildUpdate
EventGuildUpdate Sent when a guild is updated. The inner payload is a guild object.
const EventMessageCreate = event.MessageCreate
EventMessageCreate Sent when a message is created. The inner payload is a message object.
const EventMessageDelete = event.MessageDelete
EventMessageDelete Sent when a message is deleted.
Fields: - ID Snowflake - ChannelID Snowflake
const EventMessageDeleteBulk = event.MessageDeleteBulk
EventMessageDeleteBulk Sent when multiple messages are deleted at once.
Fields: - IDs []Snowflake - ChannelID Snowflake
const EventMessageReactionAdd = event.MessageReactionAdd
EventMessageReactionAdd Sent when a user adds a reaction to a message.
Fields: - UserID Snowflake - ChannelID Snowflake - MessageID Snowflake - Emoji *Emoji
const EventMessageReactionRemove = event.MessageReactionRemove
EventMessageReactionRemove Sent when a user removes a reaction from a message.
Fields: - UserID Snowflake - ChannelID Snowflake - MessageID Snowflake - Emoji *Emoji
const EventMessageReactionRemoveAll = event.MessageReactionRemoveAll
EventMessageReactionRemoveAll Sent when a user explicitly removes all reactions from a message.
Fields: - ChannelID Snowflake - MessageID Snowflake
const EventMessageUpdate = event.MessageUpdate
EventMessageUpdate Sent when a message is updated. The inner payload is a message object.
NOTE! Has _at_least_ the GuildID and ChannelID fields.
const EventPresenceUpdate = event.PresenceUpdate
EventPresenceUpdate A user's presence is their current state on a guild. This event is sent when a user's presence is updated for a guild.
Fields: - User *User - Roles []Snowflake - Game *Activity - GuildID Snowflake - Status string
const EventPresencesReplace = event.PresencesReplace
EventPresencesReplace Holds and array of presence update objects
const EventReady = event.Ready
EventReady The ready event is dispatched when a client has completed the initial handshake with the gateway (for new sessions). // The ready event can be the largest and most complex event the gateway will send, as it contains all the state // required for a client to begin interacting with the rest of the platform. // Fields: // - V int // - User *User // - PrivateChannels []*Channel // - Guilds []*GuildUnavailable // - SessionID string // - Trace []string
const EventResumed = event.Resumed
EventResumed The resumed event is dispatched when a client has sent a resume payload to the gateway (for resuming existing sessions).
Fields: - Trace []string
const EventTypingStart = event.TypingStart
EventTypingStart Sent when a user starts typing in a channel.
Fields: - ChannelID Snowflake - UserID Snowflake - TimestampUnix int
const EventUserUpdate = event.UserUpdate
EventUserUpdate Sent when properties about the user change. Inner payload is a user object.
const EventVoiceServerUpdate = event.VoiceServerUpdate
EventVoiceServerUpdate Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
Fields: - Token string - ChannelID Snowflake - Endpoint string
const EventVoiceStateUpdate = event.VoiceStateUpdate
EventVoiceStateUpdate Sent when someone joins/leaves/moves voice channels. Inner payload is a voice state object.
const EventWebhooksUpdate = event.WebhooksUpdate
EventWebhooksUpdate Sent when a guild channel's webhook is created, updated, or deleted.
Fields: - GuildID Snowflake - ChannelID Snowflake
Variables ¶
This section is empty.
Functions ¶
func AddGuildMemberRole ¶ added in v0.6.0
AddGuildMemberRole [REST] Adds a role to a guild member. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty response on success. Fires a Guild Member Update Gateway event.
Method PUT Endpoint /guilds/{guild.id}/members/{user.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/members TODO: I don't know if this is correct Discord documentation https://discordapp.com/developers/docs/resources/guild#add-guild-member-role Reviewed 2018-08-18 Comment -
func AddPinnedChannelMessage ¶ added in v0.6.0
AddPinnedChannelMessage [REST] Pin a message in a channel. Requires the 'MANAGE_MESSAGES' permission. Returns a 204 empty response on success.
Method PUT Endpoint /channels/{channel.id}/pins/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#add-pinned-channel-message Reviewed 2018-06-10 Comment -
func BulkDeleteMessages ¶ added in v0.6.0
func BulkDeleteMessages(client httd.Poster, chanID Snowflake, params *BulkDeleteMessagesParams) (err error)
BulkDeleteMessages [REST] Delete multiple messages in a single request. This endpoint can only be used on guild channels and requires the 'MANAGE_MESSAGES' permission. Returns a 204 empty response on success. Fires multiple Message Delete Gateway events.Any message IDs given that do not exist or are invalid will count towards the minimum and maximum message count (currently 2 and 100 respectively). Additionally, duplicated IDs will only be counted once.
Method POST Endpoint /channels/{channel.id}/messages/bulk-delete Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] TODO: is this limiter key incorrect? Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-message Reviewed 2018-06-10 Comment This endpoint will not delete messages older than 2 weeks, and will fail if any message provided is older than that.
func CreateGuildBan ¶ added in v0.6.0
func CreateGuildBan(client httd.Puter, guildID, userID Snowflake, params *CreateGuildBanParams) (err error)
CreateGuildBan [REST] Create a guild ban, and optionally delete previous messages sent by the banned user. Requires the 'BAN_MEMBERS' permission. Returns a 204 empty response on success. Fires a Guild Ban Add Gateway event.
Method PUT Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-ban Reviewed 2018-08-18 Comment -
func CreateGuildIntegration ¶ added in v0.6.0
func CreateGuildIntegration(client httd.Poster, guildID Snowflake, params *CreateGuildIntegrationParams) (err error)
CreateGuildIntegration [REST] Attach an integration object from the current user to the guild. Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success. Fires a Guild Integrations Update Gateway event.
Method POST Endpoint /guilds/{guild.id}/integrations Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-integration Reviewed 2018-08-18 Comment -
func CreateReaction ¶ added in v0.6.0
func CreateReaction(client httd.Puter, channelID, messageID Snowflake, emoji interface{}) (err error)
CreateReaction [REST] Create a reaction for the message. This endpoint requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the 'ADD_REACTIONS' permission to be present on the current user. Returns a 204 empty response on success. The maximum request size when sending a message is 8MB.
Method PUT Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages/reactions Discord documentation https://discordapp.com/developers/docs/resources/channel#create-reaction Reviewed 2019-01-30 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom
func DefaultLogger ¶ added in v0.9.0
func DefaultLoggerWithInstance ¶ added in v0.9.0
func DeleteAllReactions ¶ added in v0.6.0
DeleteAllReactions [REST] Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user.
Method DELETE Endpoint /channels/{channel.id}/messages/{message.id}/reactions Rate limiter [MAJOR] /channels/{channel.id}/messages/reactions Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-all-reactions Reviewed 2019-01-28 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom
func DeleteChannelPermission ¶ added in v0.6.0
DeleteChannelPermission [REST] Delete a channel permission overwrite for a user or role in a channel. Only usable for guild channels. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty response on success. For more information about permissions, see permissions: https://discordapp.com/developers/docs/topics/permissions#permissions
Method DELETE Endpoint /channels/{channel.id}/permissions/{overwrite.id} Rate limiter [MAJOR] /channels/{channel.id}/permissions Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-channel-permission Reviewed 2018-06-07 Comment -
func DeleteGuild ¶ added in v0.6.0
DeleteGuild [REST] Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event.
Method DELETE Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild Reviewed 2018-08-17 Comment -
func DeleteGuildEmoji ¶ added in v0.6.0
DeleteGuildEmoji [REST] Delete the given emoji. Requires the 'MANAGE_EMOJIS' permission. Returns 204 No Content on success. Fires a Guild Emojis Update Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#delete-guild-emoji Reviewed 2018-06-10 Comment -
func DeleteGuildIntegration ¶ added in v0.6.0
DeleteGuildIntegration [REST] Delete the attached integration object for the guild. Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success. Fires a Guild Integrations Update Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/integrations/{integration.id} Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild-integration Reviewed 2018-08-18 Comment -
func DeleteGuildRole ¶ added in v0.6.0
DeleteGuildRole [REST] Delete a guild role. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty response on success. Fires a Guild Role Delete Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild-role Reviewed 2018-08-18 Comment -
func DeleteMessage ¶ added in v0.6.0
DeleteMessage [REST] Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the 'MANAGE_MESSAGES' permission. Returns a 204 empty response on success. Fires a Message Delete Gateway event.
Method DELETE Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-message Reviewed 2018-06-10 Comment -
func DeleteOwnReaction ¶ added in v0.6.0
func DeleteOwnReaction(client httd.Deleter, channelID, messageID Snowflake, emoji interface{}) (err error)
DeleteOwnReaction [REST] Delete a reaction the current user has made for the message. Returns a 204 empty response on success.
Method DELETE Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages/reactions Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-own-reaction Reviewed 2019-01-28 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom
func DeletePinnedChannelMessage ¶ added in v0.6.0
DeletePinnedChannelMessage [REST] Delete a pinned message in a channel. Requires the 'MANAGE_MESSAGES' permission. Returns a 204 empty response on success. Returns a 204 empty response on success.
Method DELETE Endpoint /channels/{channel.id}/pins/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-pinned-channel-message Reviewed 2018-06-10 Comment -
func DeleteUserReaction ¶ added in v0.6.0
func DeleteUserReaction(client httd.Deleter, channelID, messageID, userID Snowflake, emoji interface{}) (err error)
DeleteUserReaction [REST] Deletes another user's reaction. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user. Returns a 204 empty response on success.
Method DELETE Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages/reactions Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-user-reaction Reviewed 2019-01-28 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom
func DeleteWebhook ¶ added in v0.6.0
DeleteWebhook [REST] Delete a webhook permanently. User must be owner. Returns a 204 NO CONTENT response on success.
Method DELETE Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#delete-webhook Reviewed 2018-08-14 Comment -
func DeleteWebhookWithToken ¶ added in v0.6.0
DeleteWebhookWithToken [REST] Same as DeleteWebhook, except this call does not require authentication.
Method DELETE Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#delete-webhook-with-token Reviewed 2018-08-14 Comment -
func EditChannelPermissions ¶ added in v0.6.0
func EditChannelPermissions(client httd.Puter, chanID, overwriteID Snowflake, params *EditChannelPermissionsParams) (err error)
EditChannelPermissions [REST] Edit the channel permission overwrites for a user or role in a channel. Only usable for guild channels. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty response on success. For more information about permissions, see permissions.
Method PUT Endpoint /channels/{channel.id}/permissions/{overwrite.id} Rate limiter [MAJOR] /channels/{channel.id}/permissions Discord documentation https://discordapp.com/developers/docs/resources/channel#edit-channel-permissions Reviewed 2018-06-07 Comment -
func ExecuteGitHubWebhook ¶ added in v0.6.0
func ExecuteGitHubWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)
ExecuteGitHubWebhook [REST] Trigger a webhook in Discord from the GitHub app.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-githubcompatible-webhook Reviewed 2018-08-14 Comment Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint. as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring.
func ExecuteSlackWebhook ¶ added in v0.6.0
func ExecuteSlackWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)
ExecuteSlackWebhook [REST] Trigger a webhook in Discord from the Slack app.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-slackcompatible-webhook Reviewed 2018-08-14 Comment Refer to Slack's documentation for more information. We do not support Slack's channel, icon_emoji, mrkdwn, or mrkdwn_in properties.
func ExecuteWebhook ¶ added in v0.6.0
func ExecuteWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error)
ExecuteWebhook [REST] Trigger a webhook in Discord.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-webhook Reviewed 2018-08-14 Comment This endpoint. supports both JSON and form data bodies. It does require multipart/form-data requests instead of the normal JSON request type when uploading files. Make sure you set your Content-Type to multipart/form-data if you're doing that. Note that in that case, the embeds field cannot be used, but you can pass an url-encoded JSON body as a form value for payload_json. Comment#2 For the webhook embed objects, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images.
TODO
func GetShardForGuildID ¶ added in v0.8.0
GetShardForGuildID converts a GuildID into a ShardID for correct retrieval of guild information
func GroupDMAddRecipient ¶ added in v0.6.0
func GroupDMAddRecipient(client httd.Puter, channelID, userID Snowflake, params *GroupDMAddRecipientParams) (err error)
GroupDMAddRecipient [REST] Adds a recipient to a Group DM using their access token. Returns a 204 empty response on success.
Method PUT Endpoint /channels/{channel.id}/recipients/{user.id} Rate limiter [MAJOR] /channels/{channel.id}/recipients Discord documentation https://discordapp.com/developers/docs/resources/channel#group-dm-add-recipient Reviewed 2018-06-10 Comment -
func GroupDMRemoveRecipient ¶ added in v0.6.0
GroupDMRemoveRecipient [REST] Removes a recipient from a Group DM. Returns a 204 empty response on success.
Method DELETE Endpoint /channels/{channel.id}/recipients/{user.id} Rate limiter [MAJOR] /channels/{channel.id}/recipients Discord documentation https://discordapp.com/developers/docs/resources/channel#group-dm-remove-recipient Reviewed 2018-06-10 Comment -
func LeaveGuild ¶ added in v0.6.0
LeaveGuild [REST] Leave a guild. Returns a 204 empty response on success.
Method DELETE Endpoint /users/@me/guilds/{guild.id} Rate limiter /users/@me/guilds Discord documentation https://discordapp.com/developers/docs/resources/user#leave-guild Reviewed 2019-02-18 Comment -
func ModifyCurrentUserNick ¶ added in v0.6.0
func ModifyCurrentUserNick(client httd.Patcher, id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error)
ModifyCurrentUserNick [REST] Modifies the nickname of the current user in a guild. Returns a 200 with the nickname on success. Fires a Guild Member Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id}/members/@me/nick Rate limiter /guilds/{guild.id}/members TODO: I don't know if this is correct Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-current-user-nick Reviewed 2018-08-18 Comment -
func ModifyGuildIntegration ¶ added in v0.6.0
func ModifyGuildIntegration(client httd.Patcher, guildID, integrationID Snowflake, params *ModifyGuildIntegrationParams) (err error)
ModifyGuildIntegration [REST] Modify the behavior and settings of a integration object for the guild. Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success. Fires a Guild Integrations Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id}/integrations/{integration.id} Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-integration Reviewed 2018-08-18 Comment -
func ModifyGuildMember ¶ added in v0.6.0
func ModifyGuildMember(client httd.Patcher, guildID, userID Snowflake, params *ModifyGuildMemberParams) (err error)
ModifyGuildMember [REST] Modify attributes of a guild member. Returns a 204 empty response on success. Fires a Guild Member Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-member Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional. When moving members to channels, the API user must have permissions to both connect to the channel and have the MOVE_MEMBERS permission.
func New ¶ added in v0.9.0
func New(conf *Config) (c *client)
New create a client. But panics on configuration/setup errors.
func NewClient ¶
NewClient creates a new DisGord client and returns an error on configuration issues
func NewRESTClient ¶ added in v0.8.0
NewRESTClient creates a client for sending and handling Discord protocols such as rate limiting
func RemoveGuildBan ¶ added in v0.6.0
RemoveGuildBan [REST] Remove the ban for a user. Requires the 'BAN_MEMBERS' permissions. Returns a 204 empty response on success. Fires a Guild Ban Remove Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-ban Reviewed 2018-08-18 Comment -
func RemoveGuildMember ¶ added in v0.6.0
RemoveGuildMember [REST] Remove a member from a guild. Requires 'KICK_MEMBERS' permission. Returns a 204 empty response on success. Fires a Guild Member Remove Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-member Reviewed 2018-08-18 Comment -
func RemoveGuildMemberRole ¶ added in v0.6.0
RemoveGuildMemberRole [REST] Removes a role from a guild member. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty response on success. Fires a Guild Member Update Gateway event.
Method DELETE Endpoint /guilds/{guild.id}/members/{user.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-member-role Reviewed 2018-08-18 Comment -
func SyncGuildIntegration ¶ added in v0.6.0
SyncGuildIntegration [REST] Sync an integration. Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success.
Method POST Endpoint /guilds/{guild.id}/integrations/{integration.id}/sync Rate limiter /guilds/{guild.id}/integrations TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/guild#sync-guild-integration Reviewed 2018-08-18 Comment -
func TriggerTypingIndicator ¶ added in v0.6.0
TriggerTypingIndicator [REST] Post a typing indicator for the specified channel. Generally bots should not implement this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message. Returns a 204 empty response on success. Fires a Typing Start Gateway event.
Method POST Endpoint /channels/{channel.id}/typing Rate limiter [MAJOR] /channels/{channel.id}/typing Discord documentation https://discordapp.com/developers/docs/resources/channel#trigger-typing-indicator Reviewed 2018-06-10 Comment -
func ValidateUsername ¶ added in v0.8.0
ValidateUsername uses Discords rule-set to verify user-names and nicknames https://discordapp.com/developers/docs/resources/user#usernames-and-nicknames
Note that not all the rules are listed in the docs:
There are other rules and restrictions not shared here for the sake of spam and abuse mitigation, but the majority of users won't encounter them. It's important to properly handle all error messages returned by Discord when editing or updating names.
Types ¶
type Activity ¶ added in v0.8.0
type Activity struct { Lockable `json:"-"` Name string `json:"name"` // the activity's name Type int `json:"type"` // activity type URL *string `json:"url,omitempty"` //stream url, is validated when type is 1 Timestamps *ActivityTimestamp `json:"timestamps,omitempty"` // timestamps object unix timestamps for start and/or end of the game ApplicationID Snowflake `json:"application_id,omitempty"` //? snowflake application id for the game Details *string `json:"details,omitempty"` //? ?string what the player is currently doing State *string `json:"state,omitempty"` //state? ?string the user's current party status Party *ActivityParty `json:"party,omitempty"` //party? party object information for the current party of the player Assets *ActivityAssets `json:"assets,omitempty"` // assets? assets object images for the presence and their hover texts Secrets *ActivitySecrets `json:"secrets,omitempty"` // secrets? secrets object secrets for Rich Presence joining and spectating Instance bool `json:"instance,omitempty"` // instance? boolean whether or not the activity is an instanced game session Flags int `json:"flags,omitempty"` // flags? int activity flags ORd together, describes what the payload includes }
Activity https://discordapp.com/developers/docs/topics/gateway#activity-object-activity-structure
func (*Activity) CopyOverTo ¶ added in v0.8.0
CopyOverTo see interface at struct.go#Copier
type ActivityAssets ¶ added in v0.7.0
type ActivityAssets struct { Lockable `json:"-"` LargeImage string `json:"large_image,omitempty"` // the id for a large asset of the activity, usually a snowflake LargeText string `json:"large_text,omitempty"` //text displayed when hovering over the large image of the activity SmallImage string `json:"small_image,omitempty"` // the id for a small asset of the activity, usually a snowflake SmallText string `json:"small_text,omitempty"` // text displayed when hovering over the small image of the activity }
ActivityAssets ...
func (*ActivityAssets) CopyOverTo ¶ added in v0.7.0
func (a *ActivityAssets) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityAssets) DeepCopy ¶ added in v0.7.0
func (a *ActivityAssets) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ActivityParty ¶ added in v0.7.0
type ActivityParty struct { Lockable `json:"-"` ID string `json:"id,omitempty"` // the id of the party Size []int `json:"size,omitempty"` // used to show the party's current and maximum size }
ActivityParty ...
func (*ActivityParty) CopyOverTo ¶ added in v0.7.0
func (ap *ActivityParty) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityParty) DeepCopy ¶ added in v0.7.0
func (ap *ActivityParty) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*ActivityParty) Limit ¶ added in v0.7.0
func (ap *ActivityParty) Limit() int
Limit shows the maximum number of guests/people allowed
func (*ActivityParty) NumberOfPeople ¶ added in v0.7.0
func (ap *ActivityParty) NumberOfPeople() int
NumberOfPeople shows the current number of people attending the Party
type ActivitySecrets ¶ added in v0.7.0
type ActivitySecrets struct { Lockable `json:"-"` Join string `json:"join,omitempty"` // the secret for joining a party Spectate string `json:"spectate,omitempty"` // the secret for spectating a game Match string `json:"match,omitempty"` // the secret for a specific instanced match }
ActivitySecrets ...
func (*ActivitySecrets) CopyOverTo ¶ added in v0.7.0
func (a *ActivitySecrets) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivitySecrets) DeepCopy ¶ added in v0.7.0
func (a *ActivitySecrets) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ActivityTimestamp ¶ added in v0.7.0
type ActivityTimestamp struct { Lockable `json:"-"` Start int `json:"start,omitempty"` // unix time (in milliseconds) of when the activity started End int `json:"end,omitempty"` // unix time (in milliseconds) of when the activity ends }
ActivityTimestamp ...
func (*ActivityTimestamp) CopyOverTo ¶ added in v0.7.0
func (a *ActivityTimestamp) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityTimestamp) DeepCopy ¶ added in v0.7.0
func (a *ActivityTimestamp) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AddGuildMemberParams ¶ added in v0.6.0
type AddGuildMemberParams struct { AccessToken string `json:"access_token"` Nick string `json:"nick,omitempty"` Roles []Snowflake `json:"roles"` Mute bool `json:"mute"` Deaf bool `json:"deaf"` }
AddGuildMemberParams ... https://discordapp.com/developers/docs/resources/guild#add-guild-member-json-params
type Attachment ¶ added in v0.6.0
type Attachment struct { ID Snowflake `json:"id"` Filename string `json:"filename"` Size uint `json:"size"` URL string `json:"url"` ProxyURL string `json:"proxy_url"` Height uint `json:"height"` Width uint `json:"width"` SpoilerTag bool `json:"-"` }
Attachment https://discordapp.com/developers/docs/resources/channel#attachment-object
func (*Attachment) DeepCopy ¶ added in v0.8.0
func (a *Attachment) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLog ¶ added in v0.6.0
type AuditLog struct { Lockable `json:"-"` Webhooks []*Webhook `json:"webhooks"` Users []*User `json:"users"` AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"` }
AuditLog ...
func (*AuditLog) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
type AuditLogChange ¶ added in v0.6.0
type AuditLogChange struct { Lockable `json:"-"` NewValue interface{} `json:"new_value,omitempty"` OldValue interface{} `json:"old_value,omitempty"` Key string `json:"key"` }
AuditLogChange ...
func (*AuditLogChange) CopyOverTo ¶ added in v0.7.0
func (l *AuditLogChange) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogChange) DeepCopy ¶ added in v0.7.0
func (l *AuditLogChange) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLogEntry ¶ added in v0.6.0
type AuditLogEntry struct { Lockable `json:"-"` TargetID Snowflake `json:"target_id"` Changes []*AuditLogChange `json:"changes,omitempty"` UserID Snowflake `json:"user_id"` ID Snowflake `json:"id"` ActionType uint `json:"action_type"` Options []*AuditLogOption `json:"options,omitempty"` Reason string `json:"reason,omitempty"` }
AuditLogEntry ...
func (*AuditLogEntry) CopyOverTo ¶ added in v0.7.0
func (l *AuditLogEntry) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogEntry) DeepCopy ¶ added in v0.7.0
func (l *AuditLogEntry) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLogOption ¶ added in v0.6.0
type AuditLogOption struct { Lockable `json:"-"` DeleteMemberDays string `json:"delete_member_days"` MembersRemoved string `json:"members_removed"` ChannelID Snowflake `json:"channel_id"` Count string `json:"count"` ID Snowflake `json:"id"` Type string `json:"type"` // type of overwritten entity ("member" or "role") RoleName string `json:"role_name"` }
AuditLogOption ...
func (*AuditLogOption) CopyOverTo ¶ added in v0.7.0
func (l *AuditLogOption) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogOption) DeepCopy ¶ added in v0.7.0
func (l *AuditLogOption) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLogsRESTer ¶ added in v0.8.0
type AuditLogsRESTer interface {
GetGuildAuditLogs(guildID Snowflake) *guildAuditLogsBuilder
}
AuditLogsRESTer REST interface for all audit-logs endpoints
type AvatarParamHolder ¶ added in v0.8.0
type AvatarParamHolder interface { json.Marshaler Empty() bool SetAvatar(avatar string) UseDefaultAvatar() }
AvatarParamHolder is used when handling avatar related REST structs. since a Avatar can be reset by using nil, it causes some extra issues as omit empty cannot be used to get around this, the struct requires an internal state and must also handle custom marshalling
type Ban ¶ added in v0.6.0
Ban https://discordapp.com/developers/docs/resources/guild#ban-object
func GetGuildBan ¶ added in v0.6.0
GetGuildBan [REST] Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the 'BAN_MEMBERS' permission.
Method GET Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-ban Reviewed 2018-08-18 Comment -
func GetGuildBans ¶ added in v0.6.0
GetGuildBans [REST] Returns a list of ban objects for the users banned from this guild. Requires the 'BAN_MEMBERS' permission.
Method GET Endpoint /guilds/{guild.id}/bans Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-bans Reviewed 2018-08-18 Comment -
func (*Ban) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
type BodyUserCreateDM ¶ added in v0.6.0
type BodyUserCreateDM struct {
RecipientID Snowflake `json:"recipient_id"`
}
BodyUserCreateDM JSON param for func CreateDM
type BulkDeleteMessagesParams ¶ added in v0.6.0
type BulkDeleteMessagesParams struct { Messages []Snowflake `json:"messages"` // contains filtered or unexported fields }
BulkDeleteMessagesParams https://discordapp.com/developers/docs/resources/channel#bulk-delete-messages-json-params
func (*BulkDeleteMessagesParams) AddMessage ¶ added in v0.6.0
func (p *BulkDeleteMessagesParams) AddMessage(msg *Message) (err error)
AddMessage Adds a message to be deleted
func (*BulkDeleteMessagesParams) Valid ¶ added in v0.6.0
func (p *BulkDeleteMessagesParams) Valid() (err error)
Valid validates the BulkDeleteMessagesParams data
type Cache ¶ added in v0.6.0
type Cache struct {
// contains filtered or unexported fields
}
Cache is the actual cacheLink. It holds the different systems which can be tweaked using the CacheConfig.
func (*Cache) AddGuildChannel ¶ added in v0.9.0
func (c *Cache) AddGuildChannel(guildID snowflake.ID, channelID snowflake.ID)
func (*Cache) AddGuildMember ¶ added in v0.9.0
func (*Cache) AddGuildRole ¶ added in v0.9.0
func (*Cache) DeleteChannel ¶ added in v0.8.0
DeleteChannel ...
func (*Cache) DeleteGuild ¶ added in v0.8.0
DeleteGuild ...
func (*Cache) DeleteGuildChannel ¶ added in v0.8.0
DeleteGuildChannel removes a channel from a cached guild object without removing the guild
func (*Cache) DeleteGuildRole ¶ added in v0.8.0
DeleteGuildRole removes a role from a cached guild object without removing the guild
func (*Cache) DirectUpdate ¶ added in v0.8.4
DirectUpdate is used for socket events to only update provided fields. Will peek into the cacheLink for a matching entry if found it updates it, otherwise a not found error is returned. May return a unmarshal error.
// user update id := extractAttribute([]byte(`"id":"`), 0, jsonData) err := cacheLink.DirectUpdate(UserCache, id, jsonData) if err != nil { // most likely the user does not exist or it could not be updated // add the new user. See Cache.Update }
TODO-optimize: for bulk changes
func (*Cache) Get ¶ added in v0.8.0
func (c *Cache) Get(key cacheRegistry, id Snowflake, args ...interface{}) (v interface{}, err error)
Get retrieve a item in the cacheLink, or get an error when not found or if the cacheLink system is disabled in your CacheConfig configuration.
func (*Cache) GetChannel ¶ added in v0.8.0
GetChannel ...
func (*Cache) GetGuildEmojis ¶ added in v0.8.4
GetGuildRoles ...
func (*Cache) GetGuildMember ¶ added in v0.8.0
GetGuildMember ...
func (*Cache) GetGuildMembersAfter ¶ added in v0.8.0
func (c *Cache) GetGuildMembersAfter(guildID, after Snowflake, limit int) (members []*Member, err error)
GetGuildMembersAfter ...
func (*Cache) GetGuildRoles ¶ added in v0.8.0
GetGuildRoles ...
func (*Cache) GetVoiceState ¶ added in v0.8.0
func (c *Cache) GetVoiceState(guildID Snowflake, params *guildVoiceStateCacheParams) (state *VoiceState, err error)
GetVoiceState ...
func (*Cache) RemoveGuildMember ¶ added in v0.9.0
func (c *Cache) RemoveGuildMember(guildID snowflake.ID, memberID snowflake.ID)
func (*Cache) SetChannel ¶ added in v0.8.0
SetChannel adds a new channel to cacheLink or updates an existing one
func (*Cache) SetGuild ¶ added in v0.8.0
SetGuild adds a new guild to cacheLink or updates an existing one
func (*Cache) SetGuildEmojis ¶ added in v0.8.0
SetGuildEmojis adds a new guild to cacheLink if no guild exist for the emojis or updates an existing guild with the new emojis
func (*Cache) SetGuildMember ¶ added in v0.8.0
SetGuildMember calls SetGuildMembers
func (*Cache) SetGuildMembers ¶ added in v0.8.0
SetGuildMembers adds the members to a guild or updates an existing guild
func (*Cache) SetGuildRoles ¶ added in v0.8.0
SetGuildRoles creates a new guild if none is found and updates the roles for a given guild
func (*Cache) SetUser ¶ added in v0.8.0
SetUser updates an existing user or adds a new one to the cacheLink
func (*Cache) SetVoiceState ¶ added in v0.8.0
func (c *Cache) SetVoiceState(state *VoiceState)
SetVoiceState adds a new voice state to cacheLink or updates an existing one
func (*Cache) Update ¶ added in v0.8.0
Update updates a item in the cacheLink given the key identifier and the new content. It also checks if the given structs implements the required interfaces (See below).
func (*Cache) UpdateChannelLastMessageID ¶ added in v0.8.0
UpdateChannelLastMessageID ...
func (*Cache) UpdateChannelPin ¶ added in v0.8.0
UpdateChannelPin ...
func (*Cache) UpdateGuildRole ¶ added in v0.9.0
func (c *Cache) UpdateGuildRole(guildID snowflake.ID, role *Role, data json.RawMessage) bool
func (*Cache) UpdateMemberAndUser ¶ added in v0.9.0
func (c *Cache) UpdateMemberAndUser(guildID, userID snowflake.ID, data json.RawMessage)
func (*Cache) UpdateOrAddGuildMembers ¶ added in v0.9.0
UpdateOrAddGuildMembers updates and add new members to the guild. It discards the user object so these must be handled before hand. complexity: O(M * N)
type CacheConfig ¶ added in v0.8.0
type CacheConfig struct { // may be false, the new Mutable makes it immutable by default // Deprecated Immutable bool Mutable bool // Must be immutable to support concurrent access and long-running tasks(!) DisableUserCaching bool // Deprecated UserCacheLimitMiB uint UserCacheMaxEntries uint UserCacheLifetime time.Duration UserCacheAlgorithm string DisableVoiceStateCaching bool VoiceStateCacheMaxEntries uint VoiceStateCacheLifetime time.Duration VoiceStateCacheAlgorithm string DisableChannelCaching bool // Deprecated ChannelCacheLimitMiB uint ChannelCacheMaxEntries uint ChannelCacheLifetime time.Duration ChannelCacheAlgorithm string DisableGuildCaching bool // Deprecated GuildCacheLimitMiB uint GuildCacheMaxEntries uint GuildCacheLifetime time.Duration GuildCacheAlgorithm string }
CacheConfig allows for tweaking the cacheLink system on a personal need
func DefaultCacheConfig ¶ added in v0.9.0
func DefaultCacheConfig() *CacheConfig
type Cacher ¶ added in v0.6.0
type Cacher interface { Update(key cacheRegistry, v interface{}) (err error) Get(key cacheRegistry, id Snowflake, args ...interface{}) (v interface{}, err error) DeleteChannel(channelID snowflake.ID) DeleteGuildChannel(guildID snowflake.ID, channelID snowflake.ID) AddGuildChannel(guildID snowflake.ID, channelID snowflake.ID) AddGuildMember(guildID snowflake.ID, member *Member) RemoveGuildMember(guildID snowflake.ID, memberID snowflake.ID) UpdateChannelPin(channelID snowflake.ID, lastPinTimestamp Timestamp) UpdateMemberAndUser(guildID, userID snowflake.ID, data json.RawMessage) DeleteGuild(guildID snowflake.ID) DeleteGuildRole(guildID snowflake.ID, roleID snowflake.ID) UpdateChannelLastMessageID(channelID snowflake.ID, messageID snowflake.ID) SetGuildEmojis(guildID Snowflake, emojis []*Emoji) Updates(key cacheRegistry, vs []interface{}) error AddGuildRole(guildID Snowflake, role *Role) UpdateGuildRole(guildID Snowflake, role *Role, messages json.RawMessage) bool }
Cacher gives basic cacheLink interaction options, and won't require changes when adding more cacheLink systems
type Channel ¶ added in v0.6.0
type Channel struct { Lockable `json:"-"` ID Snowflake `json:"id"` Type uint `json:"type"` GuildID Snowflake `json:"guild_id,omitempty"` // ?| Position uint `json:"position,omitempty"` // ?| PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"` // ?| Name string `json:"name,omitempty"` // ?| Topic string `json:"topic,omitempty"` // ?|? NSFW bool `json:"nsfw,omitempty"` // ?| LastMessageID Snowflake `json:"last_message_id,omitempty"` // ?|? Bitrate uint `json:"bitrate,omitempty"` // ?| UserLimit uint `json:"user_limit,omitempty"` // ?| RateLimitPerUser uint `json:"rate_limit_per_user,omitempty"` // ?| Recipients []*User `json:"recipient,omitempty"` // ?| , empty if not DM/GroupDM Icon *string `json:"icon,omitempty"` // ?|? OwnerID Snowflake `json:"owner_id,omitempty"` // ?| ApplicationID Snowflake `json:"application_id,omitempty"` // ?| ParentID Snowflake `json:"parent_id,omitempty"` // ?|? LastPinTimestamp Timestamp `json:"last_pin_timestamp,omitempty"` // ?| // contains filtered or unexported fields }
Channel ...
func CreateDM ¶ added in v0.6.0
CreateDM [REST] Create a new DM channel with a user. Returns a DM channel object.
Method POST Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#create-dm Reviewed 2018-06-10 Comment -
TODO: review
func CreateGroupDM ¶ added in v0.6.0
func CreateGroupDM(client httd.Poster, params *CreateGroupDMParams) (ret *Channel, err error)
CreateGroupDM [REST] Create a new group DM channel with multiple users. Returns a DM channel object.
Method POST Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#create-group-dm Reviewed 2018-06-10 Comment -
func CreateGuildChannel ¶ added in v0.6.0
func CreateGuildChannel(client httd.Poster, id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error)
CreateGuildChannel [REST] Create a new channel object for the guild. Requires the 'MANAGE_CHANNELS' permission. Returns the new channel object on success. Fires a Channel Create Gateway event.
Method POST Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-channel Reviewed 2018-08-17 Comment All parameters for this endpoint. are optional excluding 'name'
func DeleteChannel ¶ added in v0.6.0
DeleteChannel [REST] Delete a channel, or close a private message. Requires the 'MANAGE_CHANNELS' permission for the guild. Deleting a category does not delete its child channels; they will have their parent_id removed and a Channel Update Gateway event will fire for each of them. Returns a channel object on success. Fires a Channel Delete Gateway event.
Method Delete Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#deleteclose-channel Reviewed 2018-10-09 Comment Deleting a guild channel cannot be undone. Use this with caution, as it is impossible to undo this action when performed on a guild channel. In contrast, when used with a private message, it is possible to undo the action by opening a private message with the recipient again.
func GetChannel ¶ added in v0.6.0
GetChannel [REST] Get a channel by Snowflake. Returns a channel object.
Method GET Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel Reviewed 2018-06-07 Comment -
func GetGuildChannels ¶ added in v0.6.0
GetGuildChannels [REST] Returns a list of guild channel objects.
Method GET Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-channels Reviewed 2018-08-17 Comment -
func GetUserDMs ¶ added in v0.6.0
GetUserDMs [REST] Returns a list of DM channel objects.
Method GET Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-user-dms Reviewed 2018-06-10 Comment -
func ModifyChannel ¶ added in v0.6.0
func ModifyChannel(client httd.Patcher, id Snowflake, changes *ModifyChannelParams) (ret *Channel, err error)
ModifyChannel [REST] Update a channels settings. Requires the 'MANAGE_CHANNELS' permission for the guild. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Channel Update Gateway event. If modifying a category, individual Channel Update events will fire for each child channel that also changes. For the PATCH method, all the JSON Params are optional.
Method PUT/PATCH Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#modify-channel Reviewed 2018-06-07 Comment andersfylling: only implemented the patch method, as its parameters are optional.
func (*Channel) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*Channel) DeepCopy ¶ added in v0.6.0
func (c *Channel) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Channel) Mention ¶ added in v0.6.0
Mention creates a channel mention string. Mention format is according the Discord protocol.
func (*Channel) SendMsg ¶ added in v0.6.0
func (c *Channel) SendMsg(client MessageSender, message *Message) (msg *Message, err error)
SendMsg sends a message to a channel
func (*Channel) SendMsgString ¶ added in v0.6.0
func (c *Channel) SendMsgString(client MessageSender, content string) (msg *Message, err error)
SendMsgString same as SendMsg, however this only takes the message content (string) as a argument for the message
type ChannelCreate ¶ added in v0.6.0
type ChannelCreate struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelCreate new channel created
func (*ChannelCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelCreateHandler ¶ added in v0.9.0
type ChannelCreateHandler = func(session Session, h *ChannelCreate)
ChannelCreateHandler is triggered in ChannelCreate events
type ChannelDelete ¶ added in v0.6.0
type ChannelDelete struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelDelete channel was deleted
func (*ChannelDelete) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelDeleteHandler ¶ added in v0.9.0
type ChannelDeleteHandler = func(session Session, h *ChannelDelete)
ChannelDeleteHandler is triggered in ChannelDelete events
type ChannelEmbed ¶ added in v0.6.0
type ChannelEmbed struct { Lockable `json:"-"` Title string `json:"title"` // title of embed Type string `json:"type"` // type of embed (always "rich" for webhook embeds) Description string `json:"description"` // description of embed URL string `json:"url"` // url of embed Timestamp time.Time `json:"timestamp"` // timestamp timestamp of embed content Color int `json:"color"` // color code of the embed Image *ChannelEmbedImage `json:"image"` // embed image object image information Thumbnail *ChannelEmbedThumbnail `json:"thumbnail"` // embed thumbnail object thumbnail information Video *ChannelEmbedVideo `json:"video"` // embed video object video information Provider *ChannelEmbedProvider `json:"provider"` // embed provider object provider information Author *ChannelEmbedAuthor `json:"author"` // embed author object author information Fields []*ChannelEmbedField `json:"fields"` // array of embed field objects fields information }
ChannelEmbed https://discordapp.com/developers/docs/resources/channel#embed-object
func (*ChannelEmbed) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbed) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbed) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbed) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedAuthor ¶ added in v0.6.0
type ChannelEmbedAuthor struct { Lockable `json:"-"` Name string `json:"name,omitempty"` // ?| , name of author URL string `json:"url,omitempty"` // ?| , url of author IconURL string `json:"icon_url,omitempty"` // ?| , url of author icon (only supports http(s) and attachments) ProxyIconURL string `json:"proxy_icon_url,omitempty"` // ?| , a proxied url of author icon }
ChannelEmbedAuthor https://discordapp.com/developers/docs/resources/channel#embed-object-embed-author-structure
func (*ChannelEmbedAuthor) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedAuthor) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedAuthor) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedAuthor) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedField ¶ added in v0.6.0
type ChannelEmbedField struct { Lockable `json:"-"` Name string `json:"name"` // | , name of the field Value string `json:"value"` // | , value of the field Inline bool `json:"bool,omitempty"` // ?| , whether or not this field should display inline }
ChannelEmbedField https://discordapp.com/developers/docs/resources/channel#embed-object-embed-field-structure
func (*ChannelEmbedField) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedField) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedField) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedField) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedFooter ¶ added in v0.6.0
type ChannelEmbedFooter struct {}
ChannelEmbedFooter https://discordapp.com/developers/docs/resources/channel#embed-object-embed-footer-structure
func (*ChannelEmbedFooter) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedFooter) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedFooter) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedFooter) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedImage ¶ added in v0.6.0
type ChannelEmbedImage struct { Lockable `json:"-"` URL string `json:"url,omitempty"` // ?| , source url of image (only supports http(s) and attachments) ProxyURL string `json:"proxy_url,omitempty"` // ?| , a proxied url of the image Height int `json:"height,omitempty"` // ?| , height of image Width int `json:"width,omitempty"` // ?| , width of image }
ChannelEmbedImage https://discordapp.com/developers/docs/resources/channel#embed-object-embed-image-structure
func (*ChannelEmbedImage) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedImage) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedImage) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedImage) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedProvider ¶ added in v0.6.0
type ChannelEmbedProvider struct { Lockable `json:"-"` Name string `json:"name,omitempty"` // ?| , name of provider URL string `json:"url,omitempty"` // ?| , url of provider }
ChannelEmbedProvider https://discordapp.com/developers/docs/resources/channel#embed-object-embed-provider-structure
func (*ChannelEmbedProvider) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedProvider) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedProvider) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedProvider) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedThumbnail ¶ added in v0.6.0
type ChannelEmbedThumbnail struct { Lockable `json:"-"` URL string `json:"url,omitempty"` // ?| , source url of image (only supports http(s) and attachments) ProxyURL string `json:"proxy_url,omitempty"` // ?| , a proxied url of the image Height int `json:"height,omitempty"` // ?| , height of image Width int `json:"width,omitempty"` // ?| , width of image }
ChannelEmbedThumbnail https://discordapp.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure
func (*ChannelEmbedThumbnail) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedThumbnail) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedThumbnail) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedThumbnail) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelEmbedVideo ¶ added in v0.6.0
type ChannelEmbedVideo struct { Lockable `json:"-"` URL string `json:"url,omitempty"` // ?| , source url of video Height int `json:"height,omitempty"` // ?| , height of video Width int `json:"width,omitempty"` // ?| , width of video }
ChannelEmbedVideo https://discordapp.com/developers/docs/resources/channel#embed-object-embed-video-structure
func (*ChannelEmbedVideo) CopyOverTo ¶ added in v0.7.0
func (c *ChannelEmbedVideo) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ChannelEmbedVideo) DeepCopy ¶ added in v0.7.0
func (c *ChannelEmbedVideo) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ChannelFetcher ¶ added in v0.6.0
ChannelFetcher holds the single method for fetching a channel from the Discord REST API
type ChannelPinsUpdate ¶ added in v0.6.0
type ChannelPinsUpdate struct { // ChannelID snowflake the id of the channel ChannelID Snowflake `json:"channel_id"` // LastPinTimestamp ISO8601 timestamp the time at which the most recent pinned message was pinned LastPinTimestamp Timestamp `json:"last_pin_timestamp,omitempty"` // ?| Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelPinsUpdate message was pinned or unpinned
type ChannelPinsUpdateHandler ¶ added in v0.9.0
type ChannelPinsUpdateHandler = func(session Session, h *ChannelPinsUpdate)
ChannelPinsUpdateHandler is triggered in ChannelPinsUpdate events
type ChannelRESTer ¶ added in v0.8.0
type ChannelRESTer interface { GetChannel(id Snowflake) (ret *Channel, err error) ModifyChannel(id Snowflake, changes *ModifyChannelParams) (ret *Channel, err error) DeleteChannel(id Snowflake) (channel *Channel, err error) SetChannelPermissions(chanID, overwriteID Snowflake, params *SetChannelPermissionsParams) (err error) GetChannelInvites(id Snowflake) (ret []*Invite, err error) CreateChannelInvites(id Snowflake, params *CreateChannelInvitesParams) (ret *Invite, err error) DeleteChannelPermission(channelID, overwriteID Snowflake) (err error) TriggerTypingIndicator(channelID Snowflake) (err error) GetPinnedMessages(channelID Snowflake) (ret []*Message, err error) AddPinnedChannelMessage(channelID, msgID Snowflake) (err error) DeletePinnedChannelMessage(channelID, msgID Snowflake) (err error) GroupDMAddRecipient(channelID, userID Snowflake, params *GroupDMAddRecipientParams) (err error) GroupDMRemoveRecipient(channelID, userID Snowflake) (err error) GetMessages(channelID Snowflake, params URLParameters) (ret []*Message, err error) GetMessage(channelID, messageID Snowflake) (ret *Message, err error) CreateMessage(channelID Snowflake, params *CreateMessageParams) (ret *Message, err error) EditMessage(chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error) DeleteMessage(channelID, msgID Snowflake) (err error) BulkDeleteMessages(chanID Snowflake, params *BulkDeleteMessagesParams) (err error) CreateReaction(channelID, messageID Snowflake, emoji interface{}) (err error) DeleteOwnReaction(channelID, messageID Snowflake, emoji interface{}) (err error) DeleteUserReaction(channelID, messageID, userID Snowflake, emoji interface{}) (err error) GetReaction(channelID, messageID Snowflake, emoji interface{}, params URLParameters) (ret []*User, err error) DeleteAllReactions(channelID, messageID Snowflake) (err error) // Deprecated: use CreateMessage instead CreateChannelMessage(channelID Snowflake, params *CreateChannelMessageParams) (ret *Message, err error) // Deprecated: use GetMessages instead GetChannelMessages(channelID Snowflake, params URLParameters) (ret []*Message, err error) // Deprecated: use GetMessage instead GetChannelMessage(channelID, messageID Snowflake) (ret *Message, err error) }
ChannelRESTer REST interface for all Channel endpoints
type ChannelUpdate ¶ added in v0.6.0
type ChannelUpdate struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelUpdate channel was updated
func (*ChannelUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelUpdateHandler ¶ added in v0.9.0
type ChannelUpdateHandler = func(session Session, h *ChannelUpdate)
ChannelUpdateHandler is triggered in ChannelUpdate events
type Config ¶
type Config struct { BotToken string HTTPClient *http.Client Proxy proxy.Dialer CancelRequestWhenRateLimited bool DisableCache bool CacheConfig *CacheConfig WSShardManagerConfig *WSShardManagerConfig Presence *UpdateStatusCommand // your project name, name of bot, or application ProjectName string // ActivateEventChannels signifies that the developer will use channels to handle incoming events. May it be // in addition to handlers or not. This forces the use of a scheduler to empty the buffered channels when they // reach their capacity. Since it requires extra resources, others who have no interest in utilizing channels // should not experience any performance penalty (even though it might be unnoticeable). ActivateEventChannels bool // Logger is a dependency that must be injected to support logging. // disgord.DefaultLogger() can be used Logger Logger // contains filtered or unexported fields }
Config Configuration for the DisGord client
type Copier ¶ added in v0.7.0
type Copier interface {
CopyOverTo(other interface{}) error
}
Copier holds the CopyOverTo method which copies all it's content from one struct to another. Note that this requires a deep copy. useful when overwriting already existing content in the cacheLink to reduce GC.
type CreateChannelInvitesParams ¶ added in v0.6.0
type CreateChannelInvitesParams struct { MaxAge int `json:"max_age,omitempty"` // duration of invite in seconds before expiry, or 0 for never. default 86400 (24 hours) MaxUses int `json:"max_uses,omitempty"` // max number of uses or 0 for unlimited. default 0 Temporary bool `json:"temporary,omitempty"` // whether this invite only grants temporary membership. default false Unique bool `json:"unique,omitempty"` // if true, don't try to reuse a similar invite (useful for creating many unique one time use invites). default false }
CreateChannelInvitesParams https://discordapp.com/developers/docs/resources/channel#create-channel-invite-json-params
type CreateChannelMessageFileParams
deprecated
added in
v0.8.0
type CreateChannelMessageFileParams = CreateMessageFileParams
Deprecated: use CreateMessageFileParams instead
type CreateChannelMessageParams
deprecated
added in
v0.6.0
type CreateChannelMessageParams = CreateMessageParams
Deprecated: use CreateMessageParams instead
type CreateGroupDMParams ¶ added in v0.6.0
type CreateGroupDMParams struct { AccessTokens []string `json:"access_tokens"` // access tokens of users that have granted your app the gdm.join scope Nicks map[Snowflake]string `json:"nicks"` // map[userID] = nickname }
CreateGroupDMParams JSON params for func CreateGroupDM https://discordapp.com/developers/docs/resources/user#create-group-dm
type CreateGuildBanParams ¶ added in v0.6.0
type CreateGuildBanParams struct { DeleteMessageDays int `urlparam:"delete_message_days"` // number of days to delete messages for (0-7) Reason string `urlparam:"reason"` // reason for being banned }
CreateGuildBanParams ... https://discordapp.com/developers/docs/resources/guild#create-guild-ban-query-string-params
func (*CreateGuildBanParams) GetQueryString ¶ added in v0.6.0
func (params *CreateGuildBanParams) GetQueryString() string
GetQueryString ...
type CreateGuildChannelParams ¶ added in v0.6.0
type CreateGuildChannelParams struct { Name string `json:"name"` // required Type uint `json:"type,omitempty"` Topic string `json:"topic,omitempty"` Bitrate uint `json:"bitrate,omitempty"` UserLimit uint `json:"user_limit,omitempty"` RateLimitPerUser uint `json:"rate_limit_per_user,omitempty"` PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"` ParentID Snowflake `json:"parent_id,omitempty"` NSFW bool `json:"nsfw,omitempty"` }
CreateGuildChannelParams https://discordapp.com/developers/docs/resources/guild#create-guild-channel-json-params
type CreateGuildEmojiParams ¶ added in v0.6.0
type CreateGuildEmojiParams struct { Name string `json:"name"` Image string `json:"image"` Roles []Snowflake `json:"roles"` }
CreateGuildEmojiParams JSON params for func CreateGuildEmoji
type CreateGuildIntegrationParams ¶ added in v0.6.0
CreateGuildIntegrationParams ... https://discordapp.com/developers/docs/resources/guild#create-guild-integration-json-params
type CreateGuildParams ¶ added in v0.6.0
type CreateGuildParams struct { Name string `json:"name"` Region string `json:"region"` Icon string `json:"icon"` VerificationLvl int `json:"verification_level"` DefaultMsgNotifications DefaultMessageNotificationLvl `json:"default_message_notifications"` ExplicitContentFilter ExplicitContentFilterLvl `json:"explicit_content_filter"` Roles []*Role `json:"roles"` Channels []*PartialChannel `json:"channels"` }
CreateGuildParams ... https://discordapp.com/developers/docs/resources/guild#create-guild-json-params example partial channel object:
{ "name": "naming-things-is-hard", "type": 0 }
type CreateGuildRoleParams ¶ added in v0.6.0
type CreateGuildRoleParams struct { Name string `json:"name,omitempty"` Permissions uint64 `json:"permissions,omitempty"` Color uint `json:"color,omitempty"` Hoist bool `json:"hoist,omitempty"` Mentionable bool `json:"mentionable,omitempty"` }
CreateGuildRoleParams ... https://discordapp.com/developers/docs/resources/guild#create-guild-role-json-params
type CreateMessageFileParams ¶ added in v0.9.3
type CreateMessageFileParams struct { Reader io.Reader `json:"-"` // always omit as we don't want this as part of the JSON payload FileName string `json:"-"` // SpoilerTag lets discord know that this image should be blurred out. // Current Discord behaviour is that whenever a message with one or more images is marked as // spoiler tag, all the images in that message are blurred out. (independent of msg.Content) SpoilerTag bool `json:"-"` }
CreateMessageFileParams contains the information needed to upload a file to Discord, it is part of the CreateMessageParams struct.
type CreateMessageParams ¶ added in v0.9.3
type CreateMessageParams struct { Content string `json:"content"` Nonce Snowflake `json:"nonce,omitempty"` Tts bool `json:"tts,omitempty"` Embed *ChannelEmbed `json:"embed,omitempty"` // embedded rich content Files []CreateMessageFileParams `json:"-"` // Always omit as this is included in multipart, not JSON payload SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` }
CreateMessageParams JSON params for CreateChannelMessage
func NewMessageByString ¶ added in v0.6.0
func NewMessageByString(content string) *CreateMessageParams
NewMessageByString creates a message object from a string/content
type CreateWebhookParams ¶ added in v0.6.0
type CreateWebhookParams struct { Name string `json:"name"` // name of the webhook (2-32 characters) Avatar *string `json:"avatar"` // avatar data uri scheme, image for the default webhook avatar }
CreateWebhookParams json params for the create webhook rest request avatar string https://discordapp.com/developers/docs/resources/user#avatar-data
func NewCreateWebhookParams ¶ added in v0.8.0
func NewCreateWebhookParams(name string, avatar *string) *CreateWebhookParams
type DeepCopier ¶ added in v0.7.0
type DeepCopier interface {
DeepCopy() interface{}
}
DeepCopier holds the DeepCopy method which creates and returns a deep copy of any struct.
type DefaultMessageNotificationLvl ¶ added in v0.6.0
type DefaultMessageNotificationLvl uint
DefaultMessageNotificationLvl ... https://discordapp.com/developers/docs/resources/guild#guild-object-default-message-notification-level
const ( DefaultMessageNotificationLvlAllMessages DefaultMessageNotificationLvl = iota DefaultMessageNotificationLvlOnlyMentions )
different notification levels on new messages
func (*DefaultMessageNotificationLvl) AllMessages ¶ added in v0.6.0
func (dmnl *DefaultMessageNotificationLvl) AllMessages() bool
AllMessages ...
func (*DefaultMessageNotificationLvl) OnlyMentions ¶ added in v0.6.0
func (dmnl *DefaultMessageNotificationLvl) OnlyMentions() bool
OnlyMentions ...
type Discriminator ¶ added in v0.8.0
type Discriminator uint16
Discriminator value
func NewDiscriminator ¶ added in v0.8.0
func NewDiscriminator(d string) (discriminator Discriminator, err error)
NewDiscriminator Discord user discriminator hashtag
func (Discriminator) MarshalJSON ¶ added in v0.8.0
func (d Discriminator) MarshalJSON() (data []byte, err error)
MarshalJSON see interface json.Marshaler
func (Discriminator) NotSet ¶ added in v0.8.0
func (d Discriminator) NotSet() bool
NotSet checks if the discriminator is not set
func (Discriminator) String ¶ added in v0.8.0
func (d Discriminator) String() (str string)
func (*Discriminator) UnmarshalJSON ¶ added in v0.8.0
func (d *Discriminator) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON see interface json.Unmarshaler
type EditChannelPermissionsParams ¶ added in v0.6.0
type EditChannelPermissionsParams struct { Allow int `json:"allow"` // the bitwise value of all allowed permissions Deny int `json:"deny"` // the bitwise value of all disallowed permissions Type string `json:"type"` // "member" for a user or "role" for a role }
EditChannelPermissionsParams https://discordapp.com/developers/docs/resources/channel#edit-channel-permissions-json-params
type EditMessageParams ¶ added in v0.6.0
type EditMessageParams struct { Content string `json:"content,omitempty"` Embed *ChannelEmbed `json:"embed,omitempty"` // embedded rich content }
EditMessageParams https://discordapp.com/developers/docs/resources/channel#edit-message-json-params
type Emitter ¶ added in v0.9.0
type Emitter interface {
Emit(command SocketCommand, dataPointer interface{}) error
}
Emitter for emitting data from A to B. Used in websocket connection
type Emoji ¶ added in v0.6.0
type Emoji struct { ID Snowflake `json:"id"` Name string `json:"name"` Roles []Snowflake `json:"roles,omitempty"` User *User `json:"user,omitempty"` // the user who created the emoji RequireColons bool `json:"require_colons,omitempty"` Managed bool `json:"managed,omitempty"` Animated bool `json:"animated,omitempty"` // contains filtered or unexported fields }
Emoji ...
func CreateGuildEmoji ¶ added in v0.6.0
func CreateGuildEmoji(client httd.Poster, guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error)
CreateGuildEmoji [REST] Create a new emoji for the guild. Requires the 'MANAGE_EMOJIS' permission. Returns the new emoji object on success. Fires a Guild Emojis Update Gateway event.
Method POST Endpoint /guilds/{guild.id}/emojis Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#create-guild-emoji Reviewed 2018-06-10 Comment Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code.
func GetGuildEmoji ¶ added in v0.6.0
GetGuildEmoji [REST] Returns an emoji object for the given guild and emoji IDs.
Method GET Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#get-guild-emoji Reviewed 2018-06-10 Comment -
func ModifyGuildEmoji ¶ added in v0.6.0
func ModifyGuildEmoji(client httd.Patcher, guildID, emojiID Snowflake, params *ModifyGuildEmojiParams) (ret *Emoji, err error)
ModifyGuildEmoji [REST] Modify the given emoji. Requires the 'MANAGE_EMOJIS' permission. Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#modify-guild-emoji Reviewed 2018-06-10 Comment -
func (*Emoji) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*Emoji) DeepCopy ¶ added in v0.7.0
func (e *Emoji) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Emoji) LinkToGuild ¶ added in v0.8.4
func (e *Emoji) LinkToGuild(guildID snowflake.ID)
type EmojiRESTer ¶ added in v0.8.0
type EmojiRESTer interface { GetGuildEmojis(id Snowflake) *listGuildEmojisBuilder GetGuildEmoji(guildID, emojiID Snowflake) (ret *Emoji, err error) CreateGuildEmoji(guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error) ModifyGuildEmoji(guildID, emojiID Snowflake, params *ModifyGuildEmojiParams) (ret *Emoji, err error) DeleteGuildEmoji(guildID, emojiID Snowflake) (err error) }
EmojiRESTer REST interface for all emoji endpoints
type ErrorCacheItemNotFound ¶ added in v0.8.0
type ErrorCacheItemNotFound struct {
// contains filtered or unexported fields
}
ErrorCacheItemNotFound requested item was not found in cacheLink
func (*ErrorCacheItemNotFound) Error ¶ added in v0.8.0
func (e *ErrorCacheItemNotFound) Error() string
Error ...
type ErrorEmptyValue ¶ added in v0.7.0
type ErrorEmptyValue struct {
// contains filtered or unexported fields
}
ErrorEmptyValue when a required value was set as empty
func (*ErrorEmptyValue) Error ¶ added in v0.7.0
func (e *ErrorEmptyValue) Error() string
type ErrorMissingSnowflake ¶ added in v0.7.0
type ErrorMissingSnowflake struct {
// contains filtered or unexported fields
}
ErrorMissingSnowflake used by methods about to communicate with the Discord API. If a snowflake value is required this is used to identify that you must set the value before being able to interact with the Discord API
func (*ErrorMissingSnowflake) Error ¶ added in v0.7.0
func (e *ErrorMissingSnowflake) Error() string
type ErrorUnsupportedType ¶ added in v0.7.0
type ErrorUnsupportedType struct {
// contains filtered or unexported fields
}
ErrorUnsupportedType used when the given param type is not supported
func (*ErrorUnsupportedType) Error ¶ added in v0.7.0
func (e *ErrorUnsupportedType) Error() string
type ErrorUsingDeactivatedCache ¶ added in v0.8.0
type ErrorUsingDeactivatedCache struct {
// contains filtered or unexported fields
}
ErrorUsingDeactivatedCache the cacheLink system you are trying to access has been disabled in the CacheConfig
func (*ErrorUsingDeactivatedCache) Error ¶ added in v0.8.0
func (e *ErrorUsingDeactivatedCache) Error() string
type EventChannels ¶ added in v0.8.0
type EventChannels interface { Ready() <-chan *Ready Resumed() <-chan *Resumed ChannelCreate() <-chan *ChannelCreate ChannelUpdate() <-chan *ChannelUpdate ChannelDelete() <-chan *ChannelDelete ChannelPinsUpdate() <-chan *ChannelPinsUpdate GuildCreate() <-chan *GuildCreate GuildUpdate() <-chan *GuildUpdate GuildDelete() <-chan *GuildDelete GuildBanAdd() <-chan *GuildBanAdd GuildBanRemove() <-chan *GuildBanRemove GuildEmojisUpdate() <-chan *GuildEmojisUpdate GuildIntegrationsUpdate() <-chan *GuildIntegrationsUpdate GuildMemberAdd() <-chan *GuildMemberAdd GuildMemberRemove() <-chan *GuildMemberRemove GuildMemberUpdate() <-chan *GuildMemberUpdate GuildMembersChunk() <-chan *GuildMembersChunk GuildRoleUpdate() <-chan *GuildRoleUpdate GuildRoleCreate() <-chan *GuildRoleCreate GuildRoleDelete() <-chan *GuildRoleDelete MessageCreate() <-chan *MessageCreate MessageUpdate() <-chan *MessageUpdate MessageDelete() <-chan *MessageDelete MessageDeleteBulk() <-chan *MessageDeleteBulk MessageReactionAdd() <-chan *MessageReactionAdd MessageReactionRemove() <-chan *MessageReactionRemove MessageReactionRemoveAll() <-chan *MessageReactionRemoveAll PresenceUpdate() <-chan *PresenceUpdate PresencesReplace() <-chan *PresencesReplace TypingStart() <-chan *TypingStart UserUpdate() <-chan *UserUpdate VoiceStateUpdate() <-chan *VoiceStateUpdate VoiceServerUpdate() <-chan *VoiceServerUpdate WebhooksUpdate() <-chan *WebhooksUpdate }
EventChannels all methods for retrieving event channels
type ExecuteWebhookParams ¶ added in v0.6.0
type ExecuteWebhookParams struct { WebhookID Snowflake `json:"-"` Token string `json:"-"` Content string `json:"content"` Username string `json:"username"` AvatarURL string `json:"avatar_url"` TTS bool `json:"tts"` File interface{} `json:"file"` Embeds []*ChannelEmbed `json:"embeds"` }
ExecuteWebhookParams JSON params for func ExecuteWebhook
func NewExecuteWebhookParams ¶ added in v0.6.0
func NewExecuteWebhookParams(id Snowflake, token string) (ret *ExecuteWebhookParams, err error)
NewExecuteWebhookParams creates params for func ExecuteWebhook
type ExplicitContentFilterLvl ¶ added in v0.6.0
type ExplicitContentFilterLvl uint
ExplicitContentFilterLvl ... https://discordapp.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
const ( ExplicitContentFilterLvlDisabled ExplicitContentFilterLvl = iota ExplicitContentFilterLvlMembersWithoutRoles ExplicitContentFilterLvlAllMembers )
Explicit content filter levels
func (*ExplicitContentFilterLvl) AllMembers ¶ added in v0.6.0
func (ecfl *ExplicitContentFilterLvl) AllMembers() bool
AllMembers if the filter applies for all members regardles of them having a role or not
func (*ExplicitContentFilterLvl) Disabled ¶ added in v0.6.0
func (ecfl *ExplicitContentFilterLvl) Disabled() bool
Disabled if the content filter is disabled
func (*ExplicitContentFilterLvl) MembersWithoutRoles ¶ added in v0.6.0
func (ecfl *ExplicitContentFilterLvl) MembersWithoutRoles() bool
MembersWithoutRoles if the filter only applies for members without a role
type Gateway ¶ added in v0.8.0
type Gateway struct {
URL string `json:"url"`
}
Gateway is for parsing the Gateway endpoint response
func GetGateway ¶ added in v0.8.0
GetGateway [REST] Returns an object with a single valid WSS URL, which the client can use for Connecting. Clients should cacheLink this value and only call this endpoint to retrieve a new URL if they are unable to properly establish a connection using the cached version of the URL.
Method GET Endpoint /gateway Rate limiter /gateway Discord documentation https://discordapp.com/developers/docs/topics/gateway#get-gateway Reviewed 2018-10-12 Comment This endpoint does not require authentication.
type GatewayBot ¶ added in v0.8.0
type GatewayBot struct { Gateway Shards uint `json:"shards"` SessionStartLimit struct { Total uint `json:"total"` Remaining uint `json:"remaining"` ResetAfter uint `json:"reset_after"` } `json:"session_start_limit"` }
GatewayBot is for parsing the Gateway Bot endpoint response
func GetGatewayBot ¶ added in v0.8.0
func GetGatewayBot(client httd.Getter) (gateway *GatewayBot, err error)
GetGatewayBot [REST] Returns an object based on the information in Get Gateway, plus additional metadata that can help during the operation of large or sharded bots. Unlike the Get Gateway, this route should not be cached for extended periods of time as the value is not guaranteed to be the same per-call, and changes as the bot joins/leaves guilds.
Method GET Endpoint /gateway/bot Rate limiter /gateway/bot Discord documentation https://discordapp.com/developers/docs/topics/gateway#get-gateway-bot Reviewed 2018-10-12 Comment This endpoint requires authentication using a valid bot token.
type GetChannelMessagesParams
deprecated
added in
v0.6.0
type GetChannelMessagesParams = GetMessagesParams
Deprecated: use GetMessagesParams instead
type GetCurrentUserGuildsParams ¶ added in v0.6.0
type GetCurrentUserGuildsParams struct { Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit int `urlparam:"limit,omitempty"` }
GetCurrentUserGuildsParams JSON params for func GetCurrentUserGuilds
func (*GetCurrentUserGuildsParams) GetQueryString ¶ added in v0.6.0
func (params *GetCurrentUserGuildsParams) GetQueryString() string
GetQueryString ...
type GetMessagesParams ¶ added in v0.9.3
type GetMessagesParams struct { Around Snowflake `urlparam:"around,omitempty"` Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit int `urlparam:"limit,omitempty"` }
GetChannelMessagesParams https://discordapp.com/developers/docs/resources/channel#get-channel-messages-query-string-params TODO: ensure limits
func (*GetMessagesParams) GetQueryString ¶ added in v0.9.3
func (params *GetMessagesParams) GetQueryString() string
GetQueryString .
type GetReactionURLParams ¶ added in v0.6.0
type GetReactionURLParams struct { Before Snowflake `urlparam:"before,omitempty"` // get users before this user Snowflake After Snowflake `urlparam:"after,omitempty"` // get users after this user Snowflake Limit int `urlparam:"limit,omitempty"` // max number of users to return (1-100) }
GetReactionURLParams https://discordapp.com/developers/docs/resources/channel#get-reactions-query-string-params
func (*GetReactionURLParams) GetQueryString ¶ added in v0.6.0
func (params *GetReactionURLParams) GetQueryString() string
GetQueryString .
type GroupDMAddRecipientParams ¶ added in v0.6.0
type GroupDMAddRecipientParams struct { AccessToken string `json:"access_token"` // access token of a user that has granted your app the gdm.join scope Nickname string `json:"nick"` // nickname of the user being added }
GroupDMAddRecipientParams JSON params for GroupDMAddRecipient
type Guild ¶ added in v0.6.0
type Guild struct { Lockable `json:"-"` ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` // |? Name string `json:"name"` Icon *string `json:"icon"` // |?, icon hash Splash *string `json:"splash"` // |?, image hash Owner bool `json:"owner,omitempty"` // ?| OwnerID Snowflake `json:"owner_id"` Permissions uint64 `json:"permissions,omitempty"` // ?|, permission flags for connected user `/users/@me/guilds` Region string `json:"region"` AfkChannelID Snowflake `json:"afk_channel_id"` // |? AfkTimeout uint `json:"afk_timeout"` EmbedEnabled bool `json:"embed_enabled,omit_empty"` EmbedChannelID Snowflake `json:"embed_channel_id,omit_empty"` VerificationLevel VerificationLvl `json:"verification_level"` DefaultMessageNotifications DefaultMessageNotificationLvl `json:"default_message_notifications"` ExplicitContentFilter ExplicitContentFilterLvl `json:"explicit_content_filter"` Roles []*Role `json:"roles"` Emojis []*Emoji `json:"emojis"` Features []string `json:"features"` MFALevel MFALvl `json:"mfa_level"` WidgetEnabled bool `json:"widget_enabled,omit_empty"` // | WidgetChannelID Snowflake `json:"widget_channel_id,omit_empty"` // |? SystemChannelID Snowflake `json:"system_channel_id,omitempty"` // |? // JoinedAt must be a pointer, as we can't hide non-nil structs JoinedAt *Timestamp `json:"joined_at,omitempty"` // ?*| Large bool `json:"large,omitempty"` // ?*| MemberCount uint `json:"member_count,omitempty"` // ?*| VoiceStates []*VoiceState `json:"voice_states,omitempty"` // ?*| Members []*Member `json:"members,omitempty"` // ?*| Channels []*Channel `json:"channels,omitempty"` // ?*| Presences []*UserPresence `json:"presences,omitempty"` // ?*| }
Guild Guilds in Discord represent an isolated collection of users and channels,
and are often referred to as "servers" in the UI.
https://discordapp.com/developers/docs/resources/guild#guild-object Fields with `*` are only sent within the GUILD_CREATE event reviewed: 2018-08-25
func CreateGuild ¶ added in v0.6.0
func CreateGuild(client httd.Poster, params *CreateGuildParams) (ret *Guild, err error)
CreateGuild [REST] Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event.
Method POST Endpoint /guilds Rate limiter /guilds Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild Reviewed 2018-08-16 Comment This endpoint. can be used only by bots in less than 10 guilds. Creating channel categories from this endpoint. is not supported.
func GetCurrentUserGuilds ¶ added in v0.6.0
func GetCurrentUserGuilds(client httd.Getter, params *GetCurrentUserGuildsParams) (ret []*Guild, err error)
GetCurrentUserGuilds [REST] Returns a list of partial guild objects the current user is a member of. Requires the guilds OAuth2 scope.
Method GET Endpoint /users/@me/guilds Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-current-user-guilds Reviewed 2018-06-10 Comment This endpoint. returns 100 guilds by default, which is the maximum number of guilds a non-bot user can join. Therefore, pagination is not needed for integrations that need to get a list of users' guilds.
func GetGuild ¶ added in v0.6.0
GetGuild [REST] Returns the guild object for the given id.
Method GET Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild Reviewed 2018-08-17 Comment -
func ModifyGuild ¶ added in v0.6.0
func ModifyGuild(client httd.Patcher, id Snowflake, params *ModifyGuildParams) (ret *Guild, err error)
ModifyGuild [REST] Modify a guild's settings. Requires the 'MANAGE_GUILD' permission. Returns the updated guild object on success. Fires a Guild Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional
func ModifyGuildChannelPositions ¶ added in v0.6.0
func ModifyGuildChannelPositions(client httd.Patcher, id Snowflake, params []ModifyGuildChannelPositionsParams) (ret *Guild, err error)
ModifyGuildChannelPositions [REST] Modify the positions of a set of channel objects for the guild. Requires 'MANAGE_CHANNELS' permission. Returns a 204 empty response on success. Fires multiple Channel Update Gateway events.
Method PATCH Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-channel-positions Reviewed 2018-08-17 Comment Only channels to be modified are required, with the minimum being a swap between at least two channels.
func NewGuildFromJSON ¶ added in v0.6.0
NewGuildFromJSON ...
func NewGuildFromUnavailable ¶ added in v0.6.0
func NewGuildFromUnavailable(gu *GuildUnavailable) *Guild
NewGuildFromUnavailable converts a unavailable guild object into a normal Guild object
func NewPartialGuild ¶ added in v0.6.0
NewPartialGuild ...
func (*Guild) AddChannel ¶ added in v0.6.0
AddChannel adds a channel to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMember ¶ added in v0.6.0
AddMember adds a member to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMembers ¶ added in v0.7.0
AddMembers adds multiple members to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddRole ¶ added in v0.6.0
AddRole adds a role to the Guild object. Note that this does not interact with Discord.
func (*Guild) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*Guild) DeepCopy ¶ added in v0.6.0
func (g *Guild) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Guild) DeleteChannel ¶ added in v0.6.0
DeleteChannel removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteChannelByID ¶ added in v0.6.0
DeleteChannelByID removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteRoleByID ¶ added in v0.6.0
DeleteRoleByID remove a role from the guild struct
func (*Guild) GetMemberWithHighestSnowflake ¶ added in v0.7.0
GetMemberWithHighestSnowflake finds the member with the highest snowflake value.
func (*Guild) LoadAllMembers ¶ added in v0.7.0
LoadAllMembers fetches all the members for this guild from the Discord REST API
func (*Guild) MarshalJSON ¶ added in v0.6.0
MarshalJSON see interface json.Marshaler TODO: fix copying of mutex lock
func (*Guild) MembersByName ¶ added in v0.7.0
MembersByName retrieve a slice of members with same username or nickname
type GuildBanAdd ¶ added in v0.6.0
type GuildBanAdd struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildBanAdd user was banned from a guild
type GuildBanAddHandler ¶ added in v0.9.0
type GuildBanAddHandler = func(session Session, h *GuildBanAdd)
GuildBanAddHandler is triggered in GuildBanAdd events
type GuildBanRemove ¶ added in v0.6.0
type GuildBanRemove struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildBanRemove user was unbanned from a guild
type GuildBanRemoveHandler ¶ added in v0.9.0
type GuildBanRemoveHandler = func(session Session, h *GuildBanRemove)
GuildBanRemoveHandler is triggered in GuildBanRemove events
type GuildCreate ¶ added in v0.6.0
type GuildCreate struct { Guild *Guild `json:"guild"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildCreate This event can be sent in three different scenarios:
- When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the Ready event.
- When a Guild becomes available again to the client.
- When the current user joins a new Guild.
func (*GuildCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildCreateHandler ¶ added in v0.9.0
type GuildCreateHandler = func(session Session, h *GuildCreate)
GuildCreateHandler is triggered in GuildCreate events
type GuildDelete ¶ added in v0.6.0
GuildDelete guild became unavailable, or user left/was removed from a guild
func (*GuildDelete) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
func (*GuildDelete) UserWasRemoved ¶ added in v0.8.0
func (obj *GuildDelete) UserWasRemoved() bool
UserWasRemoved ... TODO
type GuildDeleteHandler ¶ added in v0.9.0
type GuildDeleteHandler = func(session Session, h *GuildDelete)
GuildDeleteHandler is triggered in GuildDelete events
type GuildEmbed ¶ added in v0.6.0
type GuildEmbed struct { Lockable `json:"-"` Enabled bool `json:"enabled"` ChannelID Snowflake `json:"channel_id"` }
GuildEmbed https://discordapp.com/developers/docs/resources/guild#guild-embed-object
func GetGuildEmbed ¶ added in v0.6.0
func GetGuildEmbed(client httd.Getter, guildID Snowflake) (ret *GuildEmbed, err error)
GetGuildEmbed [REST] Returns the guild embed object. Requires the 'MANAGE_GUILD' permission.
Method GET Endpoint /guilds/{guild.id}/embed Rate limiter /guilds/{guild.id}/embed Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-embed Reviewed 2018-08-18 Comment -
func ModifyGuildEmbed ¶ added in v0.6.0
func ModifyGuildEmbed(client httd.Patcher, guildID Snowflake, params *GuildEmbed) (ret *GuildEmbed, err error)
ModifyGuildEmbed [REST] Modify a guild embed object for the guild. All attributes may be passed in with JSON and modified. Requires the 'MANAGE_GUILD' permission. Returns the updated guild embed object.
Method PATCH Endpoint /guilds/{guild.id}/embed Rate limiter /guilds/{guild.id}/embed Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-embed Reviewed 2018-08-18 Comment -
func (*GuildEmbed) CopyOverTo ¶ added in v0.7.0
func (e *GuildEmbed) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*GuildEmbed) DeepCopy ¶ added in v0.7.0
func (e *GuildEmbed) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type GuildEmojisUpdate ¶ added in v0.6.0
type GuildEmojisUpdate struct { GuildID Snowflake `json:"guild_id"` Emojis []*Emoji `json:"emojis"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildEmojisUpdate guild emojis were updated
type GuildEmojisUpdateHandler ¶ added in v0.9.0
type GuildEmojisUpdateHandler = func(session Session, h *GuildEmojisUpdate)
GuildEmojisUpdateHandler is triggered in GuildEmojisUpdate events
type GuildIntegrationsUpdate ¶ added in v0.6.0
type GuildIntegrationsUpdate struct { GuildID Snowflake `json:"guild_id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildIntegrationsUpdate guild integration was updated
type GuildIntegrationsUpdateHandler ¶ added in v0.9.0
type GuildIntegrationsUpdateHandler = func(session Session, h *GuildIntegrationsUpdate)
GuildIntegrationsUpdateHandler is triggered in GuildIntegrationsUpdate events
type GuildMemberAdd ¶ added in v0.6.0
type GuildMemberAdd struct { Member *Member `json:"member"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildMemberAdd new user joined a guild
func (*GuildMemberAdd) UnmarshalJSON ¶ added in v0.9.0
func (obj *GuildMemberAdd) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildMemberAddHandler ¶ added in v0.9.0
type GuildMemberAddHandler = func(session Session, h *GuildMemberAdd)
GuildMemberAddHandler is triggered in GuildMemberAdd events
type GuildMemberRemove ¶ added in v0.6.0
type GuildMemberRemove struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildMemberRemove user was removed from a guild
type GuildMemberRemoveHandler ¶ added in v0.9.0
type GuildMemberRemoveHandler = func(session Session, h *GuildMemberRemove)
GuildMemberRemoveHandler is triggered in GuildMemberRemove events
type GuildMemberUpdate ¶ added in v0.6.0
type GuildMemberUpdate struct { GuildID Snowflake `json:"guild_id"` Roles []Snowflake `json:"roles"` User *User `json:"user"` Nick string `json:"nick"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildMemberUpdate guild member was updated
type GuildMemberUpdateHandler ¶ added in v0.9.0
type GuildMemberUpdateHandler = func(session Session, h *GuildMemberUpdate)
GuildMemberUpdateHandler is triggered in GuildMemberUpdate events
type GuildMembersChunk ¶ added in v0.6.0
type GuildMembersChunk struct { GuildID Snowflake `json:"guild_id"` Members []*Member `json:"members"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildMembersChunk response to Request Guild Members
type GuildMembersChunkHandler ¶ added in v0.9.0
type GuildMembersChunkHandler = func(session Session, h *GuildMembersChunk)
GuildMembersChunkHandler is triggered in GuildMembersChunk events
type GuildPruneCount ¶ added in v0.6.0
type GuildPruneCount struct {
Pruned int `json:"pruned"`
}
GuildPruneCount ...
func BeginGuildPrune ¶ added in v0.6.0
func BeginGuildPrune(client httd.Poster, id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)
BeginGuildPrune [REST] Begin a 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. Fires multiple Guild Member Remove Gateway events.
Method POST Endpoint /guilds/{guild.id}/prune Rate limiter /guilds/{guild.id}/prune Discord documentation https://discordapp.com/developers/docs/resources/guild#begin-guild-prune Reviewed 2018-08-18 Comment -
func GetGuildPruneCount ¶ added in v0.6.0
func GetGuildPruneCount(client httd.Getter, id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)
GetGuildPruneCount [REST] Returns an object with one 'pruned' key indicating the number of members that would be removed in a prune operation. Requires the 'KICK_MEMBERS' permission.
Method GET Endpoint /guilds/{guild.id}/prune Rate limiter /guilds/{guild.id}/prune Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-prune-count Reviewed 2018-08-18 Comment -
type GuildPruneParams ¶ added in v0.6.0
type GuildPruneParams struct {
Days int `urlparam:"days"` // number of days to count prune for (1 or more)
}
GuildPruneParams ... https://discordapp.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params
func (*GuildPruneParams) GetQueryString ¶ added in v0.6.0
func (params *GuildPruneParams) GetQueryString() string
GetQueryString ...
type GuildRESTer ¶ added in v0.8.0
type GuildRESTer interface { CreateGuild(params *CreateGuildParams) (ret *Guild, err error) GetGuild(id Snowflake) (ret *Guild, err error) ModifyGuild(id Snowflake, params *ModifyGuildParams) (ret *Guild, err error) DeleteGuild(id Snowflake) (err error) GetGuildChannels(id Snowflake) (ret []*Channel, err error) CreateGuildChannel(id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error) ModifyGuildChannelPositions(id Snowflake, params []ModifyGuildChannelPositionsParams) (ret *Guild, err error) GetGuildMember(guildID, userID Snowflake) (ret *Member, err error) GetGuildMembers(guildID, after Snowflake, limit int) (ret []*Member, err error) AddGuildMember(guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error) ModifyGuildMember(guildID, userID Snowflake, params *ModifyGuildMemberParams) (err error) ModifyCurrentUserNick(id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error) AddGuildMemberRole(guildID, userID, roleID Snowflake) (err error) RemoveGuildMemberRole(guildID, userID, roleID Snowflake) (err error) RemoveGuildMember(guildID, userID Snowflake) (err error) GetGuildBans(id Snowflake) (ret []*Ban, err error) GetGuildBan(guildID, userID Snowflake) (ret *Ban, err error) CreateGuildBan(guildID, userID Snowflake, params *CreateGuildBanParams) (err error) RemoveGuildBan(guildID, userID Snowflake) (err error) GetGuildRoles(guildID Snowflake) (ret []*Role, err error) CreateGuildRole(id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error) ModifyGuildRolePositions(guildID Snowflake, params []ModifyGuildRolePositionsParams) (ret []*Role, err error) ModifyGuildRole(guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret *Role, err error) DeleteGuildRole(guildID, roleID Snowflake) (err error) GetGuildPruneCount(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error) BeginGuildPrune(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error) GetGuildVoiceRegions(id Snowflake) (ret []*VoiceRegion, err error) GetGuildInvites(id Snowflake) (ret []*Invite, err error) GetGuildIntegrations(id Snowflake) (ret []*Integration, err error) CreateGuildIntegration(guildID Snowflake, params *CreateGuildIntegrationParams) (err error) ModifyGuildIntegration(guildID, integrationID Snowflake, params *ModifyGuildIntegrationParams) (err error) DeleteGuildIntegration(guildID, integrationID Snowflake) (err error) SyncGuildIntegration(guildID, integrationID Snowflake) (err error) GetGuildEmbed(guildID Snowflake) (ret *GuildEmbed, err error) ModifyGuildEmbed(guildID Snowflake, params *GuildEmbed) (ret *GuildEmbed, err error) GetGuildVanityURL(guildID Snowflake) (ret *PartialInvite, err error) }
GuildRESTer REST interface for all guild endpoints
type GuildRoleCreate ¶ added in v0.6.0
type GuildRoleCreate struct { GuildID Snowflake `json:"guild_id"` Role *Role `json:"role"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildRoleCreate guild role was created
type GuildRoleCreateHandler ¶ added in v0.9.0
type GuildRoleCreateHandler = func(session Session, h *GuildRoleCreate)
GuildRoleCreateHandler is triggered in GuildRoleCreate events
type GuildRoleDelete ¶ added in v0.6.0
type GuildRoleDelete struct { GuildID Snowflake `json:"guild_id"` RoleID Snowflake `json:"role_id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildRoleDelete a guild role was deleted
type GuildRoleDeleteHandler ¶ added in v0.9.0
type GuildRoleDeleteHandler = func(session Session, h *GuildRoleDelete)
GuildRoleDeleteHandler is triggered in GuildRoleDelete events
type GuildRoleUpdate ¶ added in v0.6.0
type GuildRoleUpdate struct { GuildID Snowflake `json:"guild_id"` Role *Role `json:"role"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildRoleUpdate guild role was updated
type GuildRoleUpdateHandler ¶ added in v0.9.0
type GuildRoleUpdateHandler = func(session Session, h *GuildRoleUpdate)
GuildRoleUpdateHandler is triggered in GuildRoleUpdate events
type GuildUnavailable ¶ added in v0.6.0
type GuildUnavailable struct {}
GuildUnavailable is a partial Guild object.
func NewGuildUnavailable ¶ added in v0.6.0
func NewGuildUnavailable(ID Snowflake) *GuildUnavailable
NewGuildUnavailable ...
type GuildUpdate ¶ added in v0.6.0
type GuildUpdate struct { Guild *Guild `json:"guild"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildUpdate guild was updated
func (*GuildUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildUpdateHandler ¶ added in v0.9.0
type GuildUpdateHandler = func(session Session, h *GuildUpdate)
GuildUpdateHandler is triggered in GuildUpdate events
type HandlerCtrl ¶ added in v0.9.2
type HandlerCtrl interface { OnInsert(Session) error OnRemove(Session) error // IsDead does not need to be locked as the demultiplexer access it synchronously. IsDead() bool // Update For every time Update is called, it's internal trackers must be updated. // you should assume that .Update() means the handler was used. Update() }
HandlerCtrl used when inserting a handler to dictate whether or not the handler(s) should still be kept in the handlers list..
type Integration ¶ added in v0.6.0
type Integration struct { Lockable `json:"-"` ID Snowflake `json:"id"` Name string `json:"name"` Type string `json:"type"` Enabled bool `json:"enabled"` Syncing bool `json:"syncing"` RoleID Snowflake `json:"role_id"` ExpireBehavior int `json:"expire_behavior"` ExpireGracePeriod int `json:"expire_grace_period"` User *User `json:"user"` Account *IntegrationAccount `json:"account"` }
Integration https://discordapp.com/developers/docs/resources/guild#integration-object
func GetGuildIntegrations ¶ added in v0.6.0
func GetGuildIntegrations(client httd.Getter, id Snowflake) (ret []*Integration, err error)
GetGuildIntegrations [REST] Returns a list of integration objects for the guild. Requires the 'MANAGE_GUILD' permission.
Method GET Endpoint /guilds/{guild.id}/integrations Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-integrations Reviewed 2018-08-18 Comment -
func (*Integration) CopyOverTo ¶ added in v0.7.0
func (i *Integration) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*Integration) DeepCopy ¶ added in v0.7.0
func (i *Integration) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type IntegrationAccount ¶ added in v0.6.0
type IntegrationAccount struct { Lockable `json:"-"` ID string `json:"id"` // id of the account Name string `json:"name"` // name of the account }
IntegrationAccount https://discordapp.com/developers/docs/resources/guild#integration-account-object
func (*IntegrationAccount) CopyOverTo ¶ added in v0.7.0
func (i *IntegrationAccount) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*IntegrationAccount) DeepCopy ¶ added in v0.7.0
func (i *IntegrationAccount) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type Invite ¶ added in v0.6.0
type Invite struct { Lockable `json:"-"` // Code the invite code (unique Snowflake) Code string `json:"code"` // Guild the guild this invite is for Guild *PartialGuild `json:"guild"` // Channel the channel this invite is for Channel *PartialChannel `json:"channel"` // ApproximatePresenceCount approximate count of online members ApproximatePresenceCount int `json:"approximate_presence_count,omitempty"` // ApproximatePresenceCount approximate count of total members ApproximateMemberCount int `json:"approximate_member_count,omitempty"` }
Invite Represents a code that when used, adds a user to a guild. https://discordapp.com/developers/docs/resources/invite#invite-object Reviewed: 2018-06-10
func CreateChannelInvites ¶ added in v0.6.0
func CreateChannelInvites(client httd.Poster, id Snowflake, params *CreateChannelInvitesParams) (ret *Invite, err error)
CreateChannelInvites [REST] Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission. All JSON parameters for this route are optional, however the request body is not. If you are not sending any fields, you still have to send an empty JSON object ({}). Returns an invite object.
Method POST Endpoint /channels/{channel.id}/invites Rate limiter [MAJOR] /channels/{channel.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/channel#create-channel-invite Reviewed 2018-06-07 Comment -
func GetChannelInvites ¶ added in v0.6.0
GetChannelInvites [REST] Returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels. Requires the 'MANAGE_CHANNELS' permission.
Method GET Endpoint /channels/{channel.id}/invites Rate limiter [MAJOR] /channels/{channel.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-invites Reviewed 2018-06-07 Comment -
func GetGuildInvites ¶ added in v0.6.0
GetGuildInvites [REST] Returns a list of invite objects (with invite metadata) for the guild. Requires the 'MANAGE_GUILD' permission.
Method GET Endpoint /guilds/{guild.id}/invites Rate limiter /guilds/{guild.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-invites Reviewed 2018-08-18 Comment -
func (*Invite) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
type InviteMetadata ¶ added in v0.6.0
type InviteMetadata struct { Lockable `json:"-"` // Inviter user who created the invite Inviter *User `json:"inviter"` // Uses number of times this invite has been used Uses int `json:"uses"` // MaxUses max number of times this invite can be used MaxUses int `json:"max_uses"` // MaxAge duration (in seconds) after which the invite expires MaxAge int `json:"max_age"` // Temporary whether this invite only grants temporary membership Temporary bool `json:"temporary"` // CreatedAt when this invite was created CreatedAt Timestamp `json:"created_at"` // Revoked whether this invite is revoked Revoked bool `json:"revoked"` }
InviteMetadata Object https://discordapp.com/developers/docs/resources/invite#invite-metadata-object Reviewed: 2018-06-10
func (*InviteMetadata) CopyOverTo ¶ added in v0.7.0
func (i *InviteMetadata) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*InviteMetadata) DeepCopy ¶ added in v0.7.0
func (i *InviteMetadata) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type InviteRESTer ¶ added in v0.8.0
type InviteRESTer interface { GetInvite(inviteCode string) *getInviteBuilder DeleteInvite(inviteCode string) *deleteInviteBuilder }
InviteRESTer REST interface for all invite endpoints
type Link ¶ added in v0.9.0
Link is used to establish basic commands to create and destroy a link. See client.Disconnect() and client.Connect() for linking to the Discord servers
type MFALvl ¶ added in v0.6.0
type MFALvl uint
MFALvl ... https://discordapp.com/developers/docs/resources/guild#guild-object-mfa-level
type Member ¶ added in v0.6.0
type Member struct { Lockable `json:"-"` GuildID Snowflake `json:"guild_id,omitempty"` User *User `json:"user"` Nick string `json:"nick,omitempty"` // ?| Roles []Snowflake `json:"roles"` JoinedAt Timestamp `json:"joined_at,omitempty"` // voice Deaf bool `json:"deaf"` Mute bool `json:"mute"` // contains filtered or unexported fields }
Member https://discordapp.com/developers/docs/resources/guild#guild-member-object
func AddGuildMember ¶ added in v0.6.0
func AddGuildMember(client httd.Puter, guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error)
AddGuildMember [REST] Adds a user to the guild, provided you have a valid oauth2 access token for the user with the guilds.join scope. Returns a 201 Created with the guild member as the body, or 204 No Content if the user is already a member of the guild. Fires a Guild Member Add Gateway event. Requires the bot to have the CREATE_INSTANT_INVITE permission.
Method PUT Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#add-guild-member Reviewed 2018-08-18 Comment All parameters to this endpoint. except for access_token are optional.
func GetGuildMember ¶ added in v0.6.0
GetGuildMember [REST] Returns a guild member object for the specified user.
Method GET Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-member Reviewed 2018-08-17 Comment -
func GetGuildMembers ¶ added in v0.6.0
func GetGuildMembers(client httd.Getter, guildID, after Snowflake, limit int) (ret []*Member, err error)
GetGuildMembers [REST] Returns a list of guild member objects that are members of the guild. The `after` param refers to the highest snowflake.
Method GET Endpoint /guilds/{guild.id}/members Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-members Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional Comment#2 "List Guild Members" Comment#3 https://discordapp.com/developers/docs/resources/guild#list-guild-members-query-string-params
func (*Member) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*Member) DeepCopy ¶ added in v0.7.0
func (m *Member) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Member) GetUser ¶ added in v0.9.0
GetUser tries to ensure that you get a user object and not a nil. The user can be nil if the guild was fetched from the cache.
type Message ¶ added in v0.6.0
type Message struct { Lockable `json:"-"` ID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` Author *User `json:"author"` Content string `json:"content"` Timestamp time.Time `json:"timestamp"` EditedTimestamp time.Time `json:"edited_timestamp"` // ? Tts bool `json:"tts"` MentionEveryone bool `json:"mention_everyone"` Mentions []*User `json:"mentions"` MentionRoles []Snowflake `json:"mention_roles"` Attachments []*Attachment `json:"attachments"` Embeds []*ChannelEmbed `json:"embeds"` Reactions []*Reaction `json:"reactions"` // ? Nonce Snowflake `json:"nonce,omitempty"` // ?, used for validating a message was sent Pinned bool `json:"pinned"` WebhookID Snowflake `json:"webhook_id"` // ? Type uint `json:"type"` Activity MessageActivity `json:"activity"` Application MessageApplication `json:"application"` // SpoilerTagContent is only true if the entire message text is tagged as a spoiler (aka completely wrapped in ||) SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` HasSpoilerImage bool `json:"-"` }
Message https://discordapp.com/developers/docs/resources/channel#message-object-message-structure
func CreateChannelMessage
deprecated
added in
v0.6.0
func CreateMessage ¶ added in v0.9.3
func CreateMessage(client httd.Poster, channelID Snowflake, params *CreateMessageParams) (ret *Message, err error)
CreateMessage [REST] Post a message to a guild text or DM channel. If operating on a guild channel, this endpoint requires the 'SEND_MESSAGES' permission to be present on the current user. If the tts field is set to true, the SEND_TTS_MESSAGES permission is required for the message to be spoken. Returns a message object. Fires a Message Create Gateway event. See message formatting for more information on how to properly format messages. The maximum request size when sending a message is 8MB.
Method POST Endpoint /channels/{channel.id}/messages Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#create-message Reviewed 2018-06-10 Comment Before using this endpoint, you must connect to and identify with a gateway at least once.
func EditMessage ¶ added in v0.6.0
func EditMessage(client httd.Patcher, chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error)
EditMessage [REST] Edit a previously sent message. You can only edit messages that have been sent by the current user. Returns a message object. Fires a Message Update Gateway event.
Method PATCH Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#edit-message Reviewed 2018-06-10 Comment All parameters to this endpoint are optional.
func GetChannelMessages
deprecated
added in
v0.6.0
func GetMessage ¶ added in v0.9.3
GetMessage [REST] Returns a specific message in the channel. If operating on a guild channel, this endpoints requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user. Returns a message object on success.
Method GET Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-message Reviewed 2018-06-10 Comment -
func GetMessages ¶ added in v0.9.3
func GetMessages(client httd.Getter, channelID Snowflake, params URLParameters) (ret []*Message, err error)
GetMessages [REST] Returns the messages for a channel. If operating on a guild channel, this endpoint requires the 'VIEW_CHANNEL' permission to be present on the current user. If the current user is missing the 'READ_MESSAGE_HISTORY' permission in the channel then this will return no messages (since they cannot read the message history). Returns an array of message objects on success.
Method GET Endpoint /channels/{channel.id}/messages Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-messages Reviewed 2018-06-10 Comment The before, after, and around keys are mutually exclusive, only one may be passed at a time. see ReqGetChannelMessagesParams.
func GetPinnedMessages ¶ added in v0.6.0
GetPinnedMessages [REST] Returns all pinned messages in the channel as an array of message objects.
Method GET Endpoint /channels/{channel.id}/pins Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#get-pinned-messages Reviewed 2018-06-10 Comment -
func (*Message) CopyOverTo ¶ added in v0.8.0
CopyOverTo see interface at struct.go#Copier
func (*Message) DeepCopy ¶ added in v0.8.0
func (m *Message) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Message) Respond ¶ added in v0.6.0
func (m *Message) Respond(client MessageSender, message *Message) (msg *Message, err error)
Respond responds to a message using a Message object.
func (*Message) RespondString ¶ added in v0.6.0
func (m *Message) RespondString(client MessageSender, content string) (msg *Message, err error)
RespondString sends a reply to a message in the form of a string
type MessageActivity ¶ added in v0.6.0
MessageActivity https://discordapp.com/developers/docs/resources/channel#message-object-message-activity-structure
type MessageApplication ¶ added in v0.6.0
type MessageApplication struct { ID Snowflake `json:"id"` CoverImage string `json:"cover_image"` Description string `json:"description"` Icon string `json:"icon"` Name string `json:"name"` }
MessageApplication https://discordapp.com/developers/docs/resources/channel#message-object-message-application-structure
type MessageCreate ¶ added in v0.6.0
type MessageCreate struct { Message *Message Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageCreate message was created
func (*MessageCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *MessageCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MessageCreateHandler ¶ added in v0.9.0
type MessageCreateHandler = func(session Session, h *MessageCreate)
MessageCreateHandler is triggered in MessageCreate events
type MessageDelete ¶ added in v0.6.0
type MessageDelete struct { MessageID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id,omitempty"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageDelete message was deleted
type MessageDeleteBulk ¶ added in v0.6.0
type MessageDeleteBulk struct { MessageIDs []Snowflake `json:"ids"` ChannelID Snowflake `json:"channel_id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageDeleteBulk multiple messages were deleted at once
type MessageDeleteBulkHandler ¶ added in v0.9.0
type MessageDeleteBulkHandler = func(session Session, h *MessageDeleteBulk)
MessageDeleteBulkHandler is triggered in MessageDeleteBulk events
type MessageDeleteHandler ¶ added in v0.9.0
type MessageDeleteHandler = func(session Session, h *MessageDelete)
MessageDeleteHandler is triggered in MessageDelete events
type MessageReactionAdd ¶ added in v0.6.0
type MessageReactionAdd struct { UserID Snowflake `json:"user_id"` ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` // PartialEmoji id and name. id might be nil PartialEmoji *Emoji `json:"emoji"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageReactionAdd user reacted to a message
type MessageReactionAddHandler ¶ added in v0.9.0
type MessageReactionAddHandler = func(session Session, h *MessageReactionAdd)
MessageReactionAddHandler is triggered in MessageReactionAdd events
type MessageReactionRemove ¶ added in v0.6.0
type MessageReactionRemove struct { UserID Snowflake `json:"user_id"` ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` // PartialEmoji id and name. id might be nil PartialEmoji *Emoji `json:"emoji"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageReactionRemove user removed a reaction from a message
type MessageReactionRemoveAll ¶ added in v0.6.0
type MessageReactionRemoveAll struct { ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageReactionRemoveAll all reactions were explicitly removed from a message
type MessageReactionRemoveAllHandler ¶ added in v0.9.0
type MessageReactionRemoveAllHandler = func(session Session, h *MessageReactionRemoveAll)
MessageReactionRemoveAllHandler is triggered in MessageReactionRemoveAll events
type MessageReactionRemoveHandler ¶ added in v0.9.0
type MessageReactionRemoveHandler = func(session Session, h *MessageReactionRemove)
MessageReactionRemoveHandler is triggered in MessageReactionRemove events
type MessageSender ¶ added in v0.6.0
type MessageSender interface {
CreateChannelMessage(channelID Snowflake, params *CreateMessageParams) (ret *Message, err error)
}
MessageSender is an interface which only holds the method needed for creating a channel message
type MessageUpdate ¶ added in v0.6.0
type MessageUpdate struct { Message *Message Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageUpdate message was edited
func (*MessageUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *MessageUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MessageUpdateHandler ¶ added in v0.9.0
type MessageUpdateHandler = func(session Session, h *MessageUpdate)
MessageUpdateHandler is triggered in MessageUpdate events
type MessageUpdater ¶ added in v0.6.0
MessageUpdater is a interface which only holds the message update method
type Middleware ¶ added in v0.9.2
type Middleware = func(interface{}) interface{}
type ModifyChannelParams ¶ added in v0.6.0
type ModifyChannelParams struct {
// contains filtered or unexported fields
}
ModifyChannelParams https://discordapp.com/developers/docs/resources/channel#modify-channel-json-params
func NewModifyTextChannelParams ¶ added in v0.8.0
func NewModifyTextChannelParams() *ModifyChannelParams
NewModifyTextChannelParams create a ModifyChannelParams for a text channel. Prevents changing attributes that only exists for voice channels.
func NewModifyVoiceChannelParams ¶ added in v0.8.0
func NewModifyVoiceChannelParams() *ModifyChannelParams
NewModifyVoiceChannelParams create a ModifyChannelParams for a voice channel. Prevents changing attributes that only exists for text channels.
func (*ModifyChannelParams) AddPermissionOverwrite ¶ added in v0.8.0
func (m *ModifyChannelParams) AddPermissionOverwrite(permission PermissionOverwrite)
func (*ModifyChannelParams) AddPermissionOverwrites ¶ added in v0.8.0
func (m *ModifyChannelParams) AddPermissionOverwrites(permissions []PermissionOverwrite)
func (*ModifyChannelParams) MarshalJSON ¶ added in v0.8.0
func (m *ModifyChannelParams) MarshalJSON() ([]byte, error)
func (*ModifyChannelParams) RemoveParentID ¶ added in v0.8.0
func (m *ModifyChannelParams) RemoveParentID() error
func (*ModifyChannelParams) SetBitrate ¶ added in v0.8.0
func (m *ModifyChannelParams) SetBitrate(bitrate uint) error
func (*ModifyChannelParams) SetNSFW ¶ added in v0.8.0
func (m *ModifyChannelParams) SetNSFW(yes bool) error
func (*ModifyChannelParams) SetName ¶ added in v0.8.0
func (m *ModifyChannelParams) SetName(name string) error
func (*ModifyChannelParams) SetParentID ¶ added in v0.8.0
func (m *ModifyChannelParams) SetParentID(id Snowflake) error
func (*ModifyChannelParams) SetPermissionOverwrites ¶ added in v0.8.0
func (m *ModifyChannelParams) SetPermissionOverwrites(permissions []PermissionOverwrite)
func (*ModifyChannelParams) SetPosition ¶ added in v0.8.0
func (m *ModifyChannelParams) SetPosition(pos uint)
func (*ModifyChannelParams) SetRateLimitPerUser ¶ added in v0.8.0
func (m *ModifyChannelParams) SetRateLimitPerUser(seconds uint) error
func (*ModifyChannelParams) SetTopic ¶ added in v0.8.0
func (m *ModifyChannelParams) SetTopic(topic string) error
func (*ModifyChannelParams) SetUserLimit ¶ added in v0.8.0
func (m *ModifyChannelParams) SetUserLimit(limit uint) error
type ModifyCurrentUserNickParams ¶ added in v0.6.0
type ModifyCurrentUserNickParams struct {
Nick string `json:"nick"` // :CHANGE_NICKNAME
}
ModifyCurrentUserNickParams ... https://discordapp.com/developers/docs/resources/guild#modify-guild-member-json-params
type ModifyCurrentUserParams ¶ added in v0.6.0
type ModifyCurrentUserParams struct {
// contains filtered or unexported fields
}
ModifyCurrentUserParams JSON params for func ModifyCurrentUser
func (*ModifyCurrentUserParams) Empty ¶ added in v0.8.0
func (m *ModifyCurrentUserParams) Empty() bool
func (*ModifyCurrentUserParams) MarshalJSON ¶ added in v0.8.0
func (m *ModifyCurrentUserParams) MarshalJSON() ([]byte, error)
func (*ModifyCurrentUserParams) SetAvatar ¶ added in v0.8.0
func (m *ModifyCurrentUserParams) SetAvatar(avatar string)
SetAvatar updates the avatar image. Must be abase64 encoded string. provide a nil to reset the avatar.
func (*ModifyCurrentUserParams) SetUsername ¶ added in v0.8.0
func (m *ModifyCurrentUserParams) SetUsername(name string)
func (*ModifyCurrentUserParams) UseDefaultAvatar ¶ added in v0.8.0
func (m *ModifyCurrentUserParams) UseDefaultAvatar()
UseDefaultAvatar sets the avatar param to null, and let's Discord assign a default avatar image. Note that the avatar value will never hold content, as default avatars only works on null values.
Use this to reset an avatar image.
type ModifyGuildChannelPositionsParams ¶ added in v0.6.0
type ModifyGuildChannelPositionsParams struct { ID Snowflake `json:"id"` Position int `json:"position"` }
ModifyGuildChannelPositionsParams ... https://discordapp.com/developers/docs/resources/guild#modify-guild-channel-positions-json-params
type ModifyGuildEmojiParams ¶ added in v0.6.0
ModifyGuildEmojiParams JSON params for func ModifyGuildEmoji
type ModifyGuildIntegrationParams ¶ added in v0.6.0
type ModifyGuildIntegrationParams struct { ExpireBehavior int `json:"expire_behavior"` ExpireGracePeriod int `json:"expire_grace_period"` EnableEmoticons bool `json:"enable_emoticons"` }
ModifyGuildIntegrationParams ... https://discordapp.com/developers/docs/resources/guild#modify-guild-integration-json-params
type ModifyGuildMemberParams ¶ added in v0.6.0
type ModifyGuildMemberParams struct {
// contains filtered or unexported fields
}
ModifyGuildMemberParams ... https://discordapp.com/developers/docs/resources/guild#modify-guild-member-json-params
func (*ModifyGuildMemberParams) MarshalJSON ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) MarshalJSON() ([]byte, error)
func (*ModifyGuildMemberParams) RemoveNick ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) RemoveNick()
RemoveNick removes nickname for user. Requires permission MANAGE_NICKNAMES
func (*ModifyGuildMemberParams) SetChannelID ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) SetChannelID(id Snowflake) error
SetChannelID moves a member from one channel to another. Requires permission MOVE_MEMBERS
func (*ModifyGuildMemberParams) SetDeaf ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) SetDeaf(yes bool)
SetDeaf deafens a member. Requires permission DEAFEN_MEMBERS
func (*ModifyGuildMemberParams) SetMute ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) SetMute(yes bool)
SetMute mutes a member. Requires permission MUTE_MEMBERS
func (*ModifyGuildMemberParams) SetNick ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) SetNick(name string) error
SetNick set new nickname for user. Requires permission MANAGE_NICKNAMES
func (*ModifyGuildMemberParams) SetRoles ¶ added in v0.8.0
func (m *ModifyGuildMemberParams) SetRoles(roles []Snowflake)
SetRoles updates the member with new roles. Requires permissions MANAGE_ROLES
type ModifyGuildParams ¶ added in v0.6.0
type ModifyGuildParams struct { Name string `json:"name,omitempty"` Region string `json:"region,omitempty"` VerificationLvl int `json:"verification_level,omitempty"` DefaultMsgNotifications DefaultMessageNotificationLvl `json:"default_message_notifications,omitempty"` ExplicitContentFilter ExplicitContentFilterLvl `json:"explicit_content_filter,omitempty"` AFKChannelID Snowflake `json:"afk_channel_id,omitempty"` AFKTimeout int `json:"afk_timeout,omitempty"` Icon string `json:"icon,omitempty"` OwnerID Snowflake `json:"owner_id,omitempty"` Splash string `json:"splash,omitempty"` SystemChannelID Snowflake `json:"system_channel_id,omitempty"` }
ModifyGuildParams https://discordapp.com/developers/docs/resources/guild#modify-guild-json-params TODO: support nullable Icon, anything else?
type ModifyGuildRoleParams ¶ added in v0.6.0
type ModifyGuildRoleParams struct {
// contains filtered or unexported fields
}
ModifyGuildRoleParams JSON params for func ModifyGuildRole
func (*ModifyGuildRoleParams) MarshalJSON ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) MarshalJSON() ([]byte, error)
func (*ModifyGuildRoleParams) SetColor ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) SetColor(color uint)
func (*ModifyGuildRoleParams) SetHoist ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) SetHoist(hoist bool)
func (*ModifyGuildRoleParams) SetMentionable ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) SetMentionable(mentionable bool)
func (*ModifyGuildRoleParams) SetName ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) SetName(name string)
func (*ModifyGuildRoleParams) SetPermissions ¶ added in v0.9.0
func (p *ModifyGuildRoleParams) SetPermissions(permissions uint64)
type ModifyGuildRolePositionsParams ¶ added in v0.6.0
type ModifyGuildRolePositionsParams struct { ID Snowflake `json:"id"` Position uint `json:"position"` }
ModifyGuildRolePositionsParams ... https://discordapp.com/developers/docs/resources/guild#modify-guild-role-positions-json-params
type ModifyWebhookParams ¶ added in v0.8.0
type ModifyWebhookParams struct {
// contains filtered or unexported fields
}
ModifyWebhookParams https://discordapp.com/developers/docs/resources/webhook#modify-webhook-json-params Allows changing the name of the webhook, avatar and moving it to another channel. It also allows to resetting the avatar by providing a nil to SetAvatar.
params = &ModifyWebhookParams{} params.UseDefaultAvatar() // will reset any image data, if present
func NewModifyWebhookParams ¶ added in v0.8.0
func NewModifyWebhookParams() *ModifyWebhookParams
func (*ModifyWebhookParams) Empty ¶ added in v0.8.0
func (m *ModifyWebhookParams) Empty() bool
func (*ModifyWebhookParams) MarshalJSON ¶ added in v0.8.0
func (m *ModifyWebhookParams) MarshalJSON() ([]byte, error)
func (*ModifyWebhookParams) SetAvatar ¶ added in v0.8.0
func (m *ModifyWebhookParams) SetAvatar(avatar string)
SetAvatar updates the avatar image. Must be abase64 encoded string. provide a nil to reset the avatar.
func (*ModifyWebhookParams) SetChannelID ¶ added in v0.8.0
func (m *ModifyWebhookParams) SetChannelID(channelID Snowflake)
func (*ModifyWebhookParams) SetName ¶ added in v0.8.0
func (m *ModifyWebhookParams) SetName(name string)
func (*ModifyWebhookParams) UseDefaultAvatar ¶ added in v0.8.0
func (m *ModifyWebhookParams) UseDefaultAvatar()
UseDefaultAvatar sets the avatar param to null, and let's Discord assign a default avatar image. Note that the avatar value will never hold content, as default avatars only works on null values.
Use this to reset an avatar image.
type PartialChannel ¶ added in v0.6.0
type PartialChannel struct { Lockable `json:"-"` ID Snowflake `json:"id"` Name string `json:"name"` Type uint `json:"type"` }
PartialChannel ... example of partial channel // "channel": { // "id": "165176875973476352", // "name": "illuminati", // "type": 0 // }
type PartialInvite ¶ added in v0.6.0
type PartialInvite = Invite
PartialInvite ...
{ "code": "abc" }
func GetGuildVanityURL ¶ added in v0.6.0
func GetGuildVanityURL(client httd.Getter, guildID Snowflake) (ret *PartialInvite, err error)
GetGuildVanityURL [REST] Returns a partial invite object for guilds with that feature enabled. Requires the 'MANAGE_GUILD' permission.
Method GET Endpoint /guilds/{guild.id}/vanity-url Rate limiter /guilds/{guild.id}/vanity-url Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-vanity-url Reviewed 2018-08-18 Comment -
type PermissionOverwrite ¶ added in v0.6.0
type PermissionOverwrite struct { ID Snowflake `json:"id"` // role or user id Type string `json:"type"` // either `role` or `member` Allow int `json:"allow"` // permission bit set Deny int `json:"deny"` // permission bit set }
PermissionOverwrite https://discordapp.com/developers/docs/resources/channel#overwrite-object
type PremiumType ¶ added in v0.9.3
type PremiumType int
const ( // PremiumTypeNitroClassic includes app perks like animated emojis and avatars, but not games PremiumTypeNitroClassic PremiumType = 1 // PremiumTypeNitro includes app perks as well as the games subscription service PremiumTypeNitro PremiumType = 2 )
func (PremiumType) String ¶ added in v0.9.3
func (p PremiumType) String() (t string)
type Presence ¶ added in v0.9.3
type Presence = UpdateStatusCommand
type PresenceUpdate ¶ added in v0.6.0
type PresenceUpdate struct { User *User `json:"user"` RoleIDs []Snowflake `json:"roles"` Game *Activity `json:"game"` GuildID Snowflake `json:"guild_id"` // Status either "idle", "dnd", "online", or "offline" // TODO: constants somewhere.. Status string `json:"status"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
PresenceUpdate user's presence was updated in a guild
type PresenceUpdateHandler ¶ added in v0.9.0
type PresenceUpdateHandler = func(session Session, h *PresenceUpdate)
PresenceUpdateHandler is triggered in PresenceUpdate events
type PresencesReplace ¶ added in v0.7.0
type PresencesReplace struct { Presnces []*PresenceUpdate `json:"presences_replace"` // TODO: verify json tag Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
PresencesReplace holds the event content
type PresencesReplaceHandler ¶ added in v0.9.0
type PresencesReplaceHandler = func(session Session, h *PresencesReplace)
PresencesReplaceHandler is triggered in PresencesReplace events
type RESTBuilder ¶ added in v0.9.3
type RESTBuilder struct {
// contains filtered or unexported fields
}
func (*RESTBuilder) CancelOnRatelimit ¶ added in v0.9.3
func (b *RESTBuilder) CancelOnRatelimit() *RESTBuilder
func (*RESTBuilder) IgnoreCache ¶ added in v0.9.3
func (b *RESTBuilder) IgnoreCache() *RESTBuilder
type RESTer ¶ added in v0.8.0
type RESTer interface { AuditLogsRESTer ChannelRESTer EmojiRESTer GuildRESTer InviteRESTer UserRESTer VoiceRESTer WebhookRESTer }
RESTer holds all the sub REST interfaces
type Reaction ¶ added in v0.6.0
type Reaction struct { Lockable `json:"-"` Count uint `json:"count"` Me bool `json:"me"` Emoji *PartialEmoji `json:"Emoji"` }
Reaction ... https://discordapp.com/developers/docs/resources/channel#reaction-object
func (*Reaction) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
type Ready ¶ added in v0.6.0
type Ready struct { APIVersion int `json:"v"` User *User `json:"user"` Guilds []*GuildUnavailable `json:"guilds"` // not really needed, as it is handled on the socket layer. SessionID string `json:"session_id"` Trace []string `json:"_trace"` sync.RWMutex `json:"-"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
Ready contains the initial state information
type ReadyHandler ¶ added in v0.9.0
ReadyHandler is triggered in Ready events
type RequestGuildMembersCommand ¶ added in v0.8.0
type RequestGuildMembersCommand struct { // GuildID id of the guild(s) to get offline members for GuildID Snowflake `json:"guild_id"` // Query string that username starts with, or an empty string to return all members Query string `json:"query"` // Limit maximum number of members to send or 0 to request all members matched Limit uint `json:"limit"` }
RequestGuildMembersCommand payload for socket command REQUEST_GUILD_MEMBERS. See CommandRequestGuildMembers
type Resumed ¶ added in v0.6.0
type Resumed struct { Trace []string `json:"_trace"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
Resumed response to Resume
type ResumedHandler ¶ added in v0.9.0
ResumedHandler is triggered in Resumed events
type Role ¶ added in v0.6.0
type Role struct { Lockable `json:"-"` ID Snowflake `json:"id"` Name string `json:"name"` Color uint `json:"color"` Hoist bool `json:"hoist"` Position uint `json:"position"` Permissions uint64 `json:"permissions"` Managed bool `json:"managed"` Mentionable bool `json:"mentionable"` // contains filtered or unexported fields }
Role https://discordapp.com/developers/docs/topics/permissions#role-object
func CreateGuildRole ¶ added in v0.6.0
func CreateGuildRole(client httd.Poster, id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error)
CreateGuildRole [REST] Create a new role for the guild. Requires the 'MANAGE_ROLES' permission. Returns the new role object on success. Fires a Guild Role Create Gateway event.
Method POST Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-role Reviewed 2018-08-18 Comment All JSON params are optional.
func GetGuildRoles ¶ added in v0.6.0
GetGuildRoles [REST] Returns a list of role objects for the guild.
Method GET Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-roles Reviewed 2018-08-18 Comment -
func ModifyGuildRole ¶ added in v0.6.0
func ModifyGuildRole(client httd.Patcher, guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret *Role, err error)
ModifyGuildRole [REST] Modify a guild role. Requires the 'MANAGE_ROLES' permission. Returns the updated role on success. Fires a Guild Role Update Gateway event.
Method PATCH Endpoint /guilds/{guild.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-role Reviewed 2018-08-18 Comment -
func ModifyGuildRolePositions ¶ added in v0.6.0
func ModifyGuildRolePositions(client httd.Patcher, guildID Snowflake, params []ModifyGuildRolePositionsParams) (ret []*Role, err error)
ModifyGuildRolePositions [REST] Modify the positions of a set of role objects for the guild. Requires the 'MANAGE_ROLES' permission. Returns a list of all of the guild's role objects on success. Fires multiple Guild Role Update Gateway events.
Method PATCH Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-role-positions Reviewed 2018-08-18 Comment -
func (*Role) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*Role) DeepCopy ¶ added in v0.7.0
func (r *Role) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Role) Mention ¶ added in v0.6.0
Mention gives a formatted version of the role such that it can be parsed by Discord clients
func (*Role) SetGuildID ¶ added in v0.7.0
SetGuildID link role to a guild before running session.SaveToDiscord(*Role)
type Session ¶
type Session interface { // give information about the bot/connected user Myself() (*User, error) // Request For interacting with Discord. Sending messages, creating channels, guilds, etc. // To read object state such as guilds, State() should be used in stead. However some data // might not exist in the state. If so it should be requested. Note that this only holds http // CRUD operation and not the actual rest endpoints for discord (See Rest()). // Deprecated: will be unexported in next breaking release Req() httd.Requester // Cache reflects the latest changes received from Discord gateway. // Should be used instead of requesting objects. // Deprecated: will be unexported in next breaking release Cache() Cacher Logger() logger.Logger // RateLimiter the rate limiter for the discord REST API // Deprecated: will be unexported in next breaking release RateLimiter() httd.RateLimiter // Discord Gateway, web socket SocketHandler HeartbeatLatency() (duration time.Duration, err error) // Generic CRUD operations for Discord interaction DeleteFromDiscord(obj discordDeleter) error SaveToDiscord(original discordSaver, changes ...discordSaver) error AddPermission(permission int) (updatedPermissions int) GetPermissions() (permissions int) CreateBotURL() (u string, err error) // state/caching module // checks the cacheLink first, otherwise do a http request RESTer // Custom REST functions SendMsg(channelID Snowflake, message *Message) (msg *Message, err error) SendMsgString(channelID Snowflake, content string) (msg *Message, err error) UpdateMessage(message *Message) (msg *Message, err error) UpdateChannel(channel *Channel) (err error) // Status update functions UpdateStatus(s *UpdateStatusCommand) (err error) UpdateStatusString(s string) (err error) GetConnectedGuilds() []snowflake.ID // Voice handler, responsible for opening up new voice channel connections VoiceHandler }
Session Is the runtime interface for DisGord. It allows you to interact with a live session (using sockets or not). Note that this interface is used after you've configured DisGord, and therefore won't allow you to configure it further.
func NewSession ¶
NewSession create a client and return the Session interface Deprecated: Use NewClient instead
func NewSessionMustCompile ¶
NewSessionMustCompile same as NewClientMustCompile, but with the Session interface Deprecated: Use New(..) instead
type SessionMock ¶ added in v0.8.4
type SessionMock interface { Session }
func NewSessionMock ¶ added in v0.8.4
func NewSessionMock(conf *Config) (SessionMock, error)
NewSessionMock returns a session interface that triggers random events allows for fake rest requests. Ideal to test the behaviour of your new bot. Not implemented! TODO: what about a terminal interface for triggering specific events?
type SetChannelPermissionsParams ¶ added in v0.8.4
type SetChannelPermissionsParams = EditChannelPermissionsParams
SetChannelPermissionsParams is an alias for EditChannelPermissionsParams because Discord uses a single endpoint for both editing and adding permission overwrites.
type SimpleHandler ¶ added in v0.9.0
type SimpleHandler = func(session Session)
type SimplestHandler ¶ added in v0.9.0
type SimplestHandler = func()
these "simple" handler can be used, if you don't care about the actual event data
type Snowflake ¶ added in v0.6.0
type Snowflake = snowflake.Snowflake
Snowflake twitter snowflake identification for Discord
func GetSnowflake ¶ added in v0.6.0
GetSnowflake see snowflake.GetSnowflake
func NewSnowflake ¶ added in v0.6.0
NewSnowflake see snowflake.NewSnowflake
func ParseSnowflakeString ¶ added in v0.6.0
ParseSnowflakeString see snowflake.ParseSnowflakeString
type SocketCommand ¶ added in v0.8.0
type SocketCommand = string
SocketCommand represents the type used to emit commands to Discord over the socket connection
const CommandRequestGuildMembers SocketCommand = cmd.RequestGuildMembers
CommandRequestGuildMembers Used to request offline members for a guild or a list of guilds. When initially connecting, the gateway will only send offline members if a guild has less than the large_threshold members (value in the Gateway Identify). If a client wishes to receive additional members, they need to explicitly request them via this operation. The server will send Guild Members Chunk events in response with up to 1000 members per chunk until all members that match the request have been sent.
const CommandUpdateStatus SocketCommand = cmd.UpdateStatus
CommandUpdateStatus Sent by the client to indicate a presence or status update.
const CommandUpdateVoiceState SocketCommand = cmd.UpdateVoiceState
CommandUpdateVoiceState Sent when a client wants to join, move, or disconnect from a voice channel.
type SocketHandler ¶ added in v0.8.0
type SocketHandler interface { // Link Disconnect() error // event handlers // inputs are in the following order: middlewares, handlers, controller On(event string, inputs ...interface{}) error // Deprecated Once(event string, inputs ...interface{}) error Emitter // event channels EventChan(event string) (channel interface{}, err error) EventChannels() EventChannels // event register (which events to accept) // events which are not registered are discarded at socket level // to increase performance AcceptEvent(events ...string) }
SocketHandler all socket related
type Timestamp ¶ added in v0.6.0
Timestamp handles Discord timestamps
func (Timestamp) MarshalJSON ¶ added in v0.6.0
MarshalJSON see json.Marshaler error: https://stackoverflow.com/questions/28464711/go-strange-json-hyphen-unmarshall-error
func (Timestamp) String ¶ added in v0.6.0
String converts the timestamp into a discord formatted timestamp. time.RFC3331 does not suffice
func (Timestamp) Time ¶ added in v0.6.0
Time converts the DiscordTimestamp into a time.Time type.......
func (*Timestamp) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON see json.Unmarshaler
type TypingStart ¶ added in v0.6.0
type TypingStart struct { ChannelID Snowflake `json:"channel_id"` UserID Snowflake `json:"user_id"` TimestampUnix int `json:"timestamp"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
TypingStart user started typing in a channel
type TypingStartHandler ¶ added in v0.9.0
type TypingStartHandler = func(session Session, h *TypingStart)
TypingStartHandler is triggered in TypingStart events
type URLParameters ¶ added in v0.6.0
type URLParameters interface {
GetQueryString() string
}
URLParameters converts a struct of values to a valid URL query string
type UpdateStatusCommand ¶ added in v0.8.0
type UpdateStatusCommand struct { // Since unix time (in milliseconds) of when the client went idle, or null if the client is not idle Since *uint `json:"since"` // Game null, or the user's new activity Game *Activity `json:"game"` // Status the user's new status Status string `json:"status"` // AFK whether or not the client is afk AFK bool `json:"afk"` // contains filtered or unexported fields }
UpdateStatusCommand payload for socket command UPDATE_STATUS. see CommandUpdateStatus
type UpdateVoiceStateCommand ¶ added in v0.8.0
type UpdateVoiceStateCommand struct { // GuildID id of the guild GuildID Snowflake `json:"guild_id"` // ChannelID id of the voice channel client wants to join // (null if disconnecting) ChannelID *Snowflake `json:"channel_id"` // SelfMute is the client mute SelfMute bool `json:"self_mute"` // SelfDeaf is the client deafened SelfDeaf bool `json:"self_deaf"` }
UpdateVoiceStateCommand payload for socket command UPDATE_VOICE_STATE. see CommandUpdateVoiceState
type User ¶ added in v0.6.0
type User struct { Lockable `json:"-"` ID Snowflake `json:"id,omitempty"` Username string `json:"username,omitempty"` Discriminator Discriminator `json:"discriminator,omitempty"` Email string `json:"email,omitempty"` Avatar *string `json:"avatar"` // data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA //TODO: pointer? Token string `json:"token,omitempty"` Verified bool `json:"verified,omitempty"` MFAEnabled bool `json:"mfa_enabled,omitempty"` Bot bool `json:"bot,omitempty"` PremiumType PremiumType `json:"premium_type,omitempty"` // contains filtered or unexported fields }
User the Discord user object which is reused in most other data structures.
func GetReaction ¶ added in v0.6.0
func GetReaction(client httd.Getter, channelID, messageID Snowflake, emoji interface{}, params URLParameters) (ret []*User, err error)
GetReaction [REST] Get a list of users that reacted with this emoji. Returns an array of user objects on success.
Method GET Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji} Rate limiter [MAJOR] /channels/{channel.id}/messages/reactions Discord documentation https://discordapp.com/developers/docs/resources/channel#get-reactions Reviewed 2019-01-28 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom
func ModifyCurrentUser ¶ added in v0.6.0
func ModifyCurrentUser(client httd.Patcher, params *ModifyCurrentUserParams) (ret *User, err error)
ModifyCurrentUser [REST] Modify the requester's user account settings. Returns a user object on success.
Method PATCH Endpoint /users/@me Rate limiter /users Discord documentation https://discordapp.com/developers/docs/resources/user#modify-current-user Reviewed 2018-06-10 Comment -
func (*User) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
func (*User) DeepCopy ¶ added in v0.6.0
func (u *User) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier CopyOverTo see interface at struct.go#Copier
func (*User) MarshalJSON ¶ added in v0.6.0
MarshalJSON see interface json.Marshaler
func (*User) Mention ¶ added in v0.6.0
Mention returns the a string that Discord clients can format into a valid Discord mention
func (*User) MentionNickname ¶ added in v0.6.0
MentionNickname same as Mention, but shows nicknames TODO: move to member object(?)
func (*User) SendMsg ¶ added in v0.6.0
func (u *User) SendMsg(session Session, message *Message) (channel *Channel, msg *Message, err error)
SendMsg send a message to a user where you utilize a Message object instead of a string
func (*User) SendMsgString ¶ added in v0.6.0
func (u *User) SendMsgString(session Session, content string) (channel *Channel, msg *Message, err error)
SendMsgString send a message to given user where the message is in the form of a string.
func (*User) UnmarshalJSON ¶ added in v0.8.0
UnmarshalJSON see interface json.Unmarshaler
type UserConnection ¶ added in v0.6.0
type UserConnection struct { Lockable `json:"-"` ID string `json:"id"` // id of the connection account Name string `json:"name"` // the username of the connection account Type string `json:"type"` // the service of the connection (twitch, youtube) Revoked bool `json:"revoked"` // whether the connection is revoked Integrations []*IntegrationAccount `json:"integrations"` // an array of partial server integrations }
UserConnection ...
func GetUserConnections ¶ added in v0.6.0
func GetUserConnections(client httd.Getter) (ret []*UserConnection, err error)
GetUserConnections [REST] Returns a list of connection objects. Requires the connections OAuth2 scope.
Method GET Endpoint /users/@me/connections Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-user-connections Reviewed 2018-06-10 Comment -
func (*UserConnection) CopyOverTo ¶ added in v0.7.0
func (c *UserConnection) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*UserConnection) DeepCopy ¶ added in v0.7.0
func (c *UserConnection) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type UserPresence ¶ added in v0.6.0
type UserPresence struct { Lockable `json:"-"` User *User `json:"user"` Roles []Snowflake `json:"roles"` Game *Activity `json:"activity"` GuildID Snowflake `json:"guild_id"` Nick string `json:"nick"` Status string `json:"status"` }
UserPresence presence info for a guild member or friend/user in a DM
func NewUserPresence ¶ added in v0.6.0
func NewUserPresence() *UserPresence
NewUserPresence creates a new user presence instance
func (*UserPresence) CopyOverTo ¶ added in v0.7.0
func (p *UserPresence) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*UserPresence) DeepCopy ¶ added in v0.7.0
func (p *UserPresence) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*UserPresence) String ¶ added in v0.6.0
func (p *UserPresence) String() string
type UserRESTer ¶ added in v0.8.0
type UserRESTer interface { GetCurrentUser() (builder *getUserBuilder) GetUser(id Snowflake) (builder *getUserBuilder) ModifyCurrentUser(params *ModifyCurrentUserParams) (ret *User, err error) GetCurrentUserGuilds(params *GetCurrentUserGuildsParams) (ret []*Guild, err error) LeaveGuild(id Snowflake) (err error) GetUserDMs() (ret []*Channel, err error) CreateDM(recipientID Snowflake) (ret *Channel, err error) CreateGroupDM(params *CreateGroupDMParams) (ret *Channel, err error) GetUserConnections() (ret []*UserConnection, err error) }
UserRESTer REST interface for all user endpoints
type UserUpdate ¶ added in v0.6.0
type UserUpdate struct { User *User `json:"user"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
UserUpdate properties about a user changed
type UserUpdateHandler ¶ added in v0.9.0
type UserUpdateHandler = func(session Session, h *UserUpdate)
UserUpdateHandler is triggered in UserUpdate events
type VerificationLvl ¶ added in v0.6.0
type VerificationLvl uint
VerificationLvl ... https://discordapp.com/developers/docs/resources/guild#guild-object-verification-level
const ( VerificationLvlNone VerificationLvl = iota VerificationLvlLow VerificationLvlMedium VerificationLvlHigh VerificationLvlVeryHigh )
the different verification levels
func (*VerificationLvl) High ¶ added in v0.6.0
func (vl *VerificationLvl) High() bool
High (╯°□°)╯︵ ┻━┻ - must be a member of the server for longer than 10 minutes
func (*VerificationLvl) Low ¶ added in v0.6.0
func (vl *VerificationLvl) Low() bool
Low must have verified email on account
func (*VerificationLvl) Medium ¶ added in v0.6.0
func (vl *VerificationLvl) Medium() bool
Medium must be registered on Discord for longer than 5 minutes
func (*VerificationLvl) None ¶ added in v0.6.0
func (vl *VerificationLvl) None() bool
None unrestricted
func (*VerificationLvl) VeryHigh ¶ added in v0.6.0
func (vl *VerificationLvl) VeryHigh() bool
VeryHigh ┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻ - must have a verified phone number
type VoiceConnection ¶ added in v0.9.0
type VoiceConnection interface { // StartSpeaking should be sent before sending voice data. StartSpeaking() error // StopSpeaking should be sent after sending voice data. If there's a break in the sent data, you should not simply // stop sending data. Instead you have to send five frames of silence ([]byte{0xF8, 0xFF, 0xFE}) before stopping // to avoid unintended Opus interpolation with subsequent transmissions. StopSpeaking() error // SendOpusFrame sends a single frame of opus data to the UDP server. Frames are sent every 20ms with 960 samples (48kHz). SendOpusFrame(data []byte) // SendDCA reads from a Reader expecting a DCA encoded stream/file and sends them as frames. SendDCA(r io.Reader) error // Close closes the websocket and UDP connection. This VoiceConnection interface will no longer be usable and will // panic if any other functions are called beyond this point. It is the callers responsibility to ensure there are // no concurrent calls to any other methods of this interface after calling Close. Close() error }
VoiceConnection is the interface used to interact with active voice connections.
type VoiceHandler ¶ added in v0.9.0
type VoiceHandler interface {
VoiceConnect(guildID, channelID Snowflake) (ret VoiceConnection, err error)
}
VoiceHandler holds all the voice connection related methods
type VoiceRESTer ¶ added in v0.8.0
type VoiceRESTer interface {
GetVoiceRegions() *listVoiceRegionsBuilder
}
VoiceRESTer REST interface for all voice endpoints
type VoiceRegion ¶ added in v0.6.0
type VoiceRegion struct { Lockable `json:"-"` // Snowflake unique Snowflake for the region ID string `json:"id"` // Name name of the region Name string `json:"name"` // SampleHostname an example hostname for the region SampleHostname string `json:"sample_hostname"` // SamplePort an example port for the region SamplePort uint `json:"sample_port"` // VIP true if this is a vip-only server VIP bool `json:"vip"` // Optimal true for a single server that is closest to the current user's client Optimal bool `json:"optimal"` // Deprecated whether this is a deprecated voice region (avoid switching to these) Deprecated bool `json:"deprecated"` // Custom whether this is a custom voice region (used for events/etc) Custom bool `json:"custom"` }
VoiceRegion voice region structure https://discordapp.com/developers/docs/resources/voice#voice-region
func GetGuildVoiceRegions ¶ added in v0.6.0
func GetGuildVoiceRegions(client httd.Getter, id Snowflake) (ret []*VoiceRegion, err error)
GetGuildVoiceRegions [REST] Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled.
Method GET Endpoint /guilds/{guild.id}/regions Rate limiter /guilds/{guild.id}/regions Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-voice-regions Reviewed 2018-08-18 Comment -
func (*VoiceRegion) CopyOverTo ¶ added in v0.7.0
func (v *VoiceRegion) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*VoiceRegion) DeepCopy ¶ added in v0.7.0
func (v *VoiceRegion) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type VoiceServerUpdate ¶ added in v0.6.0
type VoiceServerUpdate struct { Token string `json:"token"` GuildID Snowflake `json:"guild_id"` Endpoint string `json:"endpoint"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
VoiceServerUpdate guild's voice server was updated. Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
type VoiceServerUpdateHandler ¶ added in v0.9.0
type VoiceServerUpdateHandler = func(session Session, h *VoiceServerUpdate)
VoiceServerUpdateHandler is triggered in VoiceServerUpdate events
type VoiceState ¶ added in v0.6.0
type VoiceState struct { Lockable `json:"-"` // GuildID the guild id this voice state is for GuildID Snowflake `json:"guild_id,omitempty"` // ? | // ChannelID the channel id this user is connected to ChannelID Snowflake `json:"channel_id"` // | ? // UserID the user id this voice state is for UserID Snowflake `json:"user_id"` // | // the guild member this voice state is for Member *Member `json:"member,omitempty"` // SessionID the session id for this voice state SessionID string `json:"session_id"` // | // Deaf whether this user is deafened by the server Deaf bool `json:"deaf"` // | // Mute whether this user is muted by the server Mute bool `json:"mute"` // | // SelfDeaf whether this user is locally deafened SelfDeaf bool `json:"self_deaf"` // | // SelfMute whether this user is locally muted SelfMute bool `json:"self_mute"` // | // Suppress whether this user is muted by the current user Suppress bool `json:"suppress"` // | }
VoiceState Voice State structure https://discordapp.com/developers/docs/resources/voice#voice-state-object reviewed 2018-09-29
func (*VoiceState) CopyOverTo ¶ added in v0.7.0
func (v *VoiceState) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*VoiceState) DeepCopy ¶ added in v0.7.0
func (v *VoiceState) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type VoiceStateUpdate ¶ added in v0.6.0
type VoiceStateUpdate struct { *VoiceState Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
VoiceStateUpdate someone joined, left, or moved a voice channel
type VoiceStateUpdateHandler ¶ added in v0.9.0
type VoiceStateUpdateHandler = func(session Session, h *VoiceStateUpdate)
VoiceStateUpdateHandler is triggered in VoiceStateUpdate events
type WSShard ¶ added in v0.9.0
func (*WSShard) Disconnect ¶ added in v0.9.0
func (*WSShard) Emit ¶ added in v0.9.0
func (s *WSShard) Emit(cmd SocketCommand, data interface{}) (err error)
type WSShardManager ¶ added in v0.9.0
type WSShardManager struct { sync.RWMutex TrackEvent *websocket.UniqueStringSlice // Presence represents the desired bot status at any given time Presence *UpdateStatusCommand // contains filtered or unexported fields }
func NewShardManager ¶ added in v0.9.0
func NewShardManager(conf *Config) *WSShardManager
func (*WSShardManager) Connect ¶ added in v0.9.0
func (s *WSShardManager) Connect() (err error)
func (*WSShardManager) Disconnect ¶ added in v0.9.0
func (s *WSShardManager) Disconnect() (err error)
func (*WSShardManager) Emit ¶ added in v0.9.0
func (s *WSShardManager) Emit(cmd SocketCommand, data interface{}) (err error)
func (*WSShardManager) GetAvgHeartbeatLatency ¶ added in v0.9.0
func (s *WSShardManager) GetAvgHeartbeatLatency() (latency time.Duration, err error)
GetAvgHeartbeatLatency can be 0 if no heartbeat has been measured yet
func (*WSShardManager) GetConnectionDetails ¶ added in v0.9.0
func (*WSShardManager) GetShard ¶ added in v0.9.0
func (s *WSShardManager) GetShard(guildID snowflake.ID) (*WSShard, error)
func (*WSShardManager) InitialReadyReceived ¶ added in v0.9.0
func (s *WSShardManager) InitialReadyReceived() bool
InitialReadyReceived checks if each shard has gotten at least one Ready event
func (*WSShardManager) Prepare ¶ added in v0.9.0
func (s *WSShardManager) Prepare(conf *Config) error
type WSShardManagerConfig ¶ added in v0.9.0
type WSShardManagerConfig struct { // FirstID and ShardLimit creates the shard id range for this client. // this can be useful if you have multiple clients and don't want to // duplicate the sharded connections. But have unique ones on each machine. // // ShardLimit overrides the recommended shards sent by Discord if specified. // If you do not understand sharding, and your bot is not considered "large" according // to the documentation, then just don't touch these and let DisGord configure them. FirstID uint ShardLimit uint ShardRateLimit float64 // URL is fetched from the gateway before initialising a connection URL string }
type Webhook ¶ added in v0.6.0
type Webhook struct { Lockable `json:"-"` ID Snowflake `json:"id"` // | GuildID Snowflake `json:"guild_id,omitempty"` // |? ChannelID Snowflake `json:"channel_id"` // | User *User `json:"user,omitempty"` // ?| Name string `json:"name"` // |? Avatar string `json:"avatar"` // |? Token string `json:"token"` // | }
Webhook Used to represent a webhook https://discordapp.com/developers/docs/resources/webhook#webhook-object
func CreateWebhook ¶ added in v0.6.0
func CreateWebhook(client httd.Poster, channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error)
CreateWebhook [REST] Create a new webhook. Requires the 'MANAGE_WEBHOOKS' permission. Returns a webhook object on success.
Method POST Endpoint /channels/{channel.id}/webhooks Rate limiter /channels/{channel.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#create-webhook Reviewed 2018-08-14 Comment -
func GetChannelWebhooks ¶ added in v0.6.0
GetChannelWebhooks [REST] Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission.
Method POST Endpoint /channels/{channel.id}/webhooks Rate limiter /channels/{channel.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-channel-webhooks Reviewed 2018-08-14 Comment -
func GetGuildWebhooks ¶ added in v0.6.0
GetGuildWebhooks [REST] Returns a list of guild webhook objects. Requires the 'MANAGE_WEBHOOKS' permission.
Method GET Endpoint /guilds/{guild.id}/webhooks Rate limiter /guilds/{guild.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-guild-webhooks Reviewed 2018-08-14 Comment -
func GetWebhook ¶ added in v0.6.0
GetWebhook [REST] Returns the new webhook object for the given id.
Method GET Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-webhook Reviewed 2018-08-14 Comment -
func GetWebhookWithToken ¶ added in v0.6.0
GetWebhookWithToken [REST] Same as GetWebhook, except this call does not require authentication and returns no user in the webhook object.
Method GET Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-webhook-with-token Reviewed 2018-08-14 Comment -
func ModifyWebhook ¶ added in v0.6.0
func ModifyWebhook(client httd.Patcher, id Snowflake, params *ModifyWebhookParams) (ret *Webhook, err error)
ModifyWebhook [REST] Modify a webhook. Requires the 'MANAGE_WEBHOOKS' permission. Returns the updated webhook object on success.
Method PATCH Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#modify-webhook Reviewed 2018-08-14 Comment All parameters to this endpoint.
func ModifyWebhookWithToken ¶ added in v0.6.0
ModifyWebhookWithToken [REST] Same as ModifyWebhook, except this call does not require authentication, does not accept a channel_id parameter in the body, and does not return a user in the webhook object.
Method PATCH Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#modify-webhook-with-token Reviewed 2018-08-14 Comment All parameters to this endpoint. are optional. Not tested:extra json fields might cause an issue. Consider writing a json params object.
func (*Webhook) CopyOverTo ¶ added in v0.7.0
CopyOverTo see interface at struct.go#Copier
type WebhookRESTer ¶ added in v0.8.0
type WebhookRESTer interface { CreateWebhook(channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error) GetChannelWebhooks(channelID Snowflake) (ret []*Webhook, err error) GetGuildWebhooks(guildID Snowflake) (ret []*Webhook, err error) GetWebhook(id Snowflake) (ret *Webhook, err error) GetWebhookWithToken(id Snowflake, token string) (ret *Webhook, err error) ModifyWebhook(id Snowflake, params *ModifyWebhookParams) (ret *Webhook, err error) ModifyWebhookWithToken(newWebhook *Webhook) (ret *Webhook, err error) DeleteWebhook(webhookID Snowflake) (err error) DeleteWebhookWithToken(id Snowflake, token string) (err error) ExecuteWebhook(params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error) ExecuteSlackWebhook(params *ExecuteWebhookParams, wait bool) (err error) ExecuteGitHubWebhook(params *ExecuteWebhookParams, wait bool) (err error) }
WebhookRESTer REST interface for all Webhook endpoints
type WebhooksUpdate ¶ added in v0.6.0
type WebhooksUpdate struct { GuildID Snowflake `json:"guild_id"` ChannelID Snowflake `json:"channel_id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
WebhooksUpdate guild channel webhook was created, update, or deleted
type WebhooksUpdateHandler ¶ added in v0.9.0
type WebhooksUpdateHandler = func(session Session, h *WebhooksUpdate)
WebhooksUpdateHandler is triggered in WebhooksUpdate events
Source Files ¶
- auditlog.go
- cache.go
- channel.go
- client.go
- commands.go
- disgord.go
- emoji.go
- event_demultiplexer_gen.go
- events.go
- events_gen.go
- internal_handlers.go
- invite.go
- locking.go
- logging.go
- message.go
- reaction.go
- rest.go
- rest_channel.go
- rest_guild.go
- restbuilders_gen.go
- role.go
- session.go
- shard.go
- struct.go
- struct_guild.go
- user.go
- voice.go
- voiceconnection.go
- webhook.go
Directories ¶
Path | Synopsis |
---|---|
cache
|
|
lfu
lfu (least frequently counter) will overwrite cached items that have been counter the least when the cache limit is reached.
|
lfu (least frequently counter) will overwrite cached items that have been counter the least when the cache limit is reached. |
lru
lru (least recently lastUsed) will overwrite cached items that have been lastUsed the least when the cache limit is reached.
|
lru (least recently lastUsed) will overwrite cached items that have been lastUsed the least when the cache limit is reached. |
tlru
tlru (time aware least recently lastUsed) has the same overwriting strategy as LRU, but adds a lifetime to objects on creation.
|
tlru (time aware least recently lastUsed) has the same overwriting strategy as LRU, but adds a lifetime to objects on creation. |
cmd
|
|
Package endpoint holds all discord urls for the REST endpoints
|
Package endpoint holds all discord urls for the REST endpoints |
Package event is a universal discord package that holds all the event types one can receive (currently only bot events).
|
Package event is a universal discord package that holds all the event types one can receive (currently only bot events). |
shortevent
Package shortevent is a short version of the event pkg.
|
Package shortevent is a short version of the event pkg. |
generate
|
|
discorddocs
Module
|
|