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/LaevusDexter/disgord/#Session
discord := disgord.New(&disgord.Config{ BotToken: "my-secret-bot-token", }) defer discord.StayConnectedUntilInterrupted() // listen for incoming messages and reply with a "hello" discord.On(event.MessageCreate, func(s disgord.Session, evt *disgord.MessageCreate) { msg := evt.Message msg.Reply(s, "hello") }) // 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. The setup is exactly the same as registering a function. Simply define your channel, add buffering if you need it, and register it as a handler in the `.On` method.
msgCreateChan := make(chan *disgord.MessageCreate, 10) session.On(disgord.EvtMessageCreate, msgCreateChan)
Never close a channel without removing the handler from Disgord. You can't directly call Remove, instead you inject a controller to dictate the handler's lifetime. Since you are the owner of the channel, disgord will never close it for you.
ctrl := &disgord.Ctrl{Channel: msgCreateChan} session.On(disgord.EvtMessageCreate, msgCreateChan, ctrl) go func() { // close the channel after 20 seconds and safely remove it from Disgord // without Disgord trying to send data through it after it has closed <- time.After(20 * time.Second) ctrl.CloseChannel() }
Here is what it would look like to use the channel for handling events. Please run this in a go routine unless you know what you are doing.
for { var message *disgord.Message var status string select { case evt, alive := <- msgCreateChan if !alive { return } msg = evt.Message status = "created" } fmt.Printf("A message from %s was %s\n", msg.Author.Mention(), status) // output: "A message from @Anders was created" }
WebSockets and Sharding ¶
Disgord handles sharding for you automatically; when starting the bot, when discord demands you to scale up your shards (during runtime), etc. It also gives you control over the shard setup in case you want to run multiple instances of Disgord (in these cases you must handle scaling yourself as Disgord can not).
Sharding is done behind the scenes, so you do not need to worry about any settings. Disgord will simply ask Discord for the recommended amount of shards for your bot on startup. However, to set specific amount of shards you can use the `disgord.ShardConfig` to specify a range of valid shard IDs (starts from 0).
starting a bot with exactly 5 shards
client := disgord.New(&disgord.Config{ ShardConfig: disgord.ShardConfig{ // this is a copy so u can't manipulate the config later on ShardIDs: []uint{0,1,2,3,4}, }, })
Running multiple instances each with 1 shard (note each instance must use unique shard ids)
client := disgord.New(&disgord.Config{ ShardConfig: disgord.ShardConfig{ // this is a copy so u can't manipulate the config later on ShardIDs: []uint{0}, // this number must change for each instance. Try to automate this. ShardCount: 5, // total of 5 shards, but this disgord instance only has one. AutoScaling is disabled - use OnScalingRequired. }, })
Handle scaling options yourself
client := disgord.New(&disgord.Config{ ShardConfig: disgord.ShardConfig{ // this is a copy so u can't manipulate it later on DisableAutoScaling: true, OnScalingRequired: func(shardIDs []uint) (TotalNrOfShards uint, AdditionalShardIDs []uint) { // instead of asking discord for exact number of shards recommended // this is increased by 50% every time discord complains you don't have enough shards // to reduce the number of times you have to scale TotalNrOfShards := uint(len(shardIDs) * 1.5) for i := len(shardIDs) - 1; i < TotalNrOfShards; i++ { AdditionalShardIDs = append(AdditionalShardIDs, i) } return }, // end OnScalingRequired }, // end ShardConfig })
Caching ¶
> Note: if you create a CacheConfig you don't have to set every field.
> Note: Only LFU is supported.
> Note: Lifetime options does not currently work/do anything (yet).
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). Example of configuring the cache:
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 and not supported. DisableUserCaching: false, // activates caching for users UserCacheLifetime: time.Duration(4) * time.Hour, // removed from cache after 9 hours, unless updated DisableVoiceStateCaching: true, // don't cache voice states DisableChannelCaching: false, ChannelCacheLifetime: 0, // lives forever unless cache replacement strategy kicks in }, })
If you just want to change a specific field, you can do so. The fields are always default values.
> 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 cache ¶
To keep it safe and reliable, you can not directly affect the contents of the cache. Unlike discordgo where everything is mutable, the caching in disgord is immutable. This does reduce performance as a copy must be made (only on new cache entries), but as a performance freak, I can tell you right now that a simple struct copy is not that expensive. This also means that, as long as discord sends their events properly, the caching will always reflect the true state of discord.
If there is a bug in the cache and you keep getting the incorrect data, please file an issue at github.com/LaevusDexter/disgord so it can quickly be resolved(!)
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 Disgord flags.
// 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 as before, but we insert a disgord.Flag type. user, err := session.GetUser(userID, disgord.IgnoreCache)
Disgord Flags ¶
In addition to disgord.IgnoreCache, as shown above, you can pass in other flags such as: disgord.SortByID, disgord.OrderAscending, etc. You can find these flags in the flag.go file.
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.
`disgord_legacy` adds wrapper methods with the original discord naming. eg. For REST requests you will notice Disgord uses a consistency between update/create/get/delete/set while discord uses edit/update/modify/close/delete/remove/etc. So if you struggle find a REST method, you can enable this build tag to gain access to mentioned wrappers.
`disgordperf` does some low level tweaking that can help boost json unmarshalling and drops json validation from Discord responses/events. Other optimizations might take place as well.
`disgord_websocket_gorilla` replaces nhooyr/websocket dependency with gorilla/websocket for gateway communication.
Deleting Discord data ¶
In addition to the typical REST endpoints for deleting data, you can also use Client/Session.DeleteFromDiscord(...) for basic deletions. If you need to delete a specific range of messages, or anything complex as that; you can't use .DeleteFromDiscord(...). Not every struct has implemented the interface that allows you to call DeleteFromDiscord. Do not fret, if you try to pass a type that doesn't qualify, you get a compile error.
Index ¶
- Constants
- func AllEvents(except ...string) []string
- func CreateTermSigListener() <-chan os.Signal
- func DefaultLogger(debug bool) *logger.LoggerZap
- func DefaultLoggerWithInstance(log *zap.Logger) *logger.LoggerZap
- func LibraryInfo() string
- func ShardID(guildID Snowflake, nrOfShards uint) uint
- func Sort(v interface{}, fs ...Flag)
- func SortRoles(rs []*Role)
- func ValidateHandlerInputs(inputs ...interface{}) (err error)
- func ValidateUsername(name string) (err error)
- type Activity
- type ActivityAssets
- type ActivityEmoji
- type ActivityParty
- type ActivitySecrets
- type ActivityTimestamp
- type AddGuildMemberParams
- type Attachment
- type AuditLog
- type AuditLogChange
- type AuditLogChanges
- type AuditLogEntry
- type AuditLogEvt
- type AuditLogOption
- type AvatarParamHolder
- type Ban
- type BanMemberParams
- type BodyUserCreateDM
- type Cache
- func (c *Cache) AddGuildChannel(guildID Snowflake, channelID Snowflake)
- func (c *Cache) AddGuildMember(guildID Snowflake, member *Member)
- func (c *Cache) AddGuildRole(guildID Snowflake, role *Role)
- func (c *Cache) DeleteChannel(id Snowflake)
- func (c *Cache) DeleteChannelPermissionOverwrite(channelID Snowflake, overwriteID Snowflake) error
- func (c *Cache) DeleteGuild(id Snowflake)
- func (c *Cache) DeleteGuildChannel(guildID, channelID Snowflake)
- func (c *Cache) DeleteGuildEmoji(guildID, emojiID Snowflake)
- func (c *Cache) DeleteGuildRole(guildID, roleID Snowflake)
- func (c *Cache) DirectUpdate(registry cacheRegistry, id Snowflake, 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) (guild *Guild, err error)
- func (c *Cache) PeekUser(id Snowflake) (*User, error)
- func (c *Cache) RemoveGuildMember(guildID Snowflake, memberID Snowflake)
- 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 Time)
- func (c *Cache) UpdateGuildRole(guildID Snowflake, role *Role, data json.RawMessage) bool
- func (c *Cache) UpdateMemberAndUser(guildID, userID Snowflake, 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 (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) Reset()
- func (c *Channel) SendMsg(ctx context.Context, client MessageSender, message *Message) (msg *Message, err error)
- func (c *Channel) SendMsgString(ctx context.Context, client MessageSender, content string) (msg *Message, err error)
- func (c *Channel) String() string
- type ChannelCreate
- type ChannelCreateHandler
- type ChannelDelete
- type ChannelDeleteHandler
- type ChannelFetcher
- type ChannelPinsUpdate
- type ChannelPinsUpdateHandler
- type ChannelUpdate
- type ChannelUpdateHandler
- type Client
- func (c *Client) AddDMParticipant(ctx context.Context, channelID Snowflake, participant *GroupDMParticipant, ...) error
- func (c *Client) AddGuildMember(ctx context.Context, guildID, userID Snowflake, accessToken string, ...) (member *Member, err error)
- func (c *Client) AddGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) (err error)
- func (c *Client) AddPermission(permission PermissionBit) (updatedPermissions PermissionBits)
- func (c *Client) AvgHeartbeatLatency() (duration time.Duration, err error)
- func (c *Client) BanMember(ctx context.Context, guildID, userID Snowflake, params *BanMemberParams, ...) (err error)
- func (c *Client) Cache() Cacher
- func (c *Client) Connect(ctx context.Context) (err error)
- func (c *Client) CreateChannelInvites(ctx context.Context, channelID Snowflake, params *CreateChannelInvitesParams, ...) (ret *Invite, err error)
- func (c *Client) CreateDM(ctx context.Context, recipientID Snowflake, flags ...Flag) (ret *Channel, err error)
- func (c *Client) CreateGroupDM(ctx context.Context, params *CreateGroupDMParams, flags ...Flag) (ret *Channel, err error)
- func (c *Client) CreateGuild(ctx context.Context, guildName string, params *CreateGuildParams, ...) (ret *Guild, err error)
- func (c *Client) CreateGuildChannel(ctx context.Context, guildID Snowflake, channelName string, ...) (ret *Channel, err error)
- func (c *Client) CreateGuildEmoji(ctx context.Context, guildID Snowflake, params *CreateGuildEmojiParams, ...) (emoji *Emoji, err error)
- func (c *Client) CreateGuildIntegration(ctx context.Context, guildID Snowflake, params *CreateGuildIntegrationParams, ...) (err error)
- func (c *Client) CreateGuildRole(ctx context.Context, id Snowflake, params *CreateGuildRoleParams, ...) (ret *Role, err error)
- func (c *Client) CreateMessage(ctx context.Context, channelID Snowflake, params *CreateMessageParams, ...) (ret *Message, err error)
- func (c *Client) CreateReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, ...) (err error)
- func (c *Client) CreateWebhook(ctx context.Context, channelID Snowflake, params *CreateWebhookParams, ...) (ret *Webhook, err error)
- func (c *Client) DeleteAllReactions(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (channel *Channel, err error)
- func (c *Client) DeleteChannelPermission(ctx context.Context, channelID, overwriteID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteFromDiscord(ctx context.Context, obj discordDeleter, flags ...Flag) (err error)
- func (c *Client) DeleteGuild(ctx context.Context, id Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteInvite(ctx context.Context, inviteCode string, flags ...Flag) (deleted *Invite, err error)
- func (c *Client) DeleteMessage(ctx context.Context, channelID, msgID Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteMessages(ctx context.Context, chanID Snowflake, params *DeleteMessagesParams, ...) (err error)
- func (c *Client) DeleteOwnReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, ...) (err error)
- func (c *Client) DeleteUserReaction(ctx context.Context, channelID, messageID, userID Snowflake, emoji interface{}, ...) (err error)
- func (c *Client) DeleteWebhook(ctx context.Context, id Snowflake, flags ...Flag) (err error)
- func (c *Client) DeleteWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (err error)
- func (c *Client) Disconnect() (err error)
- func (c *Client) DisconnectOnInterrupt() (err error)
- func (c *Client) Emit(name gatewayCmdName, payload gatewayCmdPayload) (unchandledGuildIDs []Snowflake, err error)
- func (c *Client) EstimatePruneMembersCount(ctx context.Context, id Snowflake, days int, flags ...Flag) (estimate int, err error)
- func (c *Client) ExecuteGitHubWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) (err error)
- func (c *Client) ExecuteSlackWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) (err error)
- func (c *Client) ExecuteWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, URLSuffix string, ...) (err error)
- func (c *Client) GetChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (ret *Channel, err error)
- func (c *Client) GetChannelInvites(ctx context.Context, channelID Snowflake, flags ...Flag) (invites []*Invite, err error)
- func (c *Client) GetChannelWebhooks(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Webhook, err error)
- func (c *Client) GetConnectedGuilds() []Snowflake
- func (c *Client) GetCurrentUser(ctx context.Context, flags ...Flag) (user *User, err error)
- func (c *Client) GetCurrentUserGuilds(ctx context.Context, params *GetCurrentUserGuildsParams, flags ...Flag) (ret []*PartialGuild, err error)
- func (c *Client) GetGateway(ctx context.Context) (gateway *gateway.Gateway, err error)
- func (c *Client) GetGatewayBot(ctx context.Context) (gateway *gateway.GatewayBot, err error)
- func (c *Client) GetGuild(ctx context.Context, id Snowflake, flags ...Flag) (guild *Guild, err error)
- func (c *Client) GetGuildAuditLogs(ctx context.Context, guildID Snowflake, flags ...Flag) (builder *guildAuditLogsBuilder)
- func (c *Client) GetGuildBan(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (ret *Ban, err error)
- func (c *Client) GetGuildBans(ctx context.Context, id Snowflake, flags ...Flag) (bans []*Ban, err error)
- func (c *Client) GetGuildChannels(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Channel, err error)
- func (c *Client) GetGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) (embed *GuildEmbed, err error)
- func (c *Client) GetGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (*Emoji, error)
- func (c *Client) GetGuildEmojis(ctx context.Context, guildID Snowflake, flags ...Flag) (emojis []*Emoji, err error)
- func (c *Client) GetGuildIntegrations(ctx context.Context, id Snowflake, flags ...Flag) (ret []*Integration, err error)
- func (c *Client) GetGuildInvites(ctx context.Context, id Snowflake, flags ...Flag) (ret []*Invite, err error)
- func (c *Client) GetGuildRoles(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Role, err error)
- func (c *Client) GetGuildVanityURL(ctx context.Context, guildID Snowflake, flags ...Flag) (ret *PartialInvite, err error)
- func (c *Client) GetGuildVoiceRegions(ctx context.Context, id Snowflake, flags ...Flag) (ret []*VoiceRegion, err error)
- func (c *Client) GetGuildWebhooks(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Webhook, err error)
- func (c *Client) GetGuilds(ctx context.Context, params *GetCurrentUserGuildsParams, flags ...Flag) ([]*Guild, error)
- func (c *Client) GetInvite(ctx context.Context, inviteCode string, params URLQueryStringer, flags ...Flag) (invite *Invite, err error)
- func (c *Client) GetMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (ret *Member, err error)
- func (c *Client) GetMemberPermissions(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (permissions PermissionBits, err error)
- func (c *Client) GetMembers(ctx context.Context, guildID Snowflake, params *GetMembersParams, ...) (members []*Member, err error)
- func (c *Client) GetMessage(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (message *Message, err error)
- func (c *Client) GetMessages(ctx context.Context, channelID Snowflake, filter *GetMessagesParams, ...) (messages []*Message, err error)
- func (c *Client) GetPermissions() (permissions PermissionBits)
- func (c *Client) GetPinnedMessages(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Message, err error)
- func (c *Client) GetReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, ...) (ret []*User, err error)
- func (c *Client) GetUser(ctx context.Context, id Snowflake, flags ...Flag) (*User, error)
- func (c *Client) GetUserConnections(ctx context.Context, flags ...Flag) (connections []*UserConnection, err error)
- func (c *Client) GetUserDMs(ctx context.Context, flags ...Flag) (ret []*Channel, err error)
- func (c *Client) GetVoiceRegions(ctx context.Context, flags ...Flag) (regions []*VoiceRegion, err error)
- func (c *Client) GetWebhook(ctx context.Context, id Snowflake, flags ...Flag) (ret *Webhook, err error)
- func (c *Client) GetWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (ret *Webhook, err error)
- func (c *Client) GuildsReady(cb func())
- func (c *Client) HeartbeatLatencies() (latencies map[uint]time.Duration, err error)
- func (c *Client) InviteURL(ctx context.Context) (u string, err error)
- func (c *Client) KickMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) (err error)
- func (c *Client) KickParticipant(ctx context.Context, channelID, userID Snowflake, flags ...Flag) (err error)
- func (c *Client) KickVoiceParticipant(ctx context.Context, guildID, userID Snowflake) error
- func (c *Client) LeaveGuild(ctx context.Context, id Snowflake, flags ...Flag) (err error)
- func (c *Client) Logger() logger.Logger
- func (c *Client) Myself(ctx context.Context) (user *User, err error)
- func (c *Client) On(event string, inputs ...interface{})
- func (c *Client) OnChannelCreate(mdlws []Middleware, handlers []HandlerChannelCreate, ctrl ...HandlerCtrl)
- func (c *Client) OnChannelDelete(mdlws []Middleware, handlers []HandlerChannelDelete, ctrl ...HandlerCtrl)
- func (c *Client) OnChannelPinsUpdate(mdlws []Middleware, handlers []HandlerChannelPinsUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnChannelUpdate(mdlws []Middleware, handlers []HandlerChannelUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildBanAdd(mdlws []Middleware, handlers []HandlerGuildBanAdd, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildBanRemove(mdlws []Middleware, handlers []HandlerGuildBanRemove, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildCreate(mdlws []Middleware, handlers []HandlerGuildCreate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildDelete(mdlws []Middleware, handlers []HandlerGuildDelete, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildEmojisUpdate(mdlws []Middleware, handlers []HandlerGuildEmojisUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildIntegrationsUpdate(mdlws []Middleware, handlers []HandlerGuildIntegrationsUpdate, ...)
- func (c *Client) OnGuildMemberAdd(mdlws []Middleware, handlers []HandlerGuildMemberAdd, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildMemberRemove(mdlws []Middleware, handlers []HandlerGuildMemberRemove, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildMemberUpdate(mdlws []Middleware, handlers []HandlerGuildMemberUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildMembersChunk(mdlws []Middleware, handlers []HandlerGuildMembersChunk, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildRoleCreate(mdlws []Middleware, handlers []HandlerGuildRoleCreate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildRoleDelete(mdlws []Middleware, handlers []HandlerGuildRoleDelete, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildRoleUpdate(mdlws []Middleware, handlers []HandlerGuildRoleUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnGuildUpdate(mdlws []Middleware, handlers []HandlerGuildUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnInviteCreate(mdlws []Middleware, handlers []HandlerInviteCreate, ctrl ...HandlerCtrl)
- func (c *Client) OnMessageCreate(mdlws []Middleware, handlers []HandlerMessageCreate, ctrl ...HandlerCtrl)
- func (c *Client) OnMessageDelete(mdlws []Middleware, handlers []HandlerMessageDelete, ctrl ...HandlerCtrl)
- func (c *Client) OnMessageDeleteBulk(mdlws []Middleware, handlers []HandlerMessageDeleteBulk, ctrl ...HandlerCtrl)
- func (c *Client) OnMessageReactionAdd(mdlws []Middleware, handlers []HandlerMessageReactionAdd, ctrl ...HandlerCtrl)
- func (c *Client) OnMessageReactionRemove(mdlws []Middleware, handlers []HandlerMessageReactionRemove, ...)
- func (c *Client) OnMessageReactionRemoveAll(mdlws []Middleware, handlers []HandlerMessageReactionRemoveAll, ...)
- func (c *Client) OnMessageUpdate(mdlws []Middleware, handlers []HandlerMessageUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnPresenceUpdate(mdlws []Middleware, handlers []HandlerPresenceUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnReady(mdlws []Middleware, handlers []HandlerReady, ctrl ...HandlerCtrl)
- func (c *Client) OnResumed(mdlws []Middleware, handlers []HandlerResumed, ctrl ...HandlerCtrl)
- func (c *Client) OnTypingStart(mdlws []Middleware, handlers []HandlerTypingStart, ctrl ...HandlerCtrl)
- func (c *Client) OnUserUpdate(mdlws []Middleware, handlers []HandlerUserUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnVoiceServerUpdate(mdlws []Middleware, handlers []HandlerVoiceServerUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnVoiceStateUpdate(mdlws []Middleware, handlers []HandlerVoiceStateUpdate, ctrl ...HandlerCtrl)
- func (c *Client) OnWebhooksUpdate(mdlws []Middleware, handlers []HandlerWebhooksUpdate, ctrl ...HandlerCtrl)
- func (c *Client) PinMessage(ctx context.Context, message *Message, flags ...Flag) error
- func (c *Client) PinMessageID(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
- func (c *Client) Pool() *pools
- func (c *Client) PruneMembers(ctx context.Context, id Snowflake, days int, reason string, flags ...Flag) (err error)
- func (c *Client) RESTBucketGrouping() (group map[string][]string)
- func (c *Client) RESTRatelimitBuckets() (group map[string][]string)
- func (c *Client) Ready(cb func())
- func (c *Client) RemoveGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) (err error)
- func (c *Client) Req() httd.Requester
- func (c *Client) SendMsg(ctx context.Context, channelID Snowflake, data ...interface{}) (msg *Message, err error)
- func (c *Client) SetCurrentUserNick(ctx context.Context, id Snowflake, nick string, flags ...Flag) (newNick string, err error)
- func (c *Client) SetMsgContent(ctx context.Context, chanID, msgID Snowflake, content string) (*Message, error)
- func (c *Client) SetMsgEmbed(ctx context.Context, chanID, msgID Snowflake, embed *Embed) (*Message, error)
- func (c *Client) StayConnectedUntilInterrupted(ctx context.Context) (err error)
- func (c *Client) String() string
- func (c *Client) Suspend() (err error)
- func (c *Client) SyncGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) (err error)
- func (c *Client) TriggerTypingIndicator(ctx context.Context, channelID Snowflake, flags ...Flag) (err error)
- func (c *Client) UnbanMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) (err error)
- func (c *Client) UnpinMessage(ctx context.Context, message *Message, flags ...Flag) error
- func (c *Client) UnpinMessageID(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
- func (c *Client) UpdateChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (builder *updateChannelBuilder)
- func (c *Client) UpdateChannelPermissions(ctx context.Context, channelID, overwriteID Snowflake, ...) (err error)
- func (c *Client) UpdateCurrentUser(ctx context.Context, flags ...Flag) (builder *updateCurrentUserBuilder)
- func (c *Client) UpdateGuild(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateGuildBuilder)
- func (c *Client) UpdateGuildChannelPositions(ctx context.Context, guildID Snowflake, ...) (err error)
- func (c *Client) UpdateGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) (builder *updateGuildEmbedBuilder)
- func (c *Client) UpdateGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (builder *updateGuildEmojiBuilder)
- func (c *Client) UpdateGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, ...) (err error)
- func (c *Client) UpdateGuildMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (builder *updateGuildMemberBuilder)
- func (c *Client) UpdateGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) (builder *updateGuildRoleBuilder)
- func (c *Client) UpdateGuildRolePositions(ctx context.Context, guildID Snowflake, ...) (roles []*Role, err error)
- func (c *Client) UpdateMessage(ctx context.Context, chanID, msgID Snowflake, flags ...Flag) (builder *updateMessageBuilder)
- func (c *Client) UpdateStatus(s *UpdateStatusPayload) error
- func (c *Client) UpdateStatusString(s string) error
- func (c *Client) UpdateWebhook(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateWebhookBuilder)
- func (c *Client) UpdateWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (builder *updateWebhookBuilder)
- func (r Client) VoiceConnect(guildID, channelID Snowflake) (VoiceConnection, error)
- func (r Client) VoiceConnectOptions(guildID, channelID Snowflake, selfDeaf, selfMute bool) (ret VoiceConnection, err error)
- type CloseConnectionErr
- type Config
- type Copier
- type CreateChannelInvitesParams
- type CreateGroupDMParams
- type CreateGuildChannelParams
- type CreateGuildEmojiParams
- type CreateGuildIntegrationParams
- type CreateGuildParams
- type CreateGuildRoleParams
- type CreateMessageFileParams
- type CreateMessageParams
- type CreateWebhookParams
- type Ctrl
- type DeepCopier
- type DefaultMessageNotificationLvl
- type DeleteMessagesParams
- type Discriminator
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type Emitter
- type Emoji
- type Err
- type ErrRest
- type ErrorCacheItemNotFound
- type ErrorEmptyValue
- type ErrorMissingSnowflake
- type ErrorUnsupportedType
- type ErrorUsingDeactivatedCache
- type ExecuteWebhookParams
- type ExplicitContentFilterLvl
- type Flag
- type GetCurrentUserGuildsParams
- type GetInviteParams
- type GetMembersParams
- type GetMessagesParams
- type GetReactionURLParams
- type GroupDMParticipant
- type 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) GetMembersCountEstimate(ctx context.Context, s Session) (estimate int, 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) Reset()
- func (g *Guild) Role(id Snowflake) (role *Role, err error)
- func (g *Guild) RoleByName(name string) ([]*Role, error)
- func (g *Guild) String() string
- 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 GuildRoleCreate
- type GuildRoleCreateHandler
- type GuildRoleDelete
- type GuildRoleDeleteHandler
- type GuildRoleUpdate
- type GuildRoleUpdateHandler
- type GuildUnavailable
- type GuildUpdate
- type GuildUpdateHandler
- type Handler
- type HandlerChannelCreate
- type HandlerChannelDelete
- type HandlerChannelPinsUpdate
- type HandlerChannelUpdate
- type HandlerCtrl
- type HandlerGuildBanAdd
- type HandlerGuildBanRemove
- type HandlerGuildCreate
- type HandlerGuildDelete
- type HandlerGuildEmojisUpdate
- type HandlerGuildIntegrationsUpdate
- type HandlerGuildMemberAdd
- type HandlerGuildMemberRemove
- type HandlerGuildMemberUpdate
- type HandlerGuildMembersChunk
- type HandlerGuildRoleCreate
- type HandlerGuildRoleDelete
- type HandlerGuildRoleUpdate
- type HandlerGuildUpdate
- type HandlerInviteCreate
- type HandlerMessageCreate
- type HandlerMessageDelete
- type HandlerMessageDeleteBulk
- type HandlerMessageReactionAdd
- type HandlerMessageReactionRemove
- type HandlerMessageReactionRemoveAll
- type HandlerMessageUpdate
- type HandlerPresenceUpdate
- type HandlerReady
- type HandlerResumed
- type HandlerSpecErr
- type HandlerTypingStart
- type HandlerUserUpdate
- type HandlerVoiceServerUpdate
- type HandlerVoiceStateUpdate
- type HandlerWebhooksUpdate
- type Integration
- type IntegrationAccount
- type Invite
- type InviteCreate
- type InviteCreateHandler
- type InviteMetadata
- type Link
- type Lockable
- type Logger
- type MFALvl
- type Member
- func (m *Member) CopyOverTo(other interface{}) (err error)
- func (m *Member) DeepCopy() (copy interface{})
- func (m *Member) GetPermissions(ctx context.Context, s Session) (p uint64, err error)
- func (m *Member) GetUser(ctx context.Context, session Session) (usr *User, err error)
- func (m *Member) Mention() string
- func (m *Member) Reset()
- func (m *Member) String() string
- func (m *Member) UpdateNick(ctx context.Context, client nickUpdater, nickname string, flags ...Flag) error
- type MentionChannel
- type Mentioner
- type Message
- func (m *Message) CopyOverTo(other interface{}) (err error)
- func (m *Message) DeepCopy() (copy interface{})
- func (m *Message) DiscordURL() (string, error)
- func (m *Message) IsDirectMessage() bool
- func (m *Message) React(ctx context.Context, s Session, emoji interface{}, flags ...Flag) error
- func (m *Message) Reply(ctx context.Context, client msgSender, data ...interface{}) (*Message, error)
- func (m *Message) Reset()
- func (m *Message) Send(ctx context.Context, client MessageSender, flags ...Flag) (msg *Message, err error)
- func (m *Message) String() string
- func (m *Message) Unreact(ctx context.Context, s Session, emoji interface{}, flags ...Flag) error
- type MessageActivity
- type MessageApplication
- type MessageCreate
- type MessageCreateHandler
- type MessageDelete
- type MessageDeleteBulk
- type MessageDeleteBulkHandler
- type MessageDeleteHandler
- type MessageFlag
- type MessageReactionAdd
- type MessageReactionAddHandler
- type MessageReactionRemove
- type MessageReactionRemoveAll
- type MessageReactionRemoveAllHandler
- type MessageReactionRemoveHandler
- type MessageReference
- type MessageSender
- type MessageType
- type MessageUpdate
- type MessageUpdateHandler
- type MessageUpdater
- type Middleware
- type PartialBan
- type PartialChannel
- type PartialEmoji
- type PartialGuild
- type PartialInvite
- type PermissionBit
- type PermissionBits
- type PermissionOverwrite
- type Pool
- type PremiumType
- type PresenceUpdate
- type PresenceUpdateHandler
- type RESTAuditLogs
- type RESTBuilder
- type RESTChannel
- type RESTEmoji
- type RESTGuild
- type RESTInvite
- type RESTMessage
- type RESTMethods
- type RESTReaction
- type RESTUser
- type RESTVoice
- type RESTWebhook
- type Reaction
- type Ready
- type ReadyHandler
- type RequestGuildMembersPayload
- type Reseter
- type Resumed
- type ResumedHandler
- type Role
- type Session
- type ShardConfig
- type SimpleHandler
- type SimplestHandler
- type Snowflake
- type SocketHandler
- type SocketHandlerRegistrators
- type Time
- type TypingStart
- type TypingStartHandler
- type URLQueryStringer
- type UpdateChannelPermissionsParams
- type UpdateGuildChannelPositionsParams
- type UpdateGuildIntegrationParams
- type UpdateGuildRolePositionsParams
- type UpdateStatusPayload
- type UpdateVoiceStatePayload
- type User
- func (u *User) AvatarURL(size int, preferGIF bool) (url string, err error)
- func (u *User) CopyOverTo(other interface{}) (err error)
- func (u *User) DeepCopy() (copy interface{})
- func (u *User) Mention() string
- func (u *User) Reset()
- func (u *User) SendMsg(ctx context.Context, session Session, message *Message) (channel *Channel, msg *Message, err error)
- func (u *User) SendMsgString(ctx context.Context, session Session, content string) (channel *Channel, msg *Message, err error)
- func (u *User) String() string
- func (u *User) Tag() string
- func (u *User) UnmarshalJSON(data []byte) (err error)
- func (u *User) Valid() bool
- type UserConnection
- type UserPresence
- type UserUpdate
- type UserUpdateHandler
- type VerificationLvl
- type VoiceConnection
- type VoiceHandler
- type VoiceRegion
- type VoiceServerUpdate
- type VoiceServerUpdateHandler
- type VoiceState
- type VoiceStateUpdate
- type VoiceStateUpdateHandler
- type Webhook
- type WebhooksUpdate
- type WebhooksUpdateHandler
Constants ¶
const ( NoCacheSpecified cacheRegistry = iota UserCache ChannelCache GuildCache GuildEmojiCache VoiceStateCache GuildMembersCache GuildRolesCache // warning: deletes previous roles GuildRoleCache // updates or adds a new role )
cacheLink keys to redirect to the related cacheLink system
const ( ChannelTypeGuildText uint = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory ChannelTypeGuildNews ChannelTypeGuildStore )
Channel types https://discord.com/developers/docs/resources/channel#channel-object-channel-types
const ( // GatewayCmdRequestGuildMembers 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. RequestGuildMembers gatewayCmdName = cmd.RequestGuildMembers // UpdateVoiceState Sent when a Client wants to join, move, or // disconnect from a voice channel. UpdateVoiceState gatewayCmdName = cmd.UpdateVoiceState // UpdateStatus Sent by the Client to indicate a presence or status // update. UpdateStatus gatewayCmdName = cmd.UpdateStatus )
const ( StatusOnline = string(gateway.StatusOnline) StatusOffline = string(gateway.StatusOffline) StatusDnd = string(gateway.StatusDND) StatusIdle = string(gateway.StatusIdle) )
const ( PermissionCreateInstantInvite PermissionBit = 1 << iota PermissionKickMembers PermissionBanMembers PermissionAdministrator PermissionManageChannels PermissionManageServer PermissionAddReactions PermissionViewAuditLogs PermissionTextAll = PermissionReadMessages | PermissionSendMessages | PermissionSendTTSMessages | PermissionManageMessages | PermissionEmbedLinks | PermissionAttachFiles | PermissionReadMessageHistory | PermissionMentionEveryone PermissionAllVoice = PermissionVoiceConnect | PermissionVoiceSpeak | PermissionVoiceMuteMembers | PermissionVoiceDeafenMembers | PermissionVoiceMoveMembers | PermissionVoiceUseVAD PermissionChannelAll = PermissionTextAll | PermissionAllVoice | PermissionCreateInstantInvite | PermissionManageRoles | PermissionManageChannels | PermissionAddReactions | PermissionViewAuditLogs PermissionAll = PermissionChannelAll | PermissionKickMembers | PermissionBanMembers | PermissionManageServer | PermissionAdministrator )
Constants for the different bit offsets of general permissions
const ( MessageActivityTypeJoin MessageActivityTypeSpectate MessageActivityTypeListen MessageActivityTypeJoinRequest )
different message acticity types
const ( ActivityTypeGame acitivityType = iota ActivityTypeStreaming ActivityTypeListening ActivityTypeCustom )
const ( ActivityFlagInstance activityFlag = 1 << iota ActivityFlagJoin ActivityFlagSpectate ActivityFlagJoinRequest ActivityFlagSync ActivityFlagPlay )
flags for the Activity object to signify the type of action taken place
const (
AttachmentSpoilerPrefix = "SPOILER_"
)
const EvtChannelCreate = event.ChannelCreate
EvtChannelCreate Sent when a new channel is created, relevant to the current user. The inner payload is a DM channel or guild channel object.
const EvtChannelDelete = event.ChannelDelete
EvtChannelDelete Sent when a channel relevant to the current user is deleted. The inner payload is a DM or Guild channel object.
const EvtChannelPinsUpdate = event.ChannelPinsUpdate
EvtChannelPinsUpdate 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 EvtChannelUpdate = event.ChannelUpdate
EvtChannelUpdate Sent when a channel is updated. The inner payload is a guild channel object.
const EvtGuildBanAdd = event.GuildBanAdd
EvtGuildBanAdd Sent when a user is banned from a guild. The inner payload is a user object, with an extra guild_id key.
const EvtGuildBanRemove = event.GuildBanRemove
EvtGuildBanRemove Sent when a user is unbanned from a guild. The inner payload is a user object, with an extra guild_id key.
const EvtGuildCreate = event.GuildCreate
EvtGuildCreate 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 EvtGuildDelete = event.GuildDelete
EvtGuildDelete 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 EvtGuildEmojisUpdate = event.GuildEmojisUpdate
EvtGuildEmojisUpdate Sent when a guild's emojis have been updated.
Fields: - GuildID Snowflake - Emojis []*Emoji
const EvtGuildIntegrationsUpdate = event.GuildIntegrationsUpdate
EvtGuildIntegrationsUpdate Sent when a guild integration is updated.
Fields: - GuildID Snowflake
const EvtGuildMemberAdd = event.GuildMemberAdd
EvtGuildMemberAdd 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 EvtGuildMemberRemove = event.GuildMemberRemove
EvtGuildMemberRemove Sent when a user is removed from a guild (leave/kick/ban).
Fields: - GuildID Snowflake - User *User
const EvtGuildMemberUpdate = event.GuildMemberUpdate
EvtGuildMemberUpdate Sent when a guild member is updated.
Fields: - GuildID Snowflake - Roles []Snowflake - User *User - Nick string
const EvtGuildMembersChunk = event.GuildMembersChunk
EvtGuildMembersChunk Sent in response to Gateway Request Guild Members.
Fields: - GuildID Snowflake - Members []*Member
const EvtGuildRoleCreate = event.GuildRoleCreate
EvtGuildRoleCreate Sent when a guild role is created.
Fields: - GuildID Snowflake - Role *Role
const EvtGuildRoleDelete = event.GuildRoleDelete
EvtGuildRoleDelete Sent when a guild role is created.
Fields: - GuildID Snowflake - RoleID Snowflake
const EvtGuildRoleUpdate = event.GuildRoleUpdate
EvtGuildRoleUpdate Sent when a guild role is created.
Fields: - GuildID Snowflake - Role *Role
const EvtGuildUpdate = event.GuildUpdate
EvtGuildUpdate Sent when a guild is updated. The inner payload is a guild object.
const EvtInviteCreate = event.InviteCreate
EvtInviteCreate Sent when a guild channel's invite is created.
Fields: - GuildID Snowflake - ChannelID Snowflake
const EvtMessageCreate = event.MessageCreate
EvtMessageCreate Sent when a message is created. The inner payload is a message object.
const EvtMessageDelete = event.MessageDelete
EvtMessageDelete Sent when a message is deleted.
Fields: - ID Snowflake - ChannelID Snowflake
const EvtMessageDeleteBulk = event.MessageDeleteBulk
EvtMessageDeleteBulk Sent when multiple messages are deleted at once.
Fields: - IDs []Snowflake - ChannelID Snowflake
const EvtMessageReactionAdd = event.MessageReactionAdd
EvtMessageReactionAdd Sent when a user adds a reaction to a message.
Fields: - UserID Snowflake - ChannelID Snowflake - MessageID Snowflake - Emoji *Emoji
const EvtMessageReactionRemove = event.MessageReactionRemove
EvtMessageReactionRemove Sent when a user removes a reaction from a message.
Fields: - UserID Snowflake - ChannelID Snowflake - MessageID Snowflake - Emoji *Emoji
const EvtMessageReactionRemoveAll = event.MessageReactionRemoveAll
EvtMessageReactionRemoveAll Sent when a user explicitly removes all reactions from a message.
Fields: - ChannelID Snowflake - MessageID Snowflake
const EvtMessageUpdate = event.MessageUpdate
EvtMessageUpdate Sent when a message is updated. The inner payload is a message object.
NOTE! Has _at_least_ the GuildID and ChannelID fields.
const EvtPresenceUpdate = event.PresenceUpdate
EvtPresenceUpdate 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 EvtReady = event.Ready
EvtReady 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 EvtResumed = event.Resumed
EvtResumed The resumed event is dispatched when a client has sent a resume payload to the gateway (for resuming existing sessions).
Fields: - Trace []string
const EvtTypingStart = event.TypingStart
EvtTypingStart Sent when a user starts typing in a channel.
Fields: - ChannelID Snowflake - UserID Snowflake - TimestampUnix int
const EvtUserUpdate = event.UserUpdate
EvtUserUpdate Sent when properties about the user change. Inner payload is a user object.
const EvtVoiceServerUpdate = event.VoiceServerUpdate
EvtVoiceServerUpdate 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 EvtVoiceStateUpdate = event.VoiceStateUpdate
EvtVoiceStateUpdate Sent when someone joins/leaves/moves voice channels. Inner payload is a voice state object.
const EvtWebhooksUpdate = event.WebhooksUpdate
EvtWebhooksUpdate Sent when a guild channel's WebHook is created, updated, or deleted.
Fields: - GuildID Snowflake - ChannelID Snowflake
const Name = constant.Name
const Version = constant.Version
Variables ¶
This section is empty.
Functions ¶
func CreateTermSigListener ¶ added in v0.16.6
CreateTermSigListener create a channel to listen for termination signals (graceful shutdown)
func DefaultLogger ¶ added in v0.16.6
func DefaultLoggerWithInstance ¶ added in v0.16.6
func ShardID ¶ added in v0.16.6
ShardID calculate the shard id for a given guild. https://discord.com/developers/docs/topics/gateway#sharding-sharding-formula
func SortRoles ¶ added in v0.16.6
func SortRoles(rs []*Role)
SortRoles sorts a slice of roles such that the first element is the top one in the Discord Guild Settings UI.
func ValidateHandlerInputs ¶ added in v0.16.6
func ValidateHandlerInputs(inputs ...interface{}) (err error)
func ValidateUsername ¶ added in v0.16.6
ValidateUsername uses Discords rule-set to verify user-names and nicknames https://discord.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.16.6
type Activity struct { Lockable `json:"-"` Name string `json:"name"` // the activity's name Type acitivityType `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 Emoji *ActivityEmoji `json:"emoji"` 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 activityFlag `json:"flags,omitempty"` // flags? int activity flags ORd together, describes what the payload includes }
func (*Activity) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type ActivityAssets ¶ added in v0.16.6
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.16.6
func (a *ActivityAssets) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityAssets) DeepCopy ¶ added in v0.16.6
func (a *ActivityAssets) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ActivityEmoji ¶ added in v0.16.6
type ActivityEmoji struct { Lockable `json:"-"` Name string `json:"name"` ID Snowflake `json:"id,omitempty"` Animated bool `json:"animated,omitempty"` }
ActivityEmoji ...
type ActivityParty ¶ added in v0.16.6
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.16.6
func (ap *ActivityParty) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityParty) DeepCopy ¶ added in v0.16.6
func (ap *ActivityParty) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*ActivityParty) Limit ¶ added in v0.16.6
func (ap *ActivityParty) Limit() int
Limit shows the maximum number of guests/people allowed
func (*ActivityParty) NumberOfPeople ¶ added in v0.16.6
func (ap *ActivityParty) NumberOfPeople() int
NumberOfPeople shows the current number of people attending the Party
type ActivitySecrets ¶ added in v0.16.6
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.16.6
func (a *ActivitySecrets) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivitySecrets) DeepCopy ¶ added in v0.16.6
func (a *ActivitySecrets) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type ActivityTimestamp ¶ added in v0.16.6
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.16.6
func (a *ActivityTimestamp) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*ActivityTimestamp) DeepCopy ¶ added in v0.16.6
func (a *ActivityTimestamp) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AddGuildMemberParams ¶ added in v0.16.6
type AddGuildMemberParams struct { AccessToken string `json:"access_token"` // required Nick string `json:"nick,omitempty"` Roles []Snowflake `json:"roles,omitempty"` Mute bool `json:"mute,omitempty"` Deaf bool `json:"deaf,omitempty"` }
AddGuildMemberParams ... https://discord.com/developers/docs/resources/guild#add-guild-member-json-params
type Attachment ¶ added in v0.16.6
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://discord.com/developers/docs/resources/channel#attachment-object
func (*Attachment) DeepCopy ¶ added in v0.16.6
func (a *Attachment) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLog ¶ added in v0.16.6
type AuditLog struct { Lockable `json:"-"` Webhooks []*Webhook `json:"webhooks"` Users []*User `json:"users"` AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"` }
AuditLog ...
func (*AuditLog) Bans ¶ added in v0.16.6
func (l *AuditLog) Bans() (bans []*PartialBan)
func (*AuditLog) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type AuditLogChange ¶ added in v0.16.6
type AuditLogChange string
const ( // key name, identifier changed, type, description AuditLogChangeName AuditLogChange = "name" // guild string name changed AuditLogChangeIconHash AuditLogChange = "icon_hash" // guild string icon changed AuditLogChangeSplashHash AuditLogChange = "splash_hash" // guild string invite splash page artwork changed AuditLogChangeOwnerID AuditLogChange = "owner_id" // guild snowflake owner changed AuditLogChangeRegion AuditLogChange = "region" // guild string region changed AuditLogChangeAFKChannelID AuditLogChange = "afk_channel_id" // guild snowflake afk channel changed AuditLogChangeAFKTimeout AuditLogChange = "afk_timeout" // guild integer afk timeout duration changed AuditLogChangeMFALevel AuditLogChange = "mfa_level" // guild integer two-factor auth requirement changed AuditLogChangeVerificationLevel AuditLogChange = "verification_level" // guild integer required verification level changed AuditLogChangeExplicitContentFilter AuditLogChange = "explicit_content_filter" // guild integer change in whose messages are scanned and deleted for explicit content in the server AuditLogChangeDefaultMessageNotifications AuditLogChange = "default_message_notifications" // guild integer default message notification level changed AuditLogChangeVanityURLCode AuditLogChange = "vanity_url_code" // guild string guild invite vanity url changed AuditLogChangeAdd AuditLogChange = "$add" // add guild array of role objects new role added AuditLogChangeRemove AuditLogChange = "$remove" // remove guild array of role objects role removed AuditLogChangePruneDeleteDays AuditLogChange = "prune_delete_days" // guild integer change in number of days after which inactive and role-unassigned members are kicked AuditLogChangeWidgetEnabled AuditLogChange = "widget_enabled" // guild bool server widget enabled/disable AuditLogChangeWidgetChannelID AuditLogChange = "widget_channel_id" // guild snowflake channel id of the server widget changed AuditLogChangePosition AuditLogChange = "position" // channel integer text or voice channel position changed AuditLogChangeTopic AuditLogChange = "topic" // channel string text channel topic changed AuditLogChangeBitrate AuditLogChange = "bitrate" // channel integer voice channel bitrate changed AuditLogChangePermissionOverwrites AuditLogChange = "permission_overwrites" // channel array of channel overwrite objects permissions on a channel changed AuditLogChangeNSFW AuditLogChange = "nsfw" // channel bool channel nsfw restriction changed AuditLogChangeApplicationID AuditLogChange = "application_id" // channel snowflake application id of the added or removed webhook or bot AuditLogChangePermissions AuditLogChange = "permissions" // role integer permissions for a role changed AuditLogChangeColor AuditLogChange = "color" // role integer role color changed AuditLogChangeHoist AuditLogChange = "hoist" // role bool role is now displayed/no longer displayed separate from online users AuditLogChangeMentionable AuditLogChange = "mentionable" // role bool role is now mentionable/unmentionable AuditLogChangeAllow AuditLogChange = "allow" // role integer a permission on a text or voice channel was allowed for a role AuditLogChangeDeny AuditLogChange = "deny" // role integer a permission on a text or voice channel was denied for a role AuditLogChangeCode AuditLogChange = "code" // invite string invite code changed AuditLogChangeChannelID AuditLogChange = "channel_id" // invite snowflake channel for invite code changed AuditLogChangeInviterID AuditLogChange = "inviter_id" // invite snowflake person who created invite code changed AuditLogChangeMaxUses AuditLogChange = "max_uses" // invite integer change to max number of times invite code can be used AuditLogChangeUses AuditLogChange = "uses" // invite integer number of times invite code used changed AuditLogChangeMaxAge AuditLogChange = "max_age" // invite integer how long invite code lasts changed AuditLogChangeTemporary AuditLogChange = "temporary" // invite bool invite code is temporary/never expires AuditLogChangeDeaf AuditLogChange = "deaf" // user bool user server deafened/undeafened AuditLogChangeMute AuditLogChange = "mute" // user bool user server muted/unmuteds AuditLogChangeNick AuditLogChange = "nick" // user string user nickname changed AuditLogChangeAvatarHash AuditLogChange = "avatar_hash" // user string user avatar changed AuditLogChangeID AuditLogChange = "id" // any snowflake the id of the changed entity - sometimes used in conjunction with other keys AuditLogChangeType AuditLogChange = "type" // any integer (channel type) or string type of entity created )
all the different keys for an audit log change
type AuditLogChanges ¶ added in v0.16.6
type AuditLogChanges struct { Lockable `json:"-"` NewValue interface{} `json:"new_value,omitempty"` OldValue interface{} `json:"old_value,omitempty"` Key string `json:"key"` }
AuditLogChanges ...
func (*AuditLogChanges) CopyOverTo ¶ added in v0.16.6
func (l *AuditLogChanges) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogChanges) DeepCopy ¶ added in v0.16.6
func (l *AuditLogChanges) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLogEntry ¶ added in v0.16.6
type AuditLogEntry struct { Lockable `json:"-"` TargetID Snowflake `json:"target_id"` Changes []*AuditLogChanges `json:"changes,omitempty"` UserID Snowflake `json:"user_id"` ID Snowflake `json:"id"` Event AuditLogEvt `json:"action_type"` Options *AuditLogOption `json:"options,omitempty"` Reason string `json:"reason,omitempty"` }
AuditLogEntry ...
func (*AuditLogEntry) CopyOverTo ¶ added in v0.16.6
func (l *AuditLogEntry) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogEntry) DeepCopy ¶ added in v0.16.6
func (l *AuditLogEntry) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AuditLogEvt ¶ added in v0.16.6
type AuditLogEvt uint
const ( AuditLogEvtChannelCreate AuditLogEvt = 10 + iota AuditLogEvtChannelUpdate AuditLogEvtChannelDelete AuditLogEvtOverwriteCreate AuditLogEvtOverwriteUpdate AuditLogEvtOverwriteDelete )
const ( AuditLogEvtMemberKick AuditLogEvt = 20 + iota AuditLogEvtMemberPrune AuditLogEvtMemberBanAdd AuditLogEvtMemberBanRemove AuditLogEvtMemberUpdate AuditLogEvtMemberRoleUpdate )
const ( AuditLogEvtRoleCreate AuditLogEvt = 30 + iota AuditLogEvtRoleUpdate AuditLogEvtRoleDelete )
const ( AuditLogEvtInviteCreate AuditLogEvt = 40 AuditLogEvtInviteUpdate AuditLogEvtInviteDelete )
const ( AuditLogEvtWebhookCreate AuditLogEvt = 50 + iota AuditLogEvtWebhookUpdate AuditLogEvtWebhookDelete )
const ( AuditLogEvtEmojiCreate AuditLogEvt = 60 + iota AuditLogEvtEmojiUpdate AuditLogEvtEmojiDelete )
const (
AuditLogEvtGuildUpdate AuditLogEvt = 1
)
Audit-log event types
const (
AuditLogEvtMessageDelete AuditLogEvt = 72
)
type AuditLogOption ¶ added in v0.16.6
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.16.6
func (l *AuditLogOption) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*AuditLogOption) DeepCopy ¶ added in v0.16.6
func (l *AuditLogOption) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type AvatarParamHolder ¶ added in v0.16.6
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.16.6
Ban https://discord.com/developers/docs/resources/guild#ban-object
func (*Ban) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type BanMemberParams ¶ added in v0.16.6
type BanMemberParams struct { DeleteMessageDays int `urlparam:"delete_message_days,omitempty"` // number of days to delete messages for (0-7) Reason string `urlparam:"reason,omitempty"` // reason for being banned }
BanMemberParams ... https://discord.com/developers/docs/resources/guild#create-guild-ban-query-string-params
func (*BanMemberParams) FindErrors ¶ added in v0.16.6
func (b *BanMemberParams) FindErrors() error
func (*BanMemberParams) URLQueryString ¶ added in v0.16.6
func (b *BanMemberParams) URLQueryString() string
type BodyUserCreateDM ¶ added in v0.16.6
type BodyUserCreateDM struct {
RecipientID Snowflake `json:"recipient_id"`
}
BodyUserCreateDM JSON param for func CreateDM
type Cache ¶ added in v0.16.6
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.16.6
func (*Cache) AddGuildMember ¶ added in v0.16.6
func (*Cache) AddGuildRole ¶ added in v0.16.6
func (*Cache) DeleteChannel ¶ added in v0.16.6
DeleteChannel ...
func (*Cache) DeleteChannelPermissionOverwrite ¶ added in v0.16.6
func (*Cache) DeleteGuild ¶ added in v0.16.6
DeleteGuild ...
func (*Cache) DeleteGuildChannel ¶ added in v0.16.6
DeleteGuildChannel removes a channel from a cached guild object without removing the guild
func (*Cache) DeleteGuildEmoji ¶ added in v0.16.6
func (*Cache) DeleteGuildRole ¶ added in v0.16.6
DeleteGuildRole removes a role from a cached guild object without removing the guild
func (*Cache) DirectUpdate ¶ added in v0.16.6
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.16.6
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.16.6
GetChannel ...
func (*Cache) GetGuildEmojis ¶ added in v0.16.6
GetGuildRoles ...
func (*Cache) GetGuildMember ¶ added in v0.16.6
GetGuildMember ...
func (*Cache) GetGuildMembersAfter ¶ added in v0.16.6
func (c *Cache) GetGuildMembersAfter(guildID, after Snowflake, limit int) (members []*Member, err error)
GetGuildMembersAfter ...
func (*Cache) GetGuildRoles ¶ added in v0.16.6
GetGuildRoles ...
func (*Cache) GetVoiceState ¶ added in v0.16.6
func (c *Cache) GetVoiceState(guildID Snowflake, params *guildVoiceStateCacheParams) (state *VoiceState, err error)
GetVoiceState ...
func (*Cache) RemoveGuildMember ¶ added in v0.16.6
func (*Cache) SetChannel ¶ added in v0.16.6
SetChannel adds a new channel to cacheLink or updates an existing one
func (*Cache) SetGuild ¶ added in v0.16.6
SetGuild adds a new guild to cacheLink or updates an existing one
func (*Cache) SetGuildEmojis ¶ added in v0.16.6
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.16.6
SetGuildMember calls SetGuildMembers
func (*Cache) SetGuildMembers ¶ added in v0.16.6
SetGuildMembers adds the members to a guild or updates an existing guild
func (*Cache) SetGuildRoles ¶ added in v0.16.6
SetGuildRoles creates a new guild if none is found and updates the roles for a given guild
func (*Cache) SetUser ¶ added in v0.16.6
SetUser updates an existing user or adds a new one to the cacheLink
func (*Cache) SetVoiceState ¶ added in v0.16.6
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.16.6
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.16.6
UpdateChannelLastMessageID ...
func (*Cache) UpdateChannelPin ¶ added in v0.16.6
UpdateChannelPin ...
func (*Cache) UpdateGuildRole ¶ added in v0.16.6
func (*Cache) UpdateMemberAndUser ¶ added in v0.16.6
func (c *Cache) UpdateMemberAndUser(guildID, userID Snowflake, data json.RawMessage)
func (*Cache) UpdateOrAddGuildMembers ¶ added in v0.16.6
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.16.6
type CacheConfig struct { Mutable bool // Must be immutable to support concurrent access and long-running tasks(!) DisableUserCaching bool UserCacheMaxEntries uint UserCacheLifetime time.Duration DisableVoiceStateCaching bool VoiceStateCacheMaxEntries uint VoiceStateCacheLifetime time.Duration DisableChannelCaching bool ChannelCacheMaxEntries uint ChannelCacheLifetime time.Duration DisableGuildCaching bool GuildCacheMaxEntries uint GuildCacheLifetime time.Duration // Deprecated UserCacheAlgorithm string // Deprecated VoiceStateCacheAlgorithm string // Deprecated ChannelCacheAlgorithm string // Deprecated GuildCacheAlgorithm string }
CacheConfig allows for tweaking the cacheLink system on a personal need
type Cacher ¶ added in v0.16.6
type Cacher interface { Update(key cacheRegistry, v interface{}) (err error) Get(key cacheRegistry, id Snowflake, args ...interface{}) (v interface{}, err error) DeleteChannel(channelID Snowflake) DeleteGuildChannel(guildID Snowflake, channelID Snowflake) AddGuildChannel(guildID Snowflake, channelID Snowflake) AddGuildMember(guildID Snowflake, member *Member) RemoveGuildMember(guildID Snowflake, memberID Snowflake) UpdateChannelPin(channelID Snowflake, lastPinTimestamp Time) UpdateMemberAndUser(guildID, userID Snowflake, data json.RawMessage) DeleteGuild(guildID Snowflake) DeleteGuildRole(guildID Snowflake, roleID Snowflake) UpdateChannelLastMessageID(channelID Snowflake, messageID Snowflake) 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.16.6
type Channel struct { Lockable `json:"-"` ID Snowflake `json:"id"` Type uint `json:"type"` GuildID Snowflake `json:"guild_id,omitempty"` // ?| Position int `json:"position,omitempty"` // ?| can be less than 0 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 Time `json:"last_pin_timestamp,omitempty"` // ?| // contains filtered or unexported fields }
Channel ...
func (*Channel) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Channel) DeepCopy ¶ added in v0.16.6
func (c *Channel) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Channel) Mention ¶ added in v0.16.6
Mention creates a channel mention string. Mention format is according the Discord protocol.
func (*Channel) SendMsg ¶ added in v0.16.6
func (c *Channel) SendMsg(ctx context.Context, client MessageSender, message *Message) (msg *Message, err error)
SendMsg sends a message to a channel
func (*Channel) SendMsgString ¶ added in v0.16.6
func (c *Channel) SendMsgString(ctx context.Context, 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.16.6
type ChannelCreate struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelCreate new channel created
func (*ChannelCreate) UnmarshalJSON ¶ added in v0.16.6
func (obj *ChannelCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelCreateHandler ¶ added in v0.16.6
type ChannelCreateHandler = func(s Session, h *ChannelCreate)
ChannelCreateHandler is triggered in ChannelCreate events
type ChannelDelete ¶ added in v0.16.6
type ChannelDelete struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelDelete channel was deleted
func (*ChannelDelete) UnmarshalJSON ¶ added in v0.16.6
func (obj *ChannelDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelDeleteHandler ¶ added in v0.16.6
type ChannelDeleteHandler = func(s Session, h *ChannelDelete)
ChannelDeleteHandler is triggered in ChannelDelete events
type ChannelFetcher ¶ added in v0.16.6
ChannelFetcher holds the single method for fetching a channel from the Discord REST API
type ChannelPinsUpdate ¶ added in v0.16.6
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 Time `json:"last_pin_timestamp,omitempty"` // ?| Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelPinsUpdate message was pinned or unpinned
type ChannelPinsUpdateHandler ¶ added in v0.16.6
type ChannelPinsUpdateHandler = func(s Session, h *ChannelPinsUpdate)
ChannelPinsUpdateHandler is triggered in ChannelPinsUpdate events
type ChannelUpdate ¶ added in v0.16.6
type ChannelUpdate struct { Channel *Channel `json:"channel"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
ChannelUpdate channel was updated
func (*ChannelUpdate) UnmarshalJSON ¶ added in v0.16.6
func (obj *ChannelUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelUpdateHandler ¶ added in v0.16.6
type ChannelUpdateHandler = func(s Session, h *ChannelUpdate)
ChannelUpdateHandler is triggered in ChannelUpdate events
type Client ¶
Client is the main disgord Client to hold your state and data. You must always initiate it using the constructor methods (eg. New(..) or NewClient(..)).
Note that this Client holds all the REST methods, and is split across files, into whatever category the REST methods regards.
func NewClient ¶
NewClient creates a new Disgord Client and returns an error on configuration issues
func (*Client) AddDMParticipant ¶ added in v0.16.6
func (c *Client) AddDMParticipant(ctx context.Context, channelID Snowflake, participant *GroupDMParticipant, flags ...Flag) error
AddDMParticipant [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} Discord documentation https://discord.com/developers/docs/resources/channel#group-dm-add-recipient Reviewed 2018-06-10 Comment -
func (*Client) AddGuildMember ¶
func (c *Client) AddGuildMember(ctx context.Context, guildID, userID Snowflake, accessToken string, params *AddGuildMemberParams, flags ...Flag) (member *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} Discord documentation https://discord.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 (*Client) AddGuildMemberRole ¶
func (c *Client) AddGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#add-guild-member-role Reviewed 2018-08-18 Comment -
func (*Client) AddPermission ¶ added in v0.16.6
func (c *Client) AddPermission(permission PermissionBit) (updatedPermissions PermissionBits)
AddPermission adds a minimum required permission to the bot. If the permission is negative, it is overwritten to 0. This is useful for creating the bot URL.
At the moment, this holds no other effect than aesthetics.
func (*Client) AvgHeartbeatLatency ¶ added in v0.16.6
AvgHeartbeatLatency checks the duration of waiting before receiving a response from Discord when a heartbeat packet was sent. Note that heartbeats are usually sent around once a minute and is not a accurate way to measure delay between the Client and Discord server
func (*Client) BanMember ¶ added in v0.16.6
func (c *Client) BanMember(ctx context.Context, guildID, userID Snowflake, params *BanMemberParams, flags ...Flag) (err error)
BanMember [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 Create Gateway event.
Method PUT Endpoint /guilds/{guild.id}/bans/{user.id} Discord documentation https://discord.com/developers/docs/resources/guild#create-guild-ban Reviewed 2018-08-18 Comment -
func (*Client) CreateChannelInvites ¶
func (c *Client) CreateChannelInvites(ctx context.Context, channelID Snowflake, params *CreateChannelInvitesParams, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/channel#create-channel-invite Reviewed 2018-06-07 Comment -
func (*Client) CreateDM ¶
func (c *Client) CreateDM(ctx context.Context, recipientID Snowflake, flags ...Flag) (ret *Channel, err error)
CreateDM [REST] Create a new DM channel with a user. Returns a DM channel object.
Method POST Endpoint /users/@me/channels Discord documentation https://discord.com/developers/docs/resources/user#create-dm Reviewed 2019-02-23 Comment -
func (*Client) CreateGroupDM ¶
func (c *Client) CreateGroupDM(ctx context.Context, params *CreateGroupDMParams, flags ...Flag) (ret *Channel, err error)
CreateGroupDM [REST] Create a new group DM channel with multiple users. Returns a DM channel object. This endpoint was intended to be used with the now-deprecated GameBridge SDK. DMs created with this endpoint will not be shown in the Discord Client
Method POST Endpoint /users/@me/channels Discord documentation https://discord.com/developers/docs/resources/user#create-group-dm Reviewed 2019-02-19 Comment -
func (*Client) CreateGuild ¶
func (c *Client) CreateGuild(ctx context.Context, guildName string, params *CreateGuildParams, flags ...Flag) (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 Discord documentation https://discord.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. The params argument is optional.
func (*Client) CreateGuildChannel ¶
func (c *Client) CreateGuildChannel(ctx context.Context, guildID Snowflake, channelName string, params *CreateGuildChannelParams, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#create-guild-channel Reviewed 2018-08-17 Comment All parameters for this endpoint. are optional excluding 'name'
func (*Client) CreateGuildEmoji ¶
func (c *Client) CreateGuildEmoji(ctx context.Context, guildID Snowflake, params *CreateGuildEmojiParams, flags ...Flag) (emoji *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 Discord documentation https://discord.com/developers/docs/resources/emoji#create-guild-emoji Reviewed 2019-02-20 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 (*Client) CreateGuildIntegration ¶
func (c *Client) CreateGuildIntegration(ctx context.Context, guildID Snowflake, params *CreateGuildIntegrationParams, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#create-guild-integration Reviewed 2018-08-18 Comment -
func (*Client) CreateGuildRole ¶
func (c *Client) CreateGuildRole(ctx context.Context, id Snowflake, params *CreateGuildRoleParams, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#create-guild-role Reviewed 2018-08-18 Comment All JSON params are optional.
func (*Client) CreateMessage ¶ added in v0.16.6
func (c *Client) CreateMessage(ctx context.Context, channelID Snowflake, params *CreateMessageParams, flags ...Flag) (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 Discord documentation https://discord.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 (*Client) CreateReaction ¶
func (c *Client) CreateReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, flags ...Flag) (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 Discord documentation https://discord.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 (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, channelID Snowflake, params *CreateWebhookParams, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/webhook#create-webhook Reviewed 2018-08-14 Comment -
func (*Client) DeleteAllReactions ¶
func (c *Client) DeleteAllReactions(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
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 Discord documentation https://discord.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 (*Client) DeleteChannel ¶
func (c *Client) DeleteChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (channel *Channel, err error)
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} Discord documentation https://discord.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 (*Client) DeleteChannelPermission ¶
func (c *Client) DeleteChannelPermission(ctx context.Context, channelID, overwriteID Snowflake, flags ...Flag) (err error)
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://discord.com/developers/docs/topics/permissions#permissions
Method DELETE Endpoint /channels/{channel.id}/permissions/{overwrite.id} Discord documentation https://discord.com/developers/docs/resources/channel#delete-channel-permission Reviewed 2018-06-07 Comment -
func (*Client) DeleteFromDiscord ¶ added in v0.16.6
func (c *Client) DeleteFromDiscord(ctx context.Context, obj discordDeleter, flags ...Flag) (err error)
DeleteFromDiscord if the given object has implemented the private interface discordDeleter this method can be used to delete said object.
func (*Client) DeleteGuild ¶
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} Discord documentation https://discord.com/developers/docs/resources/guild#delete-guild Reviewed 2018-08-17 Comment -
func (*Client) DeleteGuildEmoji ¶
func (c *Client) DeleteGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/emoji#delete-guild-emoji Reviewed 2018-06-10 Comment -
func (*Client) DeleteGuildIntegration ¶
func (c *Client) DeleteGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#delete-guild-integration Reviewed 2018-08-18 Comment -
func (*Client) DeleteGuildRole ¶
func (c *Client) DeleteGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#delete-guild-role Reviewed 2018-08-18 Comment -
func (*Client) DeleteInvite ¶
func (c *Client) DeleteInvite(ctx context.Context, inviteCode string, flags ...Flag) (deleted *Invite, err error)
DeleteInvite [REST] Delete an invite. Requires the MANAGE_CHANNELS permission. Returns an invite object on success.
Method DELETE Endpoint /invites/{invite.code} Discord documentation https://discord.com/developers/docs/resources/invite#delete-invite Reviewed 2018-06-10 Comment -
func (*Client) DeleteMessage ¶
func (c *Client) DeleteMessage(ctx context.Context, channelID, msgID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/channel#delete-message Reviewed 2018-06-10 Comment -
func (*Client) DeleteMessages ¶ added in v0.16.6
func (c *Client) DeleteMessages(ctx context.Context, chanID Snowflake, params *DeleteMessagesParams, flags ...Flag) (err error)
DeleteMessages [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 Discord documentation https://discord.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 (*Client) DeleteOwnReaction ¶
func (c *Client) DeleteOwnReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, flags ...Flag) (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 Discord documentation https://discord.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 (*Client) DeleteUserReaction ¶
func (c *Client) DeleteUserReaction(ctx context.Context, channelID, messageID, userID Snowflake, emoji interface{}, flags ...Flag) (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 Discord documentation https://discord.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 (*Client) DeleteWebhook ¶
DeleteWebhook [REST] Delete a webhook permanently. User must be owner. Returns a 204 NO CONTENT response on success.
Method DELETE Endpoint /webhooks/{webhook.id} Discord documentation https://discord.com/developers/docs/resources/webhook#delete-webhook Reviewed 2018-08-14 Comment -
func (*Client) DeleteWebhookWithToken ¶
func (c *Client) DeleteWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (err error)
DeleteWebhookWithToken [REST] Same as DeleteWebhook, except this call does not require authentication.
Method DELETE Endpoint /webhooks/{webhook.id}/{webhook.token} Discord documentation https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token Reviewed 2018-08-14 Comment -
func (*Client) Disconnect ¶
Disconnect closes the discord websocket connection
func (*Client) DisconnectOnInterrupt ¶ added in v0.16.6
DisconnectOnInterrupt wait until a termination signal is detected
func (*Client) Emit ¶ added in v0.16.6
func (c *Client) Emit(name gatewayCmdName, payload gatewayCmdPayload) (unchandledGuildIDs []Snowflake, err error)
Emit sends a socket command directly to Discord.
func (*Client) EstimatePruneMembersCount ¶ added in v0.16.6
func (c *Client) EstimatePruneMembersCount(ctx context.Context, id Snowflake, days int, flags ...Flag) (estimate int, err error)
EstimatePruneMembersCount [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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-prune-count Reviewed 2018-08-18 Comment -
func (*Client) ExecuteGitHubWebhook ¶
func (c *Client) ExecuteGitHubWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) (err error)
ExecuteGitHubWebhook [REST] Trigger a webhook in Discord from the GitHub app.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Discord documentation https://discord.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 (*Client) ExecuteSlackWebhook ¶
func (c *Client) ExecuteSlackWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) (err error)
ExecuteSlackWebhook [REST] Trigger a webhook in Discord from the Slack app.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Discord documentation https://discord.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 (*Client) ExecuteWebhook ¶
func (c *Client) ExecuteWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, URLSuffix string, flags ...Flag) (err error)
ExecuteWebhook [REST] Trigger a webhook in Discord.
Method POST Endpoint /webhooks/{webhook.id}/{webhook.token} Discord documentation https://discord.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.
func (*Client) GetChannel ¶
func (c *Client) GetChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (ret *Channel, err error)
GetChannel [REST] Get a channel by Snowflake. Returns a channel object.
Method GET Endpoint /channels/{channel.id} Discord documentation https://discord.com/developers/docs/resources/channel#get-channel Reviewed 2018-06-07 Comment -
func (*Client) GetChannelInvites ¶
func (c *Client) GetChannelInvites(ctx context.Context, channelID Snowflake, flags ...Flag) (invites []*Invite, err error)
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 Discord documentation https://discord.com/developers/docs/resources/channel#get-channel-invites Reviewed 2018-06-07 Comment -
func (*Client) GetChannelWebhooks ¶
func (c *Client) GetChannelWebhooks(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Webhook, err error)
GetChannelWebhooks [REST] Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission.
Method POST Endpoint /channels/{channel.id}/webhooks Discord documentation https://discord.com/developers/docs/resources/webhook#get-channel-webhooks Reviewed 2018-08-14 Comment -
func (*Client) GetConnectedGuilds ¶ added in v0.16.6
GetConnectedGuilds get a list over guild IDs that this Client is "connected to"; or have joined through the ws connection. This will always hold the different Guild IDs, while the GetGuilds or GetCurrentUserGuilds might be affected by cache configuration.
func (*Client) GetCurrentUser ¶
GetCurrentUser [REST] Returns the user object of the requester's account. For OAuth2, this requires the identify scope, which will return the object without an email, and optionally the email scope, which returns the object with an email.
Method GET Endpoint /users/@me Discord documentation https://discord.com/developers/docs/resources/user#get-current-user Reviewed 2019-02-23 Comment -
func (*Client) GetCurrentUserGuilds ¶
func (c *Client) GetCurrentUserGuilds(ctx context.Context, params *GetCurrentUserGuildsParams, flags ...Flag) (ret []*PartialGuild, 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 Discord documentation https://discord.com/developers/docs/resources/user#get-current-user-guilds Reviewed 2019-02-18 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 (*Client) GetGateway ¶ added in v0.16.6
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 Discord documentation https://discord.com/developers/docs/topics/gateway#get-gateway Reviewed 2018-10-12 Comment This endpoint does not require authentication.
func (*Client) GetGatewayBot ¶ added in v0.16.6
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 Discord documentation https://discord.com/developers/docs/topics/gateway#get-gateway-bot Reviewed 2018-10-12 Comment This endpoint requires authentication using a valid bot token.
func (*Client) GetGuild ¶
func (c *Client) GetGuild(ctx context.Context, id Snowflake, flags ...Flag) (guild *Guild, err error)
GetGuild [REST] Returns the guild object for the given id.
Method GET Endpoint /guilds/{guild.id} Discord documentation https://discord.com/developers/docs/resources/guild#get-guild Reviewed 2018-08-17 Comment -
func (*Client) GetGuildAuditLogs ¶
func (c *Client) GetGuildAuditLogs(ctx context.Context, guildID Snowflake, flags ...Flag) (builder *guildAuditLogsBuilder)
GetGuildAuditLogs [REST] Returns an audit log object for the guild. Requires the 'VIEW_AUDIT_LOG' permission. Note that this request will _always_ send a REST request, regardless of you calling IgnoreCache or not.
Method GET Endpoint /guilds/{guild.id}/audit-logs Discord documentation https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log Reviewed 2018-06-05 Comment - Note Check the last entry in the cacheLink, to avoid fetching data we already got
func (*Client) GetGuildBan ¶
func (c *Client) GetGuildBan(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (ret *Ban, err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-ban Reviewed 2018-08-18 Comment -
func (*Client) GetGuildBans ¶
func (c *Client) GetGuildBans(ctx context.Context, id Snowflake, flags ...Flag) (bans []*Ban, err error)
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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-bans Reviewed 2018-08-18 Comment -
func (*Client) GetGuildChannels ¶
func (c *Client) GetGuildChannels(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Channel, err error)
GetGuildChannels [REST] Returns a list of guild channel objects.
Method GET Endpoint /guilds/{guild.id}/channels Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-channels Reviewed 2018-08-17 Comment -
func (*Client) GetGuildEmbed ¶
func (c *Client) GetGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) (embed *GuildEmbed, err error)
GetGuildEmbed [REST] Returns the guild embed object. Requires the 'MANAGE_GUILD' permission.
Method GET Endpoint /guilds/{guild.id}/embed Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-embed Reviewed 2018-08-18 Comment -
func (*Client) GetGuildEmoji ¶
func (c *Client) GetGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (*Emoji, error)
GetGuildEmoji [REST] Returns an emoji object for the given guild and emoji IDs.
Method GET Endpoint /guilds/{guild.id}/emojis/{emoji.id} Discord documentation https://discord.com/developers/docs/resources/emoji#get-guild-emoji Reviewed 2019-02-20 Comment -
func (*Client) GetGuildEmojis ¶
func (c *Client) GetGuildEmojis(ctx context.Context, guildID Snowflake, flags ...Flag) (emojis []*Emoji, err error)
GetGuildEmojis [REST] Returns a list of emoji objects for the given guild.
Method GET Endpoint /guilds/{guild.id}/emojis Discord documentation https://discord.com/developers/docs/resources/emoji#list-guild-emojis Reviewed 2018-06-10 Comment -
func (*Client) GetGuildIntegrations ¶
func (c *Client) GetGuildIntegrations(ctx context.Context, id Snowflake, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-integrations Reviewed 2018-08-18 Comment -
func (*Client) GetGuildInvites ¶
func (c *Client) GetGuildInvites(ctx context.Context, id Snowflake, flags ...Flag) (ret []*Invite, err error)
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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-invites Reviewed 2018-08-18 Comment -
func (*Client) GetGuildRoles ¶
func (c *Client) GetGuildRoles(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Role, err error)
GetGuildRoles [REST] Returns a list of role objects for the guild.
Method GET Endpoint /guilds/{guild.id}/roles Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-roles Reviewed 2018-08-18 Comment -
func (*Client) GetGuildVanityURL ¶
func (c *Client) GetGuildVanityURL(ctx context.Context, guildID Snowflake, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-vanity-url Reviewed 2018-08-18 Comment -
func (*Client) GetGuildVoiceRegions ¶
func (c *Client) GetGuildVoiceRegions(ctx context.Context, id Snowflake, flags ...Flag) (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 Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-voice-regions Reviewed 2018-08-18 Comment -
func (*Client) GetGuildWebhooks ¶
func (c *Client) GetGuildWebhooks(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Webhook, err error)
GetGuildWebhooks [REST] Returns a list of guild webhook objects. Requires the 'MANAGE_WEBHOOKS' permission.
Method GET Endpoint /guilds/{guild.id}/webhooks Discord documentation https://discord.com/developers/docs/resources/webhook#get-guild-webhooks Reviewed 2018-08-14 Comment -
func (*Client) GetInvite ¶
func (c *Client) GetInvite(ctx context.Context, inviteCode string, params URLQueryStringer, flags ...Flag) (invite *Invite, err error)
GetInvite [REST] Returns an invite object for the given code.
Method GET Endpoint /invites/{invite.code} Discord documentation https://discord.com/developers/docs/resources/invite#get-invite Reviewed 2018-06-10 Comment - withMemberCount: whether or not the invite should contain the approximate number of members
func (*Client) GetMember ¶ added in v0.16.6
func (c *Client) GetMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (ret *Member, err error)
GetMember [REST] Returns a guild member object for the specified user.
Method GET Endpoint /guilds/{guild.id}/members/{user.id} Discord documentation https://discord.com/developers/docs/resources/guild#get-guild-member Reviewed 2018-08-17 Comment -
func (*Client) GetMemberPermissions ¶ added in v0.16.6
func (c *Client) GetMemberPermissions(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (permissions PermissionBits, err error)
GetMemberPermissions populates a uint64 with all the permission flags
func (*Client) GetMembers ¶ added in v0.16.6
func (c *Client) GetMembers(ctx context.Context, guildID Snowflake, params *GetMembersParams, flags ...Flag) (members []*Member, err error)
GetMembers uses the GetGuildMembers endpoint iteratively until the your restriction/query params are met.
func (*Client) GetMessage ¶ added in v0.16.6
func (c *Client) GetMessage(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (message *Message, err error)
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} Discord documentation https://discord.com/developers/docs/resources/channel#get-channel-message Reviewed 2018-06-10 Comment -
func (*Client) GetMessages ¶ added in v0.16.6
func (c *Client) GetMessages(ctx context.Context, channelID Snowflake, filter *GetMessagesParams, flags ...Flag) (messages []*Message, err error)
GetMessages bypasses discord limitations and iteratively fetches messages until the set filters are met.
func (*Client) GetPermissions ¶ added in v0.16.6
func (c *Client) GetPermissions() (permissions PermissionBits)
GetPermissions returns the minimum bot requirements.
func (*Client) GetPinnedMessages ¶
func (c *Client) GetPinnedMessages(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Message, err error)
GetPinnedMessages [REST] Returns all pinned messages in the channel as an array of message objects.
Method GET Endpoint /channels/{channel.id}/pins Discord documentation https://discord.com/developers/docs/resources/channel#get-pinned-messages Reviewed 2018-06-10 Comment -
func (*Client) GetReaction ¶
func (c *Client) GetReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, params URLQueryStringer, flags ...Flag) (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} Discord documentation https://discord.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 (*Client) GetUser ¶
GetUser [REST] Returns a user object for a given user Snowflake.
Method GET Endpoint /users/{user.id} Discord documentation https://discord.com/developers/docs/resources/user#get-user Reviewed 2018-06-10 Comment -
func (*Client) GetUserConnections ¶
func (c *Client) GetUserConnections(ctx context.Context, flags ...Flag) (connections []*UserConnection, err error)
GetUserConnections [REST] Returns a list of connection objects. Requires the connections OAuth2 scope.
Method GET Endpoint /users/@me/connections Discord documentation https://discord.com/developers/docs/resources/user#get-user-connections Reviewed 2019-02-19 Comment -
func (*Client) GetUserDMs ¶
GetUserDMs [REST] Returns a list of DM channel objects.
Method GET Endpoint /users/@me/channels Discord documentation https://discord.com/developers/docs/resources/user#get-user-dms Reviewed 2019-02-19 Comment Apparently Discord removed support for this in 2016 and updated their docs 2 years after.. https://github.com/discord/discord-api-docs/issues/184 For now I'll just leave this here, until I can do a cache lookup. Making this cache dependent.
Deprecated: Needs cache checking to get the actual list of channels
func (*Client) GetVoiceRegions ¶
func (c *Client) GetVoiceRegions(ctx context.Context, flags ...Flag) (regions []*VoiceRegion, err error)
GetVoiceRegionsBuilder [REST] Returns an array of voice region objects that can be used when creating servers.
Method GET Endpoint /voice/regions Discord documentation https://discord.com/developers/docs/resources/voice#list-voice-regions Reviewed 2018-08-21 Comment -
func (*Client) GetWebhook ¶
func (c *Client) GetWebhook(ctx context.Context, id Snowflake, flags ...Flag) (ret *Webhook, err error)
GetWebhook [REST] Returns the new webhook object for the given id.
Method GET Endpoint /webhooks/{webhook.id} Discord documentation https://discord.com/developers/docs/resources/webhook#get-webhook Reviewed 2018-08-14 Comment -
func (*Client) GetWebhookWithToken ¶
func (c *Client) GetWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (ret *Webhook, err error)
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} Discord documentation https://discord.com/developers/docs/resources/webhook#get-webhook-with-token Reviewed 2018-08-14 Comment -
func (*Client) GuildsReady ¶ added in v0.16.6
func (c *Client) GuildsReady(cb func())
GuildsReady is triggered once all unavailable guilds given in the READY event has loaded from their respective GUILD_CREATE events.
func (*Client) HeartbeatLatencies ¶ added in v0.16.6
HeartbeatLatencies returns latencies mapped to each shard, by their respective ID. shardID => latency.
func (*Client) InviteURL ¶ added in v0.16.6
InviteURL creates a URL that can be used to invite this bot to a guild/server. Note that it depends on the bot ID to be after the Discord update where the Client ID is the same as the Bot ID.
By default the permissions will be 0, as in none. If you want to add/set the minimum required permissions for your bot to run successfully, you should utilise
Client.
func (*Client) KickMember ¶ added in v0.16.6
func (c *Client) KickMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#remove-guild-member Reviewed 2018-08-18 Comment -
func (*Client) KickParticipant ¶ added in v0.16.6
func (c *Client) KickParticipant(ctx context.Context, channelID, userID Snowflake, flags ...Flag) (err error)
KickParticipant [REST] Removes a recipient from a Group DM. Returns a 204 empty response on success.
Method DELETE Endpoint /channels/{channel.id}/recipients/{user.id} Discord documentation https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient Reviewed 2018-06-10 Comment -
func (*Client) KickVoiceParticipant ¶ added in v0.16.6
func (*Client) LeaveGuild ¶
LeaveGuild [REST] Leave a guild. Returns a 204 empty response on success.
Method DELETE Endpoint /users/@me/guilds/{guild.id} Discord documentation https://discord.com/developers/docs/resources/user#leave-guild Reviewed 2019-02-18 Comment -
func (*Client) Logger ¶ added in v0.16.6
Logger returns the log instance of Disgord. Note that this instance is never nil. When the conf.Logger is not assigned an empty struct is used instead. Such that all calls are simply discarded at compile time removing the need for nil checks.
func (*Client) Myself ¶ added in v0.16.6
Myself get the current user / connected user Deprecated: use GetCurrentUser instead
func (*Client) On ¶ added in v0.16.6
On creates a specification to be executed on the given event. The specification consists of, in order, 0 or more middlewares, 1 or more handlers, 0 or 1 controller. On incorrect ordering, or types, the method will panic. See reactor.go for types.
Each of the three sub-types of a specification is run in sequence, as well as the specifications registered for a event. However, the slice of specifications are executed in a goroutine to avoid blocking future events. The middlewares allows manipulating the event data before it reaches the handlers. The handlers executes short-running logic based on the event data (use go routine if you need a long running task). The controller dictates lifetime of the specification.
// a handler that is executed on every Ready event Client.On(EvtReady, onReady) // a handler that runs only the first three times a READY event is fired Client.On(EvtReady, onReady, &Ctrl{Runs: 3}) // a handler that only runs for events within the first 10 minutes Client.On(EvtReady, onReady, &Ctrl{Duration: 10*time.Minute})
Another example is to create a voting system where you specify a deadline instead of a Runs counter:
On("MESSAGE_CREATE", mdlwHasMentions, handleMsgsWithMentions, saveVoteToDB, &Ctrl{Until:time.Now().Add(time.Hour)})
You can use your own Ctrl struct, as long as it implements disgord.HandlerCtrl. Do not execute long running tasks in the methods. Use a go routine instead.
If the HandlerCtrl.OnInsert returns an error, the related handlers are still added to the dispatcher. But the error is logged to the injected logger instance (log.Error).
This ctrl feature was inspired by https://github.com/discordjs/discord.js
func (*Client) OnChannelCreate ¶ added in v0.16.6
func (c *Client) OnChannelCreate(mdlws []Middleware, handlers []HandlerChannelCreate, ctrl ...HandlerCtrl)
func (*Client) OnChannelDelete ¶ added in v0.16.6
func (c *Client) OnChannelDelete(mdlws []Middleware, handlers []HandlerChannelDelete, ctrl ...HandlerCtrl)
func (*Client) OnChannelPinsUpdate ¶ added in v0.16.6
func (c *Client) OnChannelPinsUpdate(mdlws []Middleware, handlers []HandlerChannelPinsUpdate, ctrl ...HandlerCtrl)
func (*Client) OnChannelUpdate ¶ added in v0.16.6
func (c *Client) OnChannelUpdate(mdlws []Middleware, handlers []HandlerChannelUpdate, ctrl ...HandlerCtrl)
func (*Client) OnGuildBanAdd ¶ added in v0.16.6
func (c *Client) OnGuildBanAdd(mdlws []Middleware, handlers []HandlerGuildBanAdd, ctrl ...HandlerCtrl)
func (*Client) OnGuildBanRemove ¶ added in v0.16.6
func (c *Client) OnGuildBanRemove(mdlws []Middleware, handlers []HandlerGuildBanRemove, ctrl ...HandlerCtrl)
func (*Client) OnGuildCreate ¶ added in v0.16.6
func (c *Client) OnGuildCreate(mdlws []Middleware, handlers []HandlerGuildCreate, ctrl ...HandlerCtrl)
func (*Client) OnGuildDelete ¶ added in v0.16.6
func (c *Client) OnGuildDelete(mdlws []Middleware, handlers []HandlerGuildDelete, ctrl ...HandlerCtrl)
func (*Client) OnGuildEmojisUpdate ¶ added in v0.16.6
func (c *Client) OnGuildEmojisUpdate(mdlws []Middleware, handlers []HandlerGuildEmojisUpdate, ctrl ...HandlerCtrl)
func (*Client) OnGuildIntegrationsUpdate ¶ added in v0.16.6
func (c *Client) OnGuildIntegrationsUpdate(mdlws []Middleware, handlers []HandlerGuildIntegrationsUpdate, ctrl ...HandlerCtrl)
func (*Client) OnGuildMemberAdd ¶ added in v0.16.6
func (c *Client) OnGuildMemberAdd(mdlws []Middleware, handlers []HandlerGuildMemberAdd, ctrl ...HandlerCtrl)
func (*Client) OnGuildMemberRemove ¶ added in v0.16.6
func (c *Client) OnGuildMemberRemove(mdlws []Middleware, handlers []HandlerGuildMemberRemove, ctrl ...HandlerCtrl)
func (*Client) OnGuildMemberUpdate ¶ added in v0.16.6
func (c *Client) OnGuildMemberUpdate(mdlws []Middleware, handlers []HandlerGuildMemberUpdate, ctrl ...HandlerCtrl)
func (*Client) OnGuildMembersChunk ¶ added in v0.16.6
func (c *Client) OnGuildMembersChunk(mdlws []Middleware, handlers []HandlerGuildMembersChunk, ctrl ...HandlerCtrl)
func (*Client) OnGuildRoleCreate ¶ added in v0.16.6
func (c *Client) OnGuildRoleCreate(mdlws []Middleware, handlers []HandlerGuildRoleCreate, ctrl ...HandlerCtrl)
func (*Client) OnGuildRoleDelete ¶ added in v0.16.6
func (c *Client) OnGuildRoleDelete(mdlws []Middleware, handlers []HandlerGuildRoleDelete, ctrl ...HandlerCtrl)
func (*Client) OnGuildRoleUpdate ¶ added in v0.16.6
func (c *Client) OnGuildRoleUpdate(mdlws []Middleware, handlers []HandlerGuildRoleUpdate, ctrl ...HandlerCtrl)
func (*Client) OnGuildUpdate ¶ added in v0.16.6
func (c *Client) OnGuildUpdate(mdlws []Middleware, handlers []HandlerGuildUpdate, ctrl ...HandlerCtrl)
func (*Client) OnInviteCreate ¶ added in v0.16.6
func (c *Client) OnInviteCreate(mdlws []Middleware, handlers []HandlerInviteCreate, ctrl ...HandlerCtrl)
func (*Client) OnMessageCreate ¶ added in v0.16.6
func (c *Client) OnMessageCreate(mdlws []Middleware, handlers []HandlerMessageCreate, ctrl ...HandlerCtrl)
func (*Client) OnMessageDelete ¶ added in v0.16.6
func (c *Client) OnMessageDelete(mdlws []Middleware, handlers []HandlerMessageDelete, ctrl ...HandlerCtrl)
func (*Client) OnMessageDeleteBulk ¶ added in v0.16.6
func (c *Client) OnMessageDeleteBulk(mdlws []Middleware, handlers []HandlerMessageDeleteBulk, ctrl ...HandlerCtrl)
func (*Client) OnMessageReactionAdd ¶ added in v0.16.6
func (c *Client) OnMessageReactionAdd(mdlws []Middleware, handlers []HandlerMessageReactionAdd, ctrl ...HandlerCtrl)
func (*Client) OnMessageReactionRemove ¶ added in v0.16.6
func (c *Client) OnMessageReactionRemove(mdlws []Middleware, handlers []HandlerMessageReactionRemove, ctrl ...HandlerCtrl)
func (*Client) OnMessageReactionRemoveAll ¶ added in v0.16.6
func (c *Client) OnMessageReactionRemoveAll(mdlws []Middleware, handlers []HandlerMessageReactionRemoveAll, ctrl ...HandlerCtrl)
func (*Client) OnMessageUpdate ¶ added in v0.16.6
func (c *Client) OnMessageUpdate(mdlws []Middleware, handlers []HandlerMessageUpdate, ctrl ...HandlerCtrl)
func (*Client) OnPresenceUpdate ¶ added in v0.16.6
func (c *Client) OnPresenceUpdate(mdlws []Middleware, handlers []HandlerPresenceUpdate, ctrl ...HandlerCtrl)
func (*Client) OnReady ¶ added in v0.16.6
func (c *Client) OnReady(mdlws []Middleware, handlers []HandlerReady, ctrl ...HandlerCtrl)
func (*Client) OnResumed ¶ added in v0.16.6
func (c *Client) OnResumed(mdlws []Middleware, handlers []HandlerResumed, ctrl ...HandlerCtrl)
func (*Client) OnTypingStart ¶ added in v0.16.6
func (c *Client) OnTypingStart(mdlws []Middleware, handlers []HandlerTypingStart, ctrl ...HandlerCtrl)
func (*Client) OnUserUpdate ¶ added in v0.16.6
func (c *Client) OnUserUpdate(mdlws []Middleware, handlers []HandlerUserUpdate, ctrl ...HandlerCtrl)
func (*Client) OnVoiceServerUpdate ¶ added in v0.16.6
func (c *Client) OnVoiceServerUpdate(mdlws []Middleware, handlers []HandlerVoiceServerUpdate, ctrl ...HandlerCtrl)
func (*Client) OnVoiceStateUpdate ¶ added in v0.16.6
func (c *Client) OnVoiceStateUpdate(mdlws []Middleware, handlers []HandlerVoiceStateUpdate, ctrl ...HandlerCtrl)
func (*Client) OnWebhooksUpdate ¶ added in v0.16.6
func (c *Client) OnWebhooksUpdate(mdlws []Middleware, handlers []HandlerWebhooksUpdate, ctrl ...HandlerCtrl)
func (*Client) PinMessage ¶ added in v0.16.6
PinMessage see Client.PinMessageID
func (*Client) PinMessageID ¶ added in v0.16.6
func (c *Client) PinMessageID(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
PinMessageID [REST] Pin a message by its ID and channel ID. Requires the 'MANAGE_MESSAGES' permission. Returns a 204 empty response on success.
Method PUT Endpoint /channels/{channel.id}/pins/{message.id} Discord documentation https://discord.com/developers/docs/resources/channel#add-pinned-channel-message Reviewed 2018-06-10 Comment -
func (*Client) Pool ¶ added in v0.16.6
func (c *Client) Pool() *pools
////////////////////////////////////////////////////
METHODS ¶
////////////////////////////////////////////////////
func (*Client) PruneMembers ¶ added in v0.16.6
func (c *Client) PruneMembers(ctx context.Context, id Snowflake, days int, reason string, flags ...Flag) (err error)
PruneMembers [REST] Kicks members from N day back. Requires the 'KICK_MEMBERS' permission. The estimate of kicked people is not returned. Use EstimatePruneMembersCount before calling PruneMembers if you need it. Fires multiple Guild Member Remove Gateway events.
Method POST Endpoint /guilds/{guild.id}/prune Discord documentation https://discord.com/developers/docs/resources/guild#begin-guild-prune Reviewed 2018-08-18 Comment -
func (*Client) RESTBucketGrouping ¶ added in v0.16.6
@Deprecated: use Client.RESTRatelimitBuckets()
func (*Client) RESTRatelimitBuckets ¶ added in v0.16.6
RESTBucketGrouping shows which hashed endpoints belong to which bucket hash for the REST API. Note that these bucket hashes are eventual consistent.
func (*Client) Ready ¶ added in v0.16.6
func (c *Client) Ready(cb func())
Ready triggers a given callback when all shards has gotten their first Ready event Warning: Do not call Client.Connect before this.
func (*Client) RemoveGuildMemberRole ¶
func (c *Client) RemoveGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) (err error)
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} Discord documentation https://discord.com/developers/docs/resources/guild#remove-guild-member-role Reviewed 2018-08-18 Comment -
func (*Client) Req ¶
Req return the request object. Used in REST requests to handle rate limits, wrong http responses, etc.
func (*Client) SendMsg ¶ added in v0.16.6
func (c *Client) SendMsg(ctx context.Context, channelID Snowflake, data ...interface{}) (msg *Message, err error)
SendMsg should convert all inputs into a single message. If you supply a object with an ID such as a channel, message, role, etc. It will become a reference. If say the Message provided does not have an ID, the Message will populate a CreateMessage with it's fields.
If you want to affect the actual message data besides .Content; provide a MessageCreateParams. The reply message will be updated by the last one provided.
func (*Client) SetCurrentUserNick ¶ added in v0.16.6
func (c *Client) SetCurrentUserNick(ctx context.Context, id Snowflake, nick string, flags ...Flag) (newNick string, err error)
SetCurrentUserNick [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 Discord documentation https://discord.com/developers/docs/resources/guild#modify-current-user-nick Reviewed 2018-08-18 Comment -
func (*Client) SetMsgContent ¶ added in v0.16.6
func (*Client) SetMsgEmbed ¶ added in v0.16.6
func (*Client) StayConnectedUntilInterrupted ¶ added in v0.16.6
StayConnectedUntilInterrupted is a simple wrapper for connect, and disconnect that listens for system interrupts. When a error happens you can terminate the application without worries.
func (*Client) Suspend ¶ added in v0.16.6
Suspend in case you want to temporary disconnect from the Gateway. But plan on connecting again without restarting your software/application, this should be used.
func (*Client) SyncGuildIntegration ¶
func (c *Client) SyncGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) (err error)
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 Discord documentation https://discord.com/developers/docs/resources/guild#sync-guild-integration Reviewed 2018-08-18 Comment -
func (*Client) TriggerTypingIndicator ¶
func (c *Client) TriggerTypingIndicator(ctx context.Context, channelID Snowflake, flags ...Flag) (err error)
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 Discord documentation https://discord.com/developers/docs/resources/channel#trigger-typing-indicator Reviewed 2018-06-10 Comment -
func (*Client) UnbanMember ¶ added in v0.16.6
func (c *Client) UnbanMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) (err error)
UnbanMember [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} Discord documentation https://discord.com/developers/docs/resources/guild#remove-guild-ban Reviewed 2018-08-18 Comment -
func (*Client) UnpinMessage ¶ added in v0.16.6
UnpinMessage see Client.UnpinMessageID
func (*Client) UnpinMessageID ¶ added in v0.16.6
func (c *Client) UnpinMessageID(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error)
UnpinMessageID [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} Discord documentation https://discord.com/developers/docs/resources/channel#delete-pinned-channel-message Reviewed 2018-06-10 Comment -
func (*Client) UpdateChannel ¶ added in v0.16.6
func (c *Client) UpdateChannel(ctx context.Context, channelID Snowflake, flags ...Flag) (builder *updateChannelBuilder)
UpdateChannel [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} Discord documentation https://discord.com/developers/docs/resources/channel#modify-channel Reviewed 2018-06-07 Comment andersfylling: only implemented the patch method, as its parameters are optional.
func (*Client) UpdateChannelPermissions ¶ added in v0.16.6
func (c *Client) UpdateChannelPermissions(ctx context.Context, channelID, overwriteID Snowflake, params *UpdateChannelPermissionsParams, flags ...Flag) (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} Discord documentation https://discord.com/developers/docs/resources/channel#edit-channel-permissions Reviewed 2018-06-07 Comment -
func (*Client) UpdateCurrentUser ¶ added in v0.16.6
func (c *Client) UpdateCurrentUser(ctx context.Context, flags ...Flag) (builder *updateCurrentUserBuilder)
UpdateCurrentUser [REST] Modify the requester's user account settings. Returns a user object on success.
Method PATCH Endpoint /users/@me Discord documentation https://discord.com/developers/docs/resources/user#modify-current-user Reviewed 2019-02-18 Comment -
func (*Client) UpdateGuild ¶ added in v0.16.6
func (c *Client) UpdateGuild(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateGuildBuilder)
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} Discord documentation https://discord.com/developers/docs/resources/guild#modify-guild Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional
func (*Client) UpdateGuildChannelPositions ¶ added in v0.16.6
func (c *Client) UpdateGuildChannelPositions(ctx context.Context, guildID Snowflake, params []UpdateGuildChannelPositionsParams, flags ...Flag) (err error)
UpdateGuildChannelPositions [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 Discord documentation https://discord.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 (*Client) UpdateGuildEmbed ¶ added in v0.16.6
func (c *Client) UpdateGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) (builder *updateGuildEmbedBuilder)
UpdateGuildEmbed [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 Discord documentation https://discord.com/developers/docs/resources/guild#modify-guild-embed Reviewed 2018-08-18 Comment -
func (*Client) UpdateGuildEmoji ¶ added in v0.16.6
func (c *Client) UpdateGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (builder *updateGuildEmojiBuilder)
UpdateGuildEmoji [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} Discord documentation https://discord.com/developers/docs/resources/emoji#modify-guild-emoji Reviewed 2019-02-20 Comment -
func (*Client) UpdateGuildIntegration ¶ added in v0.16.6
func (c *Client) UpdateGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, params *UpdateGuildIntegrationParams, flags ...Flag) (err error)
UpdateGuildIntegration [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} Discord documentation https://discord.com/developers/docs/resources/guild#modify-guild-integration Reviewed 2018-08-18 Comment -
func (*Client) UpdateGuildMember ¶ added in v0.16.6
func (c *Client) UpdateGuildMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (builder *updateGuildMemberBuilder)
UpdateGuildMember [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} Discord documentation https://discord.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 (*Client) UpdateGuildRole ¶ added in v0.16.6
func (c *Client) UpdateGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) (builder *updateGuildRoleBuilder)
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} Discord documentation https://discord.com/developers/docs/resources/guild#modify-guild-role Reviewed 2018-08-18 Comment -
func (*Client) UpdateGuildRolePositions ¶ added in v0.16.6
func (c *Client) UpdateGuildRolePositions(ctx context.Context, guildID Snowflake, params []UpdateGuildRolePositionsParams, flags ...Flag) (roles []*Role, err error)
UpdateGuildRolePositions [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 Discord documentation https://discord.com/developers/docs/resources/guild#modify-guild-role-positions Reviewed 2018-08-18 Comment -
func (*Client) UpdateMessage ¶ added in v0.16.6
func (c *Client) UpdateMessage(ctx context.Context, chanID, msgID Snowflake, flags ...Flag) (builder *updateMessageBuilder)
UpdateMessage [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} Discord documentation https://discord.com/developers/docs/resources/channel#edit-message Reviewed 2018-06-10 Comment All parameters to this endpoint are optional.
TODO: verify embed is working
func (*Client) UpdateStatus ¶ added in v0.16.6
func (c *Client) UpdateStatus(s *UpdateStatusPayload) error
UpdateStatus updates the Client's game status note: for simple games, check out UpdateStatusString
func (*Client) UpdateStatusString ¶ added in v0.16.6
UpdateStatusString sets the Client's game activity to the provided string, status to online and type to Playing
func (*Client) UpdateWebhook ¶ added in v0.16.6
func (c *Client) UpdateWebhook(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateWebhookBuilder)
UpdateWebhook [REST] Modify a webhook. Requires the 'MANAGE_WEBHOOKS' permission. Returns the updated webhook object on success.
Method PATCH Endpoint /webhooks/{webhook.id} Discord documentation https://discord.com/developers/docs/resources/webhook#modify-webhook Reviewed 2018-08-14 Comment All parameters to this endpoint.
func (*Client) UpdateWebhookWithToken ¶ added in v0.16.6
func (c *Client) UpdateWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (builder *updateWebhookBuilder)
UpdateWebhookWithToken [REST] Same as UpdateWebhook, 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} Discord documentation https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token Reviewed 2018-08-14 Comment All parameters to this endpoint. are optional.
func (Client) VoiceConnect ¶ added in v0.16.6
func (r Client) VoiceConnect(guildID, channelID Snowflake) (VoiceConnection, error)
func (Client) VoiceConnectOptions ¶ added in v0.16.6
func (r Client) VoiceConnectOptions(guildID, channelID Snowflake, selfDeaf, selfMute bool) (ret VoiceConnection, err error)
type CloseConnectionErr ¶ added in v0.16.6
type CloseConnectionErr = disgorderr.ClosedConnectionErr
type Config ¶
type Config struct { // ################################################ // ## // ## Basic bot configuration. // ## This section is for everyone. And beginners // ## should stick to this section unless they know // ## what they are doing. // ## // ################################################ BotToken string HTTPClient *http.Client Proxy proxy.Dialer CancelRequestWhenRateLimited bool // LoadMembersQuietly will start fetching members for all guilds in the background. // There is currently no proper way to detect when the loading is done nor if it // finished successfully. LoadMembersQuietly bool // Presence will automatically be emitted to discord on start up Presence *UpdateStatusPayload // your project name, name of bot, or application ProjectName string // Logger is a dependency that must be injected to support logging. // disgord.DefaultLogger() can be used Logger Logger // ################################################ // ## // ## WARNING! For advanced users only. // ## This section of options might break the bot, // ## make it incoherent to the Discord API requirements, // ## potentially causing your bot to be banned. // ## You use these features on your own risk. // ## // ################################################ RESTBucketManager httd.RESTBucketManager DisableCache bool CacheConfig *CacheConfig ShardConfig ShardConfig // IgnoreEvents will skip events that matches the given event names. // WARNING! This can break your caching, so be careful about what you want to ignore. // // Note this also triggers discord optimizations behind the scenes, such that disgord_diagnosews might // seem to be missing some events. But actually the lack of certain events will mean Discord aren't sending // them at all due to how the identify command was defined. eg. guildS_subscriptions IgnoreEvents []string // contains filtered or unexported fields }
Config Configuration for the Disgord Client
type Copier ¶ added in v0.16.6
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.16.6
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 // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
CreateChannelInvitesParams https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
type CreateGroupDMParams ¶ added in v0.16.6
type CreateGroupDMParams struct { // AccessTokens access tokens of users that have granted your app the gdm.join scope AccessTokens []string `json:"access_tokens"` // map[userID] = nickname Nicks map[Snowflake]string `json:"nicks"` }
CreateGroupDMParams required JSON params for func CreateGroupDM https://discord.com/developers/docs/resources/user#create-group-dm
type CreateGuildChannelParams ¶ added in v0.16.6
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"` Position int `json:"position"` // can not omitempty in case position is 0 // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
CreateGuildChannelParams https://discord.com/developers/docs/resources/guild#create-guild-channel-json-params
type CreateGuildEmojiParams ¶ added in v0.16.6
type CreateGuildEmojiParams struct { Name string `json:"name"` // required Image string `json:"image"` // required Roles []Snowflake `json:"roles"` // optional // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
CreateGuildEmojiParams JSON params for func CreateGuildEmoji
type CreateGuildIntegrationParams ¶ added in v0.16.6
CreateGuildIntegrationParams ... https://discord.com/developers/docs/resources/guild#create-guild-integration-json-params
type CreateGuildParams ¶ added in v0.16.6
type CreateGuildParams struct { Name string `json:"name"` // required 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://discord.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.16.6
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"` // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
CreateGuildRoleParams ... https://discord.com/developers/docs/resources/guild#create-guild-role-json-params
type CreateMessageFileParams ¶ added in v0.16.6
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.16.6
type CreateMessageParams struct { Content string `json:"content"` Nonce string `json:"nonce,omitempty"` // THIS IS A STRING. NOT A SNOWFLAKE! DONT TOUCH! Tts bool `json:"tts,omitempty"` Embed *Embed `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.16.6
func NewMessageByString(content string) *CreateMessageParams
NewMessageByString creates a message object from a string/content
type CreateWebhookParams ¶ added in v0.16.6
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 // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
CreateWebhookParams json params for the create webhook rest request avatar string https://discord.com/developers/docs/resources/user#avatar-data
func (*CreateWebhookParams) FindErrors ¶ added in v0.16.6
func (c *CreateWebhookParams) FindErrors() error
type Ctrl ¶ added in v0.16.6
Ctrl is a handler controller that supports lifetime and max number of execution for one or several handlers.
// register only the first 6 votes Client.On("MESSAGE_CREATE", filter.NonVotes, registerVoteHandler, &disgord.Ctrl{Runs: 6}) // Allow voting for only 10 minutes Client.On("MESSAGE_CREATE", filter.NonVotes, registerVoteHandler, &disgord.Ctrl{Duration: 10*time.Second}) // Allow voting until the month is over Client.On("MESSAGE_CREATE", filter.NonVotes, registerVoteHandler, &disgord.Ctrl{Until: time.Now().AddDate(0, 1, 0)})
func (*Ctrl) CloseChannel ¶ added in v0.16.6
func (c *Ctrl) CloseChannel()
CloseChannel must be called instead of closing an event channel directly. This is to make sure Disgord does not go into a deadlock
type DeepCopier ¶ added in v0.16.6
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.16.6
type DefaultMessageNotificationLvl uint
DefaultMessageNotificationLvl ... https://discord.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.16.6
func (dmnl *DefaultMessageNotificationLvl) AllMessages() bool
AllMessages ...
func (*DefaultMessageNotificationLvl) OnlyMentions ¶ added in v0.16.6
func (dmnl *DefaultMessageNotificationLvl) OnlyMentions() bool
OnlyMentions ...
type DeleteMessagesParams ¶ added in v0.16.6
type DeleteMessagesParams struct { Messages []Snowflake `json:"messages"` // contains filtered or unexported fields }
DeleteMessagesParams https://discord.com/developers/docs/resources/channel#bulk-delete-messages-json-params
func (*DeleteMessagesParams) AddMessage ¶ added in v0.16.6
func (p *DeleteMessagesParams) AddMessage(msg *Message) (err error)
AddMessage Adds a message to be deleted
func (*DeleteMessagesParams) Valid ¶ added in v0.16.6
func (p *DeleteMessagesParams) Valid() (err error)
Valid validates the DeleteMessagesParams data
type Discriminator ¶ added in v0.16.6
type Discriminator uint16
Discriminator value
func NewDiscriminator ¶ added in v0.16.6
func NewDiscriminator(d string) (discriminator Discriminator, err error)
NewDiscriminator Discord user discriminator hashtag
func (Discriminator) MarshalJSON ¶ added in v0.16.6
func (d Discriminator) MarshalJSON() (data []byte, err error)
MarshalJSON see interface json.Marshaler
func (Discriminator) NotSet ¶ added in v0.16.6
func (d Discriminator) NotSet() bool
NotSet checks if the discriminator is not set
func (Discriminator) String ¶ added in v0.16.6
func (d Discriminator) String() (str string)
func (*Discriminator) UnmarshalJSON ¶ added in v0.16.6
func (d *Discriminator) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON see interface json.Unmarshaler
type Embed ¶ added in v0.16.6
type Embed struct { Lockable `json:"-"` Title string `json:"title,omitempty"` // title of embed Type string `json:"type,omitempty"` // type of embed (always "rich" for webhook embeds) Description string `json:"description,omitempty"` // description of embed URL string `json:"url,omitempty"` // url of embed Timestamp Time `json:"timestamp,omitempty"` // timestamp timestamp of embed content Color int `json:"color,omitempty"` // color code of the embed Image *EmbedImage `json:"image,omitempty"` // embed image object image information Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"` // embed thumbnail object thumbnail information Video *EmbedVideo `json:"video,omitempty"` // embed video object video information Provider *EmbedProvider `json:"provider,omitempty"` // embed provider object provider information Author *EmbedAuthor `json:"author,omitempty"` // embed author object author information Fields []*EmbedField `json:"fields,omitempty"` // array of embed field objects fields information }
Embed https://discord.com/developers/docs/resources/channel#embed-object
func (*Embed) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type EmbedAuthor ¶ added in v0.16.6
type EmbedAuthor 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 }
func (*EmbedAuthor) CopyOverTo ¶ added in v0.16.6
func (c *EmbedAuthor) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedAuthor) DeepCopy ¶ added in v0.16.6
func (c *EmbedAuthor) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedField ¶ added in v0.16.6
type EmbedField struct { Lockable `json:"-"` Name string `json:"name"` // | , name of the field Value string `json:"value"` // | , value of the field Inline bool `json:"inline,omitempty"` // ?| , whether or not this field should display inline }
func (*EmbedField) CopyOverTo ¶ added in v0.16.6
func (c *EmbedField) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedField) DeepCopy ¶ added in v0.16.6
func (c *EmbedField) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedFooter ¶ added in v0.16.6
type EmbedFooter struct {}
func (*EmbedFooter) CopyOverTo ¶ added in v0.16.6
func (c *EmbedFooter) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedFooter) DeepCopy ¶ added in v0.16.6
func (c *EmbedFooter) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedImage ¶ added in v0.16.6
type EmbedImage 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 }
func (*EmbedImage) CopyOverTo ¶ added in v0.16.6
func (c *EmbedImage) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedImage) DeepCopy ¶ added in v0.16.6
func (c *EmbedImage) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedProvider ¶ added in v0.16.6
type EmbedProvider struct { Lockable `json:"-"` Name string `json:"name,omitempty"` // ?| , name of provider URL string `json:"url,omitempty"` // ?| , url of provider }
EmbedProvider https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure
func (*EmbedProvider) CopyOverTo ¶ added in v0.16.6
func (c *EmbedProvider) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedProvider) DeepCopy ¶ added in v0.16.6
func (c *EmbedProvider) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedThumbnail ¶ added in v0.16.6
type EmbedThumbnail 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 }
EmbedThumbnail https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure
func (*EmbedThumbnail) CopyOverTo ¶ added in v0.16.6
func (c *EmbedThumbnail) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedThumbnail) DeepCopy ¶ added in v0.16.6
func (c *EmbedThumbnail) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type EmbedVideo ¶ added in v0.16.6
type EmbedVideo 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 }
func (*EmbedVideo) CopyOverTo ¶ added in v0.16.6
func (c *EmbedVideo) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*EmbedVideo) DeepCopy ¶ added in v0.16.6
func (c *EmbedVideo) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type Emitter ¶ added in v0.16.6
type Emitter interface {
Emit(name gatewayCmdName, data gatewayCmdPayload) (unhandledGuildIDs []Snowflake, err error)
}
Emitter for emitting data from A to B. Used in websocket connection
type Emoji ¶ added in v0.16.6
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 (*Emoji) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Emoji) DeepCopy ¶ added in v0.16.6
func (e *Emoji) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Emoji) LinkToGuild ¶ added in v0.16.6
type ErrorCacheItemNotFound ¶ added in v0.16.6
type ErrorCacheItemNotFound struct {
// contains filtered or unexported fields
}
ErrorCacheItemNotFound requested item was not found in cacheLink
func (*ErrorCacheItemNotFound) Error ¶ added in v0.16.6
func (e *ErrorCacheItemNotFound) Error() string
Error ...
type ErrorEmptyValue ¶ added in v0.16.6
type ErrorEmptyValue struct {
// contains filtered or unexported fields
}
ErrorEmptyValue when a required value was set as empty
func (*ErrorEmptyValue) Error ¶ added in v0.16.6
func (e *ErrorEmptyValue) Error() string
type ErrorMissingSnowflake ¶ added in v0.16.6
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.16.6
func (e *ErrorMissingSnowflake) Error() string
type ErrorUnsupportedType ¶ added in v0.16.6
type ErrorUnsupportedType struct {
// contains filtered or unexported fields
}
ErrorUnsupportedType used when the given param type is not supported
func (*ErrorUnsupportedType) Error ¶ added in v0.16.6
func (e *ErrorUnsupportedType) Error() string
type ErrorUsingDeactivatedCache ¶ added in v0.16.6
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.16.6
func (e *ErrorUsingDeactivatedCache) Error() string
type ExecuteWebhookParams ¶ added in v0.16.6
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 []*Embed `json:"embeds"` }
ExecuteWebhookParams JSON params for func ExecuteWebhook
func NewExecuteWebhookParams ¶ added in v0.16.6
func NewExecuteWebhookParams(id Snowflake, token string) (ret *ExecuteWebhookParams, err error)
NewExecuteWebhookParams creates params for func ExecuteWebhook
type ExplicitContentFilterLvl ¶ added in v0.16.6
type ExplicitContentFilterLvl uint
ExplicitContentFilterLvl ... https://discord.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.16.6
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.16.6
func (ecfl *ExplicitContentFilterLvl) Disabled() bool
Disabled if the content filter is disabled
func (*ExplicitContentFilterLvl) MembersWithoutRoles ¶ added in v0.16.6
func (ecfl *ExplicitContentFilterLvl) MembersWithoutRoles() bool
MembersWithoutRoles if the filter only applies for members without a role
type Flag ¶ added in v0.16.6
type Flag uint32
func (Flag) IgnoreEmptyParams ¶ added in v0.16.6
func (Flag) Ignorecache ¶ added in v0.16.6
type GetCurrentUserGuildsParams ¶ added in v0.16.6
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) URLQueryString ¶ added in v0.16.6
func (g *GetCurrentUserGuildsParams) URLQueryString() string
type GetInviteParams ¶ added in v0.16.6
type GetInviteParams struct {
WithMemberCount bool `urlparam:"with_count,omitempty"`
}
func (*GetInviteParams) URLQueryString ¶ added in v0.16.6
func (g *GetInviteParams) URLQueryString() string
type GetMembersParams ¶ added in v0.16.6
type GetMembersParams struct { After Snowflake `urlparam:"after,omitempty"` Limit uint32 `urlparam:"limit,omitempty"` // 0 will fetch everyone }
GetMembersParams if Limit is 0, every member is fetched. This does not follow the Discord API where a 0 is converted into a 1. 0 = every member. The rest is exactly the same, you should be able to do everything the Discord docs says with the addition that you can bypass a limit of 1,000.
If you specify a limit of +1,000 Disgord will run N requests until that amount is met, or until you run out of members to fetch.
type GetMessagesParams ¶ added in v0.16.6
type GetMessagesParams struct { Around Snowflake `urlparam:"around,omitempty"` Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit uint `urlparam:"limit,omitempty"` }
GetChannelMessagesParams https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params TODO: ensure limits
func (*GetMessagesParams) URLQueryString ¶ added in v0.16.6
func (g *GetMessagesParams) URLQueryString() string
func (*GetMessagesParams) Validate ¶ added in v0.16.6
func (p *GetMessagesParams) Validate() error
type GetReactionURLParams ¶ added in v0.16.6
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://discord.com/developers/docs/resources/channel#get-reactions-query-string-params
func (*GetReactionURLParams) URLQueryString ¶ added in v0.16.6
func (g *GetReactionURLParams) URLQueryString() string
type GroupDMParticipant ¶ added in v0.16.6
type GroupDMParticipant struct { AccessToken string `json:"access_token"` // access token of a user that has granted your app the gdm.join scope Nickname string `json:"nick,omitempty"` // nickname of the user being added UserID Snowflake `json:"-"` }
GroupDMParticipant Information needed to add a recipient to a group chat
func (*GroupDMParticipant) FindErrors ¶ added in v0.16.6
func (g *GroupDMParticipant) FindErrors() error
type Guild ¶ added in v0.16.6
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 PermissionBits `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 *Time `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://discord.com/developers/docs/resources/guild#guild-object Fields with `*` are only sent within the GUILD_CREATE event reviewed: 2018-08-25
func NewGuildFromJSON ¶ added in v0.16.6
NewGuildFromJSON ...
func NewGuildFromUnavailable ¶ added in v0.16.6
func NewGuildFromUnavailable(gu *GuildUnavailable) *Guild
NewGuildFromUnavailable converts a unavailable guild object into a normal Guild object
func NewPartialGuild ¶ added in v0.16.6
NewPartialGuild ...
func (*Guild) AddChannel ¶ added in v0.16.6
AddChannel adds a channel to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMember ¶ added in v0.16.6
AddMember adds a member to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMembers ¶ added in v0.16.6
AddMembers adds multiple members to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddRole ¶ added in v0.16.6
AddRole adds a role to the Guild object. Note that this does not interact with Discord.
func (*Guild) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Guild) DeepCopy ¶ added in v0.16.6
func (g *Guild) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Guild) DeleteChannel ¶ added in v0.16.6
DeleteChannel removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteChannelByID ¶ added in v0.16.6
DeleteChannelByID removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteRoleByID ¶ added in v0.16.6
DeleteRoleByID remove a role from the guild struct
func (*Guild) GetMemberWithHighestSnowflake ¶ added in v0.16.6
GetMemberWithHighestSnowflake finds the member with the highest snowflake value.
func (*Guild) GetMembersCountEstimate ¶ added in v0.16.6
GetMembersCountEstimate estimates the number of members in a guild without fetching everyone. There is no proper way to get this number, so a invite is created and the estimate is read from there. The invite is then deleted again.
func (*Guild) MarshalJSON ¶ added in v0.16.6
MarshalJSON see interface json.Marshaler TODO: fix copying of mutex lock
func (*Guild) MembersByName ¶ added in v0.16.6
MembersByName retrieve a slice of members with same username or nickname
func (*Guild) RoleByName ¶ added in v0.16.6
RoleByName retrieves a slice of roles with same name
type GuildBanAdd ¶ added in v0.16.6
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.16.6
type GuildBanAddHandler = func(s Session, h *GuildBanAdd)
GuildBanAddHandler is triggered in GuildBanAdd events
type GuildBanRemove ¶ added in v0.16.6
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.16.6
type GuildBanRemoveHandler = func(s Session, h *GuildBanRemove)
GuildBanRemoveHandler is triggered in GuildBanRemove events
type GuildCreate ¶ added in v0.16.6
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.16.6
func (obj *GuildCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildCreateHandler ¶ added in v0.16.6
type GuildCreateHandler = func(s Session, h *GuildCreate)
GuildCreateHandler is triggered in GuildCreate events
type GuildDelete ¶ added in v0.16.6
GuildDelete guild became unavailable, or user left/was removed from a guild
func (*GuildDelete) UnmarshalJSON ¶ added in v0.16.6
func (obj *GuildDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
func (*GuildDelete) UserWasRemoved ¶ added in v0.16.6
func (obj *GuildDelete) UserWasRemoved() bool
UserWasRemoved ... TODO
type GuildDeleteHandler ¶ added in v0.16.6
type GuildDeleteHandler = func(s Session, h *GuildDelete)
GuildDeleteHandler is triggered in GuildDelete events
type GuildEmbed ¶ added in v0.16.6
type GuildEmbed struct { Lockable `json:"-"` Enabled bool `json:"enabled"` ChannelID Snowflake `json:"channel_id"` }
GuildEmbed https://discord.com/developers/docs/resources/guild#guild-embed-object
func (*GuildEmbed) CopyOverTo ¶ added in v0.16.6
func (e *GuildEmbed) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*GuildEmbed) DeepCopy ¶ added in v0.16.6
func (e *GuildEmbed) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type GuildEmojisUpdate ¶ added in v0.16.6
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.16.6
type GuildEmojisUpdateHandler = func(s Session, h *GuildEmojisUpdate)
GuildEmojisUpdateHandler is triggered in GuildEmojisUpdate events
type GuildIntegrationsUpdate ¶ added in v0.16.6
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.16.6
type GuildIntegrationsUpdateHandler = func(s Session, h *GuildIntegrationsUpdate)
GuildIntegrationsUpdateHandler is triggered in GuildIntegrationsUpdate events
type GuildMemberAdd ¶ added in v0.16.6
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.16.6
func (obj *GuildMemberAdd) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildMemberAddHandler ¶ added in v0.16.6
type GuildMemberAddHandler = func(s Session, h *GuildMemberAdd)
GuildMemberAddHandler is triggered in GuildMemberAdd events
type GuildMemberRemove ¶ added in v0.16.6
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.16.6
type GuildMemberRemoveHandler = func(s Session, h *GuildMemberRemove)
GuildMemberRemoveHandler is triggered in GuildMemberRemove events
type GuildMemberUpdate ¶ added in v0.16.6
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.16.6
type GuildMemberUpdateHandler = func(s Session, h *GuildMemberUpdate)
GuildMemberUpdateHandler is triggered in GuildMemberUpdate events
type GuildMembersChunk ¶ added in v0.16.6
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.16.6
type GuildMembersChunkHandler = func(s Session, h *GuildMembersChunk)
GuildMembersChunkHandler is triggered in GuildMembersChunk events
type GuildRoleCreate ¶ added in v0.16.6
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.16.6
type GuildRoleCreateHandler = func(s Session, h *GuildRoleCreate)
GuildRoleCreateHandler is triggered in GuildRoleCreate events
type GuildRoleDelete ¶ added in v0.16.6
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.16.6
type GuildRoleDeleteHandler = func(s Session, h *GuildRoleDelete)
GuildRoleDeleteHandler is triggered in GuildRoleDelete events
type GuildRoleUpdate ¶ added in v0.16.6
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.16.6
type GuildRoleUpdateHandler = func(s Session, h *GuildRoleUpdate)
GuildRoleUpdateHandler is triggered in GuildRoleUpdate events
type GuildUnavailable ¶ added in v0.16.6
type GuildUnavailable struct {}
GuildUnavailable is a partial Guild object.
func NewGuildUnavailable ¶ added in v0.16.6
func NewGuildUnavailable(ID Snowflake) *GuildUnavailable
NewGuildUnavailable ...
type GuildUpdate ¶ added in v0.16.6
type GuildUpdate struct { Guild *Guild `json:"guild"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
GuildUpdate guild was updated
func (*GuildUpdate) UnmarshalJSON ¶ added in v0.16.6
func (obj *GuildUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildUpdateHandler ¶ added in v0.16.6
type GuildUpdateHandler = func(s Session, h *GuildUpdate)
GuildUpdateHandler is triggered in GuildUpdate events
type Handler ¶ added in v0.16.6
type Handler = interface{}
Handler needs to match one of the *Handler signatures
type HandlerChannelCreate ¶ added in v0.16.6
type HandlerChannelCreate = func(Session, *ChannelCreate)
type HandlerChannelDelete ¶ added in v0.16.6
type HandlerChannelDelete = func(Session, *ChannelDelete)
type HandlerChannelPinsUpdate ¶ added in v0.16.6
type HandlerChannelPinsUpdate = func(Session, *ChannelPinsUpdate)
type HandlerChannelUpdate ¶ added in v0.16.6
type HandlerChannelUpdate = func(Session, *ChannelUpdate)
type HandlerCtrl ¶ added in v0.16.6
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 HandlerGuildBanAdd ¶ added in v0.16.6
type HandlerGuildBanAdd = func(Session, *GuildBanAdd)
type HandlerGuildBanRemove ¶ added in v0.16.6
type HandlerGuildBanRemove = func(Session, *GuildBanRemove)
type HandlerGuildCreate ¶ added in v0.16.6
type HandlerGuildCreate = func(Session, *GuildCreate)
type HandlerGuildDelete ¶ added in v0.16.6
type HandlerGuildDelete = func(Session, *GuildDelete)
type HandlerGuildEmojisUpdate ¶ added in v0.16.6
type HandlerGuildEmojisUpdate = func(Session, *GuildEmojisUpdate)
type HandlerGuildIntegrationsUpdate ¶ added in v0.16.6
type HandlerGuildIntegrationsUpdate = func(Session, *GuildIntegrationsUpdate)
type HandlerGuildMemberAdd ¶ added in v0.16.6
type HandlerGuildMemberAdd = func(Session, *GuildMemberAdd)
type HandlerGuildMemberRemove ¶ added in v0.16.6
type HandlerGuildMemberRemove = func(Session, *GuildMemberRemove)
type HandlerGuildMemberUpdate ¶ added in v0.16.6
type HandlerGuildMemberUpdate = func(Session, *GuildMemberUpdate)
type HandlerGuildMembersChunk ¶ added in v0.16.6
type HandlerGuildMembersChunk = func(Session, *GuildMembersChunk)
type HandlerGuildRoleCreate ¶ added in v0.16.6
type HandlerGuildRoleCreate = func(Session, *GuildRoleCreate)
type HandlerGuildRoleDelete ¶ added in v0.16.6
type HandlerGuildRoleDelete = func(Session, *GuildRoleDelete)
type HandlerGuildRoleUpdate ¶ added in v0.16.6
type HandlerGuildRoleUpdate = func(Session, *GuildRoleUpdate)
type HandlerGuildUpdate ¶ added in v0.16.6
type HandlerGuildUpdate = func(Session, *GuildUpdate)
type HandlerInviteCreate ¶ added in v0.16.6
type HandlerInviteCreate = func(Session, *InviteCreate)
type HandlerMessageCreate ¶ added in v0.16.6
type HandlerMessageCreate = func(Session, *MessageCreate)
type HandlerMessageDelete ¶ added in v0.16.6
type HandlerMessageDelete = func(Session, *MessageDelete)
type HandlerMessageDeleteBulk ¶ added in v0.16.6
type HandlerMessageDeleteBulk = func(Session, *MessageDeleteBulk)
type HandlerMessageReactionAdd ¶ added in v0.16.6
type HandlerMessageReactionAdd = func(Session, *MessageReactionAdd)
type HandlerMessageReactionRemove ¶ added in v0.16.6
type HandlerMessageReactionRemove = func(Session, *MessageReactionRemove)
type HandlerMessageReactionRemoveAll ¶ added in v0.16.6
type HandlerMessageReactionRemoveAll = func(Session, *MessageReactionRemoveAll)
type HandlerMessageUpdate ¶ added in v0.16.6
type HandlerMessageUpdate = func(Session, *MessageUpdate)
type HandlerPresenceUpdate ¶ added in v0.16.6
type HandlerPresenceUpdate = func(Session, *PresenceUpdate)
type HandlerReady ¶ added in v0.16.6
type HandlerResumed ¶ added in v0.16.6
type HandlerSpecErr ¶ added in v0.16.6
type HandlerSpecErr = disgorderr.HandlerSpecErr
type HandlerTypingStart ¶ added in v0.16.6
type HandlerTypingStart = func(Session, *TypingStart)
type HandlerUserUpdate ¶ added in v0.16.6
type HandlerUserUpdate = func(Session, *UserUpdate)
type HandlerVoiceServerUpdate ¶ added in v0.16.6
type HandlerVoiceServerUpdate = func(Session, *VoiceServerUpdate)
type HandlerVoiceStateUpdate ¶ added in v0.16.6
type HandlerVoiceStateUpdate = func(Session, *VoiceStateUpdate)
type HandlerWebhooksUpdate ¶ added in v0.16.6
type HandlerWebhooksUpdate = func(Session, *WebhooksUpdate)
type Integration ¶ added in v0.16.6
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://discord.com/developers/docs/resources/guild#integration-object
func (*Integration) CopyOverTo ¶ added in v0.16.6
func (i *Integration) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*Integration) DeepCopy ¶ added in v0.16.6
func (i *Integration) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type IntegrationAccount ¶ added in v0.16.6
type IntegrationAccount struct { Lockable `json:"-"` ID string `json:"id"` // id of the account Name string `json:"name"` // name of the account }
IntegrationAccount https://discord.com/developers/docs/resources/guild#integration-account-object
func (*IntegrationAccount) CopyOverTo ¶ added in v0.16.6
func (i *IntegrationAccount) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*IntegrationAccount) DeepCopy ¶ added in v0.16.6
func (i *IntegrationAccount) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type Invite ¶ added in v0.16.6
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"` Inviter *User `json:"inviter"` CreatedAt Time `json:"created_at"` MaxAge int `json:"max_age"` Uses int `json:"uses"` MaxUses int `json:"max_uses"` Revoked bool `json:"revoked"` Temporary bool `json:"temporary"` Unique bool `json:"unique"` // 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://discord.com/developers/docs/resources/invite#invite-object Reviewed: 2018-06-10
func (*Invite) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type InviteCreate ¶ added in v0.16.6
type InviteCreate struct { GuildID Snowflake `json:"guild"` ChannelID Snowflake `json:"channel"` InviterID Snowflake `json:"inviter"` Code string `json:"code"` CreatedAt Time `json:"created_at"` MaxAge int `json:"max_age"` Uses int `json:"uses"` MaxUses int `json:"max_uses"` Revoked bool `json:"revoked"` Temporary bool `json:"temporary"` Unique bool `json:"unique"` ApproximatePresenceCount int `json:"approximate_presence_count"` ApproximateMemberCount int `json:"approximate_member_count"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
InviteCreate Sent when a guild channel's invite is created.
type InviteCreateHandler ¶ added in v0.16.6
type InviteCreateHandler = func(s Session, h *InviteCreate)
InviteCreateHandler is triggered in InviteCreate events
type InviteMetadata ¶ added in v0.16.6
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 Time `json:"created_at"` // Revoked whether this invite is revoked Revoked bool `json:"revoked"` }
InviteMetadata Object https://discord.com/developers/docs/resources/invite#invite-metadata-object Reviewed: 2018-06-10
func (*InviteMetadata) CopyOverTo ¶ added in v0.16.6
func (i *InviteMetadata) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*InviteMetadata) DeepCopy ¶ added in v0.16.6
func (i *InviteMetadata) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type Link ¶ added in v0.16.6
type Link interface { // Connect establishes a websocket connection to the discord API Connect(ctx context.Context) error // Disconnect closes the discord websocket connection Disconnect() error }
Link allows basic Discord connection control. Affects all shards
type MFALvl ¶ added in v0.16.6
type MFALvl uint
MFALvl ... https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
type Member ¶ added in v0.16.6
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 Time `json:"joined_at,omitempty"` // voice Deaf bool `json:"deaf"` Mute bool `json:"mute"` // contains filtered or unexported fields }
Member https://discord.com/developers/docs/resources/guild#guild-member-object
func (*Member) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Member) DeepCopy ¶ added in v0.16.6
func (m *Member) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Member) GetPermissions ¶ added in v0.16.6
func (*Member) GetUser ¶ added in v0.16.6
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 MentionChannel ¶ added in v0.16.6
type Mentioner ¶ added in v0.16.6
type Mentioner interface {
Mention() string
}
Mentioner can be implemented by any type that is mentionable. https://discord.com/developers/docs/reference#message-formatting-formats
type Message ¶ added in v0.16.6
type Message struct { Lockable `json:"-"` ID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` Author *User `json:"author"` Member *Member `json:"member"` Content string `json:"content"` Timestamp Time `json:"timestamp"` EditedTimestamp Time `json:"edited_timestamp"` // ? Tts bool `json:"tts"` MentionEveryone bool `json:"mention_everyone"` Mentions []*User `json:"mentions"` MentionRoles []Snowflake `json:"mention_roles"` MentionChannels []*MentionChannel `json:"mention_channels"` Attachments []*Attachment `json:"attachments"` Embeds []*Embed `json:"embeds"` Reactions []*Reaction `json:"reactions"` // ? Nonce interface{} `json:"nonce"` // NOT A SNOWFLAKE! DONT TOUCH! Pinned bool `json:"pinned"` WebhookID Snowflake `json:"webhook_id"` // ? Type MessageType `json:"type"` Activity MessageActivity `json:"activity"` Application MessageApplication `json:"application"` MessageReference *MessageReference `json:"message_reference"` Flags MessageFlag `json:"flags"` // GuildID is not set when using a REST request. Only socket events. GuildID Snowflake `json:"guild_id"` // 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:"-"` }
func (*Message) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Message) DeepCopy ¶ added in v0.16.6
func (m *Message) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Message) DiscordURL ¶ added in v0.16.6
DiscordURL returns the Discord link to the message. This can be used to jump directly to a message from within the client.
func (*Message) IsDirectMessage ¶ added in v0.16.6
IsDirectMessage checks if the message is from a direct message channel.
WARNING! Note that, when fetching messages using the REST API the guildID might be empty -> giving a false positive.
func (*Message) Reply ¶ added in v0.16.6
func (m *Message) Reply(ctx context.Context, client msgSender, data ...interface{}) (*Message, error)
Reply input any type as an reply. int, string, an object, etc.
type MessageActivity ¶ added in v0.16.6
MessageActivity https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure
type MessageApplication ¶ added in v0.16.6
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://discord.com/developers/docs/resources/channel#message-object-message-application-structure
type MessageCreate ¶ added in v0.16.6
type MessageCreate struct { Message *Message Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageCreate message was created
func (*MessageCreate) Reset ¶ added in v0.16.6
func (m *MessageCreate) Reset()
func (*MessageCreate) UnmarshalJSON ¶ added in v0.16.6
func (obj *MessageCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MessageCreateHandler ¶ added in v0.16.6
type MessageCreateHandler = func(s Session, h *MessageCreate)
MessageCreateHandler is triggered in MessageCreate events
type MessageDelete ¶ added in v0.16.6
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.16.6
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.16.6
type MessageDeleteBulkHandler = func(s Session, h *MessageDeleteBulk)
MessageDeleteBulkHandler is triggered in MessageDeleteBulk events
type MessageDeleteHandler ¶ added in v0.16.6
type MessageDeleteHandler = func(s Session, h *MessageDelete)
MessageDeleteHandler is triggered in MessageDelete events
type MessageFlag ¶ added in v0.16.6
type MessageFlag uint
const ( // MessageFlagCrossposted this message has been published to subscribed channels (via Channel Following) MessageFlagCrossposted MessageFlag = 1 << iota // MessageFlagIsCrosspost this message originated from a message in another channel (via Channel Following) MessageFlagIsCrosspost // MessageFlagSupressEmbeds do not include any embeds when serializing this message MessageFlagSupressEmbeds )
type MessageReactionAdd ¶ added in v0.16.6
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 Note! do not cache emoji, unless it's updated with guildID TODO: find guildID when given userID, ChannelID and MessageID
type MessageReactionAddHandler ¶ added in v0.16.6
type MessageReactionAddHandler = func(s Session, h *MessageReactionAdd)
MessageReactionAddHandler is triggered in MessageReactionAdd events
type MessageReactionRemove ¶ added in v0.16.6
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 Note! do not cache emoji, unless it's updated with guildID TODO: find guildID when given userID, ChannelID and MessageID
type MessageReactionRemoveAll ¶ added in v0.16.6
type MessageReactionRemoveAll struct { ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageReactionRemoveAll all reactions were explicitly removed from a message
type MessageReactionRemoveAllHandler ¶ added in v0.16.6
type MessageReactionRemoveAllHandler = func(s Session, h *MessageReactionRemoveAll)
MessageReactionRemoveAllHandler is triggered in MessageReactionRemoveAll events
type MessageReactionRemoveHandler ¶ added in v0.16.6
type MessageReactionRemoveHandler = func(s Session, h *MessageReactionRemove)
MessageReactionRemoveHandler is triggered in MessageReactionRemove events
type MessageReference ¶ added in v0.16.6
type MessageSender ¶ added in v0.16.6
type MessageSender interface {
CreateMessage(ctx context.Context, channelID Snowflake, params *CreateMessageParams, flags ...Flag) (ret *Message, err error)
}
MessageSender is an interface which only holds the method needed for creating a channel message
type MessageType ¶ added in v0.16.6
type MessageType uint // TODO: once auto generated, un-export this.
The different message types usually generated by Discord. eg. "a new user joined"
const ( MessageTypeDefault MessageType = iota MessageTypeRecipientAdd MessageTypeRecipientRemove MessageTypeCall MessageTypeChannelNameChange MessageTypeChannelIconChange MessageTypeChannelPinnedMessage MessageTypeGuildMemberJoin MessageTypeUserPremiumGuildSubscription MessageTypeUserPremiumGuildSubscriptionTier1 MessageTypeUserPremiumGuildSubscriptionTier2 MessageTypeUserPremiumGuildSubscriptionTier3 MessageTypeChannelFollowAdd )
type MessageUpdate ¶ added in v0.16.6
type MessageUpdate struct { Message *Message Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
MessageUpdate message was edited
func (*MessageUpdate) UnmarshalJSON ¶ added in v0.16.6
func (obj *MessageUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MessageUpdateHandler ¶ added in v0.16.6
type MessageUpdateHandler = func(s Session, h *MessageUpdate)
MessageUpdateHandler is triggered in MessageUpdate events
type MessageUpdater ¶ added in v0.16.6
type MessageUpdater interface {
UpdateMessage(ctx context.Context, chanID, msgID Snowflake, flags ...Flag) *updateMessageBuilder
}
MessageUpdater is a interface which only holds the message update method
type Middleware ¶ added in v0.16.6
type Middleware = func(interface{}) interface{}
Middleware allows you to manipulate data during the "stream"
type PartialBan ¶ added in v0.16.6
PartialBan is used by audit logs
func (*PartialBan) String ¶ added in v0.16.6
func (p *PartialBan) String() string
type PartialChannel ¶ added in v0.16.6
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 PartialGuild ¶ added in v0.16.6
type PartialGuild = Guild // TODO: find the actual data struct for partial guild
PartialGuild see Guild
type PartialInvite ¶ added in v0.16.6
type PartialInvite = Invite
PartialInvite ...
{ "code": "abc" }
type PermissionBit ¶ added in v0.16.6
type PermissionBit = uint64
const ( PermissionReadMessages PermissionBit = 1 << (iota + 10) PermissionSendMessages PermissionSendTTSMessages PermissionManageMessages PermissionEmbedLinks PermissionAttachFiles PermissionReadMessageHistory PermissionMentionEveryone PermissionUseExternalEmojis )
Constants for the different bit offsets of text channel permissions
const ( PermissionVoiceConnect PermissionBit = 1 << (iota + 20) PermissionVoiceSpeak PermissionVoiceMuteMembers PermissionVoiceDeafenMembers PermissionVoiceMoveMembers PermissionVoiceUseVAD PermissionVoicePrioritySpeaker PermissionBit = 1 << (iota + 2) )
Constants for the different bit offsets of voice permissions
const ( PermissionChangeNickname PermissionBit = 1 << (iota + 26) PermissionManageNicknames PermissionManageRoles PermissionManageWebhooks PermissionManageEmojis )
Constants for general management.
type PermissionBits ¶ added in v0.16.6
type PermissionBits = PermissionBit
type PermissionOverwrite ¶ added in v0.16.6
type PermissionOverwrite struct { ID Snowflake `json:"id"` // role or user id Type string `json:"type"` // either `role` or `member` Allow PermissionBits `json:"allow"` // permission bit set Deny PermissionBits `json:"deny"` // permission bit set }
PermissionOverwrite https://discord.com/developers/docs/resources/channel#overwrite-object
type PremiumType ¶ added in v0.16.6
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.16.6
func (p PremiumType) String() (t string)
type PresenceUpdate ¶ added in v0.16.6
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.16.6
type PresenceUpdateHandler = func(s Session, h *PresenceUpdate)
PresenceUpdateHandler is triggered in PresenceUpdate events
type RESTAuditLogs ¶ added in v0.16.6
type RESTAuditLogs interface { // GetGuildAuditLogs Returns an audit log object for the guild. Requires the 'VIEW_AUDIT_LOG' permission. // Note that this request will _always_ send a REST request, regardless of you calling IgnoreCache or not. GetGuildAuditLogs(ctx context.Context, guildID Snowflake, flags ...Flag) *guildAuditLogsBuilder }
AuditLogsRESTer REST interface for all audit-logs endpoints
type RESTBuilder ¶ added in v0.16.6
type RESTBuilder struct {
// contains filtered or unexported fields
}
func (*RESTBuilder) CancelOnRatelimit ¶ added in v0.16.6
func (b *RESTBuilder) CancelOnRatelimit() *RESTBuilder
func (*RESTBuilder) IgnoreCache ¶ added in v0.16.6
func (b *RESTBuilder) IgnoreCache() *RESTBuilder
type RESTChannel ¶ added in v0.16.6
type RESTChannel interface { RESTMessage RESTReaction // TriggerTypingIndicator 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. TriggerTypingIndicator(ctx context.Context, channelID Snowflake, flags ...Flag) (err error) // GetPinnedMessages Returns all pinned messages in the channel as an array of message objects. GetPinnedMessages(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Message, err error) // PinMessage same as PinMessageID PinMessage(ctx context.Context, msg *Message, flags ...Flag) (err error) // PinMessageID Pin a message by its ID and channel ID. Requires the 'MANAGE_MESSAGES' permission. // Returns a 204 empty response on success. PinMessageID(ctx context.Context, channelID, msgID Snowflake, flags ...Flag) (err error) // UnpinMessage same as UnpinMessageID UnpinMessage(ctx context.Context, msg *Message, flags ...Flag) (err error) // UnpinMessageID 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. UnpinMessageID(ctx context.Context, channelID, msgID Snowflake, flags ...Flag) (err error) // GetChannel Get a channel by Snowflake. Returns a channel object. GetChannel(ctx context.Context, id Snowflake, flags ...Flag) (ret *Channel, err error) // UpdateChannel 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. UpdateChannel(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateChannelBuilder) // DeleteChannel 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. DeleteChannel(ctx context.Context, id Snowflake, flags ...Flag) (channel *Channel, err error) // EditChannelPermissions 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. UpdateChannelPermissions(ctx context.Context, chanID, overwriteID Snowflake, params *UpdateChannelPermissionsParams, flags ...Flag) (err error) // GetChannelInvites Returns a list of invite objects (with invite metadata) for the channel. Only usable for // guild channels. Requires the 'MANAGE_CHANNELS' permission. GetChannelInvites(ctx context.Context, id Snowflake, flags ...Flag) (ret []*Invite, err error) // CreateChannelInvites 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. CreateChannelInvites(ctx context.Context, id Snowflake, params *CreateChannelInvitesParams, flags ...Flag) (ret *Invite, err error) // DeleteChannelPermission 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://discord.com/developers/docs/topics/permissions#permissions DeleteChannelPermission(ctx context.Context, channelID, overwriteID Snowflake, flags ...Flag) (err error) // AddDMParticipant Adds a recipient to a Group DM using their access token. Returns a 204 empty response // on success. AddDMParticipant(ctx context.Context, channelID Snowflake, participant *GroupDMParticipant, flags ...Flag) (err error) // KickParticipant Removes a recipient from a Group DM. Returns a 204 empty response on success. KickParticipant(ctx context.Context, channelID, userID Snowflake, flags ...Flag) (err error) }
RESTChannel REST interface for all Channel endpoints
type RESTEmoji ¶ added in v0.16.6
type RESTEmoji interface { // GetGuildEmoji Returns an emoji object for the given guild and emoji IDs. GetGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) (*Emoji, error) // GetGuildEmojis Returns a list of emoji objects for the given guild. GetGuildEmojis(ctx context.Context, id Snowflake, flags ...Flag) ([]*Emoji, error) // CreateGuildEmoji 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. CreateGuildEmoji(ctx context.Context, guildID Snowflake, params *CreateGuildEmojiParams, flags ...Flag) (*Emoji, error) // UpdateGuildEmoji Modify the given emoji. Requires the 'MANAGE_EMOJIS' permission. // Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event. UpdateGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) *updateGuildEmojiBuilder // DeleteGuildEmoji Delete the given emoji. Requires the 'MANAGE_EMOJIS' permission. Returns 204 No Content on // success. Fires a Guild Emojis Update Gateway event. DeleteGuildEmoji(ctx context.Context, guildID, emojiID Snowflake, flags ...Flag) error }
RESTEmoji REST interface for all emoji endpoints
type RESTGuild ¶ added in v0.16.6
type RESTGuild interface { // CreateGuild Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. CreateGuild(ctx context.Context, guildName string, params *CreateGuildParams, flags ...Flag) (*Guild, error) // GetGuild Returns the guild object for the given id. GetGuild(ctx context.Context, id Snowflake, flags ...Flag) (*Guild, error) // ModifyGuild Modify a guild's settings. Requires the 'MANAGE_GUILD' permission. Returns the updated guild // object on success. Fires a Guild Update Gateway event. UpdateGuild(ctx context.Context, id Snowflake, flags ...Flag) *updateGuildBuilder // DeleteGuild Delete a guild permanently. User must be owner. Returns 204 No Content on success. // Fires a Guild Delete Gateway event. DeleteGuild(ctx context.Context, id Snowflake, flags ...Flag) error // GetGuildChannels Returns a list of guild channel objects. GetGuildChannels(ctx context.Context, id Snowflake, flags ...Flag) ([]*Channel, error) // CreateGuildChannel 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. CreateGuildChannel(ctx context.Context, id Snowflake, name string, params *CreateGuildChannelParams, flags ...Flag) (*Channel, error) // UpdateGuildChannelPositions 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. UpdateGuildChannelPositions(ctx context.Context, id Snowflake, params []UpdateGuildChannelPositionsParams, flags ...Flag) error // GetMember Returns a guild member object for the specified user. GetMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (*Member, error) // GetMembers uses the GetGuildMembers endpoint iteratively until your query params are met. GetMembers(ctx context.Context, guildID Snowflake, params *GetMembersParams, flags ...Flag) ([]*Member, error) // AddGuildMember 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. AddGuildMember(ctx context.Context, guildID, userID Snowflake, accessToken string, params *AddGuildMemberParams, flags ...Flag) (*Member, error) // ModifyGuildMember Modify attributes of a guild member. Returns a 204 empty response on success. // Fires a Guild Member Update Gateway event. UpdateGuildMember(ctx context.Context, guildID, userID Snowflake, flags ...Flag) *updateGuildMemberBuilder // SetCurrentUserNick 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. SetCurrentUserNick(ctx context.Context, id Snowflake, nick string, flags ...Flag) (newNick string, err error) // AddGuildMemberRole 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. AddGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) error // RemoveGuildMemberRole 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. RemoveGuildMemberRole(ctx context.Context, guildID, userID, roleID Snowflake, flags ...Flag) error // RemoveGuildMember Remove a member from a guild. Requires 'KICK_MEMBERS' permission. // Returns a 204 empty response on success. Fires a Guild Member Remove Gateway event. KickMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) error // GetGuildBans Returns a list of ban objects for the users banned from this guild. Requires the 'BAN_MEMBERS' permission. GetGuildBans(ctx context.Context, id Snowflake, flags ...Flag) ([]*Ban, error) // GetGuildBan Returns a ban object for the given user or a 404 not found if the ban cannot be found. // Requires the 'BAN_MEMBERS' permission. GetGuildBan(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (*Ban, error) // BanMember 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. BanMember(ctx context.Context, guildID, userID Snowflake, params *BanMemberParams, flags ...Flag) error // UnbanMember 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. UnbanMember(ctx context.Context, guildID, userID Snowflake, reason string, flags ...Flag) error // GetGuildRoles Returns a list of role objects for the guild. GetGuildRoles(ctx context.Context, guildID Snowflake, flags ...Flag) ([]*Role, error) GetMemberPermissions(ctx context.Context, guildID, userID Snowflake, flags ...Flag) (permissions PermissionBits, err error) // CreateGuildRole 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. CreateGuildRole(ctx context.Context, id Snowflake, params *CreateGuildRoleParams, flags ...Flag) (*Role, error) // UpdateGuildRolePositions 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. UpdateGuildRolePositions(ctx context.Context, guildID Snowflake, params []UpdateGuildRolePositionsParams, flags ...Flag) ([]*Role, error) // ModifyGuildRole Modify a guild role. Requires the 'MANAGE_ROLES' permission. // Returns the updated role on success. Fires a Guild Role Update Gateway event. UpdateGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) (builder *updateGuildRoleBuilder) // DeleteGuildRole Delete a guild role. Requires the 'MANAGE_ROLES' permission. // Returns a 204 empty response on success. Fires a Guild Role Delete Gateway event. DeleteGuildRole(ctx context.Context, guildID, roleID Snowflake, flags ...Flag) error // EstimatePruneMembersCount 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. EstimatePruneMembersCount(ctx context.Context, id Snowflake, days int, flags ...Flag) (estimate int, err error) // PruneMembers Kicks members from N day back. Requires the 'KICK_MEMBERS' permission. // The estimate of kicked people is not returned. Use EstimatePruneMembersCount before calling PruneMembers // if you need it. Fires multiple Guild Member Remove Gateway events. PruneMembers(ctx context.Context, id Snowflake, days int, reason string, flags ...Flag) error // GetGuildVoiceRegions 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. GetGuildVoiceRegions(ctx context.Context, id Snowflake, flags ...Flag) ([]*VoiceRegion, error) // GetGuildInvites Returns a list of invite objects (with invite metadata) for the guild. // Requires the 'MANAGE_GUILD' permission. GetGuildInvites(ctx context.Context, id Snowflake, flags ...Flag) ([]*Invite, error) // GetGuildIntegrations Returns a list of integration objects for the guild. // Requires the 'MANAGE_GUILD' permission. GetGuildIntegrations(ctx context.Context, id Snowflake, flags ...Flag) ([]*Integration, error) // CreateGuildIntegration 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. CreateGuildIntegration(ctx context.Context, guildID Snowflake, params *CreateGuildIntegrationParams, flags ...Flag) error // UpdateGuildIntegration 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. UpdateGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, params *UpdateGuildIntegrationParams, flags ...Flag) error // DeleteGuildIntegration 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. DeleteGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) error // SyncGuildIntegration Sync an integration. Requires the 'MANAGE_GUILD' permission. // Returns a 204 empty response on success. SyncGuildIntegration(ctx context.Context, guildID, integrationID Snowflake, flags ...Flag) error // GetGuildEmbed Returns the guild embed object. Requires the 'MANAGE_GUILD' permission. GetGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) (*GuildEmbed, error) // UpdateGuildEmbed 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. UpdateGuildEmbed(ctx context.Context, guildID Snowflake, flags ...Flag) *updateGuildEmbedBuilder // GetGuildVanityURL Returns a partial invite object for guilds with that feature enabled. // Requires the 'MANAGE_GUILD' permission. GetGuildVanityURL(ctx context.Context, guildID Snowflake, flags ...Flag) (*PartialInvite, error) }
RESTGuild REST interface for all guild endpoints
type RESTInvite ¶ added in v0.16.6
type RESTInvite interface { // GetInvite Returns an invite object for the given code. GetInvite(ctx context.Context, inviteCode string, params URLQueryStringer, flags ...Flag) (*Invite, error) // DeleteInvite Delete an invite. Requires the MANAGE_CHANNELS permission. Returns an invite object on success. DeleteInvite(ctx context.Context, inviteCode string, flags ...Flag) (deleted *Invite, err error) }
RESTInvite REST interface for all invite endpoints
type RESTMessage ¶ added in v0.16.6
type RESTMessage interface { // GetMessages 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. GetMessages(ctx context.Context, channelID Snowflake, params *GetMessagesParams, flags ...Flag) ([]*Message, error) // GetMessage 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. GetMessage(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (ret *Message, err error) // CreateMessage 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. CreateMessage(ctx context.Context, channelID Snowflake, params *CreateMessageParams, flags ...Flag) (ret *Message, err error) // UpdateMessage 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. UpdateMessage(ctx context.Context, chanID, msgID Snowflake, flags ...Flag) *updateMessageBuilder SetMsgContent(ctx context.Context, chanID, msgID Snowflake, content string) (*Message, error) SetMsgEmbed(ctx context.Context, chanID, msgID Snowflake, embed *Embed) (*Message, error) // DeleteMessage 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. DeleteMessage(ctx context.Context, channelID, msgID Snowflake, flags ...Flag) (err error) // DeleteMessages 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. DeleteMessages(ctx context.Context, chanID Snowflake, params *DeleteMessagesParams, flags ...Flag) (err error) }
type RESTMethods ¶ added in v0.16.6
type RESTMethods interface { RESTAuditLogs RESTChannel RESTEmoji RESTGuild RESTInvite RESTUser RESTVoice RESTWebhook }
RESTer holds all the sub REST interfaces
type RESTReaction ¶ added in v0.16.6
type RESTReaction interface { // CreateReaction 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. CreateReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, flags ...Flag) (err error) // DeleteOwnReaction Delete a reaction the current user has made for the message. // Returns a 204 empty response on success. DeleteOwnReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, flags ...Flag) (err error) // DeleteUserReaction 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. DeleteUserReaction(ctx context.Context, channelID, messageID, userID Snowflake, emoji interface{}, flags ...Flag) (err error) // GetReaction Get a list of users that reacted with this emoji. Returns an array of user objects on success. GetReaction(ctx context.Context, channelID, messageID Snowflake, emoji interface{}, params URLQueryStringer, flags ...Flag) (reactors []*User, err error) // DeleteAllReactions Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' // permission to be present on the current user. DeleteAllReactions(ctx context.Context, channelID, messageID Snowflake, flags ...Flag) (err error) }
type RESTUser ¶ added in v0.16.6
type RESTUser interface { // GetCurrentUser Returns the user object of the requester's account. For OAuth2, this requires the identify // scope, which will return the object without an email, and optionally the email scope, which returns the object // with an email. GetCurrentUser(ctx context.Context, flags ...Flag) (*User, error) // GetUser Returns a user object for a given user Snowflake. GetUser(ctx context.Context, id Snowflake, flags ...Flag) (*User, error) // UpdateCurrentUser Modify the requester's user account settings. Returns a user object on success. UpdateCurrentUser(ctx context.Context, flags ...Flag) (builder *updateCurrentUserBuilder) // GetCurrentUserGuilds Returns a list of partial guild objects the current user is a member of. // Requires the guilds OAuth2 scope. GetCurrentUserGuilds(ctx context.Context, params *GetCurrentUserGuildsParams, flags ...Flag) (ret []*PartialGuild, err error) // LeaveGuild Leave a guild. Returns a 204 empty response on success. LeaveGuild(ctx context.Context, id Snowflake, flags ...Flag) (err error) // GetUserDMs Returns a list of DM channel objects. GetUserDMs(ctx context.Context, flags ...Flag) (ret []*Channel, err error) // CreateDM Create a new DM channel with a user. Returns a DM channel object. CreateDM(ctx context.Context, recipientID Snowflake, flags ...Flag) (ret *Channel, err error) // CreateGroupDM Create a new group DM channel with multiple users. Returns a DM channel object. // This endpoint was intended to be used with the now-deprecated GameBridge SDK. DMs created with this // endpoint will not be shown in the Discord Client CreateGroupDM(ctx context.Context, params *CreateGroupDMParams, flags ...Flag) (ret *Channel, err error) // GetUserConnections Returns a list of connection objects. Requires the connections OAuth2 scope. GetUserConnections(ctx context.Context, flags ...Flag) (ret []*UserConnection, err error) }
RESTUser REST interface for all user endpoints
type RESTVoice ¶ added in v0.16.6
type RESTVoice interface { // GetVoiceRegionsBuilder Returns an array of voice region objects that can be used when creating servers. GetVoiceRegions(ctx context.Context, flags ...Flag) ([]*VoiceRegion, error) }
RESTVoice REST interface for all voice endpoints
type RESTWebhook ¶ added in v0.16.6
type RESTWebhook interface { // CreateWebhook Create a new webhook. Requires the 'MANAGE_WEBHOOKS' permission. // Returns a webhook object on success. CreateWebhook(ctx context.Context, channelID Snowflake, params *CreateWebhookParams, flags ...Flag) (ret *Webhook, err error) // GetChannelWebhooks Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. GetChannelWebhooks(ctx context.Context, channelID Snowflake, flags ...Flag) (ret []*Webhook, err error) // GetGuildWebhooks Returns a list of guild webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. GetGuildWebhooks(ctx context.Context, guildID Snowflake, flags ...Flag) (ret []*Webhook, err error) // GetWebhook Returns the new webhook object for the given id. GetWebhook(ctx context.Context, id Snowflake, flags ...Flag) (ret *Webhook, err error) // GetWebhookWithToken Same as GetWebhook, except this call does not require authentication and // returns no user in the webhook object. GetWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (ret *Webhook, err error) // UpdateWebhook Modify a webhook. Requires the 'MANAGE_WEBHOOKS' permission. // Returns the updated webhook object on success. UpdateWebhook(ctx context.Context, id Snowflake, flags ...Flag) (builder *updateWebhookBuilder) // UpdateWebhookWithToken Same as UpdateWebhook, 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. UpdateWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) (builder *updateWebhookBuilder) // DeleteWebhook Delete a webhook permanently. User must be owner. Returns a 204 NO CONTENT response on success. DeleteWebhook(ctx context.Context, webhookID Snowflake, flags ...Flag) error // DeleteWebhookWithToken Same as DeleteWebhook, except this call does not require authentication. DeleteWebhookWithToken(ctx context.Context, id Snowflake, token string, flags ...Flag) error // ExecuteWebhook Trigger a webhook in Discord. ExecuteWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, URLSuffix string, flags ...Flag) error // ExecuteSlackWebhook Trigger a webhook in Discord from the Slack app. ExecuteSlackWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) error // ExecuteGitHubWebhook Trigger a webhook in Discord from the GitHub app. ExecuteGitHubWebhook(ctx context.Context, params *ExecuteWebhookParams, wait bool, flags ...Flag) error }
RESTWebhook REST interface for all Webhook endpoints
type Reaction ¶ added in v0.16.6
type Reaction struct { Lockable `json:"-"` Count uint `json:"count"` Me bool `json:"me"` Emoji *PartialEmoji `json:"Emoji"` }
Reaction ... https://discord.com/developers/docs/resources/channel#reaction-object
func (*Reaction) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type Ready ¶ added in v0.16.6
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"` sync.RWMutex `json:"-"` Ctx context.Context `json:"-"` ShardID uint `json:"-"` }
Ready contains the initial state information
type ReadyHandler ¶ added in v0.16.6
ReadyHandler is triggered in Ready events
type RequestGuildMembersPayload ¶ added in v0.16.6
type RequestGuildMembersPayload struct { // GuildID id of the guild(s) to get the members for GuildIDs []Snowflake // Query string that username starts with, or an empty string to return all members Query string // Limit maximum number of members to send or 0 to request all members matched Limit uint // UserIDs used to specify which users you wish to fetch UserIDs []Snowflake }
################################################################# RequestGuildMembersPayload payload for socket command REQUEST_GUILD_MEMBERS. See RequestGuildMembers
WARNING: If this request is in queue while a auto-scaling is forced, it will be removed from the queue and not re-inserted like the other commands. This is due to the guild id slice, which is a bit trickier to handle.
Wrapper for websocket.RequestGuildMembersPayload
type Reseter ¶ added in v0.16.6
type Reseter interface {
Reset()
}
Reseter Reset() zero initialises or empties a struct instance
type ResumedHandler ¶ added in v0.16.6
ResumedHandler is triggered in Resumed events
type Role ¶ added in v0.16.6
type Role struct { Lockable `json:"-"` ID Snowflake `json:"id"` Name string `json:"name"` Color uint `json:"color"` Hoist bool `json:"hoist"` Position int `json:"position"` // can be -1 Permissions uint64 `json:"permissions"` Managed bool `json:"managed"` Mentionable bool `json:"mentionable"` // contains filtered or unexported fields }
Role https://discord.com/developers/docs/topics/permissions#role-object
func (*Role) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*Role) DeepCopy ¶ added in v0.16.6
func (r *Role) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*Role) Mention ¶ added in v0.16.6
Mention gives a formatted version of the role such that it can be parsed by Discord clients
func (*Role) SetGuildID ¶ added in v0.16.6
SetGuildID link role to a guild before running session.SaveToDiscord(*Role)
type Session ¶
type Session interface { // Logger returns the injected logger instance. If nothing was injected, a empty wrapper is returned // to avoid nil panics. Logger() logger.Logger // Discord Gateway, web socket SocketHandler // HeartbeatLatency returns the avg. ish time used to send and receive a heartbeat signal. // The latency is calculated as such: // 0. start timer (start) // 1. send heartbeat signal // 2. wait until a heartbeat ack is sent by Discord // 3. latency = time.Now().Sub(start) // 4. avg = (avg + latency) / 2 // // This feature was requested. But should never be used as a proof for delay between client and Discord. AvgHeartbeatLatency() (duration time.Duration, err error) // returns the latency for each given shard id. shardID => latency HeartbeatLatencies() (latencies map[uint]time.Duration, err error) RESTRatelimitBuckets() (group map[string][]string) RESTBucketGrouping() (group map[string][]string) // Abstract REST methods for Discord structs DeleteFromDiscord(ctx context.Context, obj discordDeleter, flags ...Flag) error // AddPermission is to store the permissions required by the bot to function as intended. AddPermission(permission PermissionBit) (updatedPermissions PermissionBits) GetPermissions() (permissions PermissionBits) // CreateBotURL InviteURL(ctx context.Context) (url string, err error) Pool() *pools RESTMethods // Custom REST functions SendMsg(ctx context.Context, channelID Snowflake, data ...interface{}) (*Message, error) KickVoiceParticipant(ctx context.Context, guildID, userID Snowflake) error // Status update functions UpdateStatus(s *UpdateStatusPayload) error UpdateStatusString(s string) error GetGuilds(ctx context.Context, params *GetCurrentUserGuildsParams, flags ...Flag) ([]*Guild, error) GetConnectedGuilds() []Snowflake // 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.
type ShardConfig ¶ added in v0.16.6
type ShardConfig = gateway.ShardConfig
type SimpleHandler ¶ added in v0.16.6
type SimpleHandler = func(Session)
type SimplestHandler ¶ added in v0.16.6
type SimplestHandler = func()
these "simple" handler can be used, if you don't care about the actual event data
type Snowflake ¶ added in v0.16.6
Snowflake twitter snowflake identification for Discord
func GetSnowflake ¶ added in v0.16.6
GetSnowflake see snowflake.GetSnowflake
func NewSnowflake ¶ added in v0.16.6
NewSnowflake see snowflake.NewSnowflake
func ParseSnowflakeString ¶ added in v0.16.6
ParseSnowflakeString see snowflake.ParseSnowflakeString
type SocketHandler ¶ added in v0.16.6
type SocketHandler interface { // Disconnect closes the discord websocket connection Disconnect() error // Suspend temporary closes the socket connection, allowing resources to be // reused on reconnect Suspend() error // On creates a specification to be executed on the given event. The specification // consists of, in order, 0 or more middlewares, 1 or more handlers, 0 or 1 controller. // On incorrect ordering, or types, the method will panic. See reactor.go for types. // // Each of the three sub-types of a specification is run in sequence, as well as the specifications // registered for a event. However, the slice of specifications are executed in a goroutine to avoid // blocking future events. The middlewares allows manipulating the event data before it reaches the // handlers. The handlers executes short-running logic based on the event data (use go routine if // you need a long running task). The controller dictates lifetime of the specification. // // // a handler that is executed on every Ready event // Client.On(EvtReady, onReady) // // // a handler that runs only the first three times a READY event is fired // Client.On(EvtReady, onReady, &Ctrl{Runs: 3}) // // // a handler that only runs for events within the first 10 minutes // Client.On(EvtReady, onReady, &Ctrl{Duration: 10*time.Minute}) On(event string, inputs ...interface{}) SocketHandlerRegistrators // type safe handler registration Emitter }
SocketHandler all socket related logic
type SocketHandlerRegistrators ¶ added in v0.16.6
type SocketHandlerRegistrators interface { OnChannelCreate([]Middleware, []HandlerChannelCreate, ...HandlerCtrl) OnChannelDelete([]Middleware, []HandlerChannelDelete, ...HandlerCtrl) OnChannelPinsUpdate([]Middleware, []HandlerChannelPinsUpdate, ...HandlerCtrl) OnChannelUpdate([]Middleware, []HandlerChannelUpdate, ...HandlerCtrl) OnGuildBanAdd([]Middleware, []HandlerGuildBanAdd, ...HandlerCtrl) OnGuildBanRemove([]Middleware, []HandlerGuildBanRemove, ...HandlerCtrl) OnGuildCreate([]Middleware, []HandlerGuildCreate, ...HandlerCtrl) OnGuildDelete([]Middleware, []HandlerGuildDelete, ...HandlerCtrl) OnGuildEmojisUpdate([]Middleware, []HandlerGuildEmojisUpdate, ...HandlerCtrl) OnGuildIntegrationsUpdate([]Middleware, []HandlerGuildIntegrationsUpdate, ...HandlerCtrl) OnGuildMemberAdd([]Middleware, []HandlerGuildMemberAdd, ...HandlerCtrl) OnGuildMemberRemove([]Middleware, []HandlerGuildMemberRemove, ...HandlerCtrl) OnGuildMemberUpdate([]Middleware, []HandlerGuildMemberUpdate, ...HandlerCtrl) OnGuildMembersChunk([]Middleware, []HandlerGuildMembersChunk, ...HandlerCtrl) OnGuildRoleCreate([]Middleware, []HandlerGuildRoleCreate, ...HandlerCtrl) OnGuildRoleDelete([]Middleware, []HandlerGuildRoleDelete, ...HandlerCtrl) OnGuildRoleUpdate([]Middleware, []HandlerGuildRoleUpdate, ...HandlerCtrl) OnGuildUpdate([]Middleware, []HandlerGuildUpdate, ...HandlerCtrl) OnInviteCreate([]Middleware, []HandlerInviteCreate, ...HandlerCtrl) OnMessageCreate([]Middleware, []HandlerMessageCreate, ...HandlerCtrl) OnMessageDelete([]Middleware, []HandlerMessageDelete, ...HandlerCtrl) OnMessageDeleteBulk([]Middleware, []HandlerMessageDeleteBulk, ...HandlerCtrl) OnMessageReactionAdd([]Middleware, []HandlerMessageReactionAdd, ...HandlerCtrl) OnMessageReactionRemove([]Middleware, []HandlerMessageReactionRemove, ...HandlerCtrl) OnMessageReactionRemoveAll([]Middleware, []HandlerMessageReactionRemoveAll, ...HandlerCtrl) OnMessageUpdate([]Middleware, []HandlerMessageUpdate, ...HandlerCtrl) OnPresenceUpdate([]Middleware, []HandlerPresenceUpdate, ...HandlerCtrl) OnReady([]Middleware, []HandlerReady, ...HandlerCtrl) OnResumed([]Middleware, []HandlerResumed, ...HandlerCtrl) OnTypingStart([]Middleware, []HandlerTypingStart, ...HandlerCtrl) OnUserUpdate([]Middleware, []HandlerUserUpdate, ...HandlerCtrl) OnVoiceServerUpdate([]Middleware, []HandlerVoiceServerUpdate, ...HandlerCtrl) OnVoiceStateUpdate([]Middleware, []HandlerVoiceStateUpdate, ...HandlerCtrl) OnWebhooksUpdate([]Middleware, []HandlerWebhooksUpdate, ...HandlerCtrl) }
type Time ¶ added in v0.16.6
Time handles Discord timestamps
func (Time) MarshalJSON ¶ added in v0.16.6
MarshalJSON implements json.Marshaler. error: https://stackoverflow.com/questions/28464711/go-strange-json-hyphen-unmarshall-error
func (Time) String ¶ added in v0.16.6
String returns the timestamp as a Discord formatted timestamp. Formatting with time.RFC3331 does not suffice.
func (*Time) UnmarshalJSON ¶ added in v0.16.6
UnmarshalJSON implements json.Unmarshaler.
type TypingStart ¶ added in v0.16.6
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.16.6
type TypingStartHandler = func(s Session, h *TypingStart)
TypingStartHandler is triggered in TypingStart events
type URLQueryStringer ¶ added in v0.16.6
type URLQueryStringer interface {
URLQueryString() string
}
URLQueryStringer converts a struct of values to a valid URL query string
type UpdateChannelPermissionsParams ¶ added in v0.16.6
type UpdateChannelPermissionsParams struct { Allow PermissionBits `json:"allow"` // the bitwise value of all allowed permissions Deny PermissionBits `json:"deny"` // the bitwise value of all disallowed permissions Type string `json:"type"` // "member" for a user or "role" for a role }
UpdateChannelPermissionsParams https://discord.com/developers/docs/resources/channel#edit-channel-permissions-json-params
type UpdateGuildChannelPositionsParams ¶ added in v0.16.6
type UpdateGuildChannelPositionsParams struct { ID Snowflake `json:"id"` Position int `json:"position"` // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. // just reuse the string. Go will optimize it to point to the same memory anyways // TODO: improve this? Reason string `json:"-"` }
UpdateGuildChannelPositionsParams ... https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions-json-params
type UpdateGuildIntegrationParams ¶ added in v0.16.6
type UpdateGuildIntegrationParams struct { ExpireBehavior int `json:"expire_behavior"` ExpireGracePeriod int `json:"expire_grace_period"` EnableEmoticons bool `json:"enable_emoticons"` }
UpdateGuildIntegrationParams ... https://discord.com/developers/docs/resources/guild#modify-guild-integration-json-params TODO: currently unsure which are required/optional params
type UpdateGuildRolePositionsParams ¶ added in v0.16.6
type UpdateGuildRolePositionsParams struct { ID Snowflake `json:"id"` Position int `json:"position"` // Reason is a X-Audit-Log-Reason header field that will show up on the audit log for this action. Reason string `json:"-"` }
UpdateGuildRolePositionsParams ... https://discord.com/developers/docs/resources/guild#modify-guild-role-positions-json-params
func NewUpdateGuildRolePositionsParams ¶ added in v0.16.6
func NewUpdateGuildRolePositionsParams(rs []*Role) (p []UpdateGuildRolePositionsParams)
type UpdateStatusPayload ¶ added in v0.16.6
type UpdateStatusPayload struct { // Since unix time (in milliseconds) of when the Client went idle, or null if the Client is not idle Since *uint // Game null, or the user's new activity Game *Activity // Status the user's new status Status string // AFK whether or not the Client is afk AFK bool // contains filtered or unexported fields }
UpdateStatusPayload payload for socket command UPDATE_STATUS. see UpdateStatus
Wrapper for websocket.UpdateStatusPayload
type UpdateVoiceStatePayload ¶ added in v0.16.6
type UpdateVoiceStatePayload struct { // GuildID id of the guild GuildID Snowflake // ChannelID id of the voice channel Client wants to join // (0 if disconnecting) ChannelID Snowflake // SelfMute is the Client mute SelfMute bool // SelfDeaf is the Client deafened SelfDeaf bool }
UpdateVoiceStatePayload payload for socket command UPDATE_VOICE_STATE. see UpdateVoiceState
Wrapper for websocket.UpdateVoiceStatePayload
type User ¶ added in v0.16.6
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 (*User) AvatarURL ¶ added in v0.16.6
AvatarURL returns a link to the users avatar with the given size.
func (*User) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
func (*User) DeepCopy ¶ added in v0.16.6
func (u *User) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier CopyOverTo see interface at struct.go#Copier
func (*User) Mention ¶ added in v0.16.6
Mention returns the a string that Discord clients can format into a valid Discord mention
func (*User) SendMsg ¶ added in v0.16.6
func (u *User) SendMsg(ctx context.Context, 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.16.6
func (u *User) SendMsgString(ctx context.Context, 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.16.6
UnmarshalJSON see interface json.Unmarshaler
type UserConnection ¶ added in v0.16.6
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 (*UserConnection) CopyOverTo ¶ added in v0.16.6
func (c *UserConnection) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*UserConnection) DeepCopy ¶ added in v0.16.6
func (c *UserConnection) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
type UserPresence ¶ added in v0.16.6
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.16.6
func NewUserPresence() *UserPresence
NewUserPresence creates a new user presence instance
func (*UserPresence) CopyOverTo ¶ added in v0.16.6
func (p *UserPresence) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*UserPresence) DeepCopy ¶ added in v0.16.6
func (p *UserPresence) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*UserPresence) String ¶ added in v0.16.6
func (p *UserPresence) String() string
type UserUpdate ¶ added in v0.16.6
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.16.6
type UserUpdateHandler = func(s Session, h *UserUpdate)
UserUpdateHandler is triggered in UserUpdate events
type VerificationLvl ¶ added in v0.16.6
type VerificationLvl uint
VerificationLvl ... https://discord.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.16.6
func (vl *VerificationLvl) High() bool
High (╯°□°)╯︵ ┻━┻ - must be a member of the server for longer than 10 minutes
func (*VerificationLvl) Low ¶ added in v0.16.6
func (vl *VerificationLvl) Low() bool
Low must have verified email on account
func (*VerificationLvl) Medium ¶ added in v0.16.6
func (vl *VerificationLvl) Medium() bool
Medium must be registered on Discord for longer than 5 minutes
func (*VerificationLvl) None ¶ added in v0.16.6
func (vl *VerificationLvl) None() bool
None unrestricted
func (*VerificationLvl) VeryHigh ¶ added in v0.16.6
func (vl *VerificationLvl) VeryHigh() bool
VeryHigh ┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻ - must have a verified phone number
type VoiceConnection ¶ added in v0.16.6
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). // // if the bot has been disconnected or the channel removed, an error will be returned. The voice object must then be properly dealt with to avoid further issues. SendOpusFrame(data []byte) error // SendDCA reads from a Reader expecting a DCA encoded stream/file and sends them as frames. SendDCA(r io.Reader) error // MoveTo moves from the current voice channel to the given. MoveTo(channelID Snowflake) error // Close closes the websocket and UDP connection. This VoiceConnection interface will no // longer be usable. // 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.16.6
type VoiceHandler interface {
VoiceConnect(guildID, channelID Snowflake) (ret VoiceConnection, err error)
}
VoiceHandler holds all the voice connection related methods
type VoiceRegion ¶ added in v0.16.6
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://discord.com/developers/docs/resources/voice#voice-region
func (*VoiceRegion) CopyOverTo ¶ added in v0.16.6
func (v *VoiceRegion) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*VoiceRegion) DeepCopy ¶ added in v0.16.6
func (v *VoiceRegion) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*VoiceRegion) Reset ¶ added in v0.16.6
func (v *VoiceRegion) Reset()
type VoiceServerUpdate ¶ added in v0.16.6
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.16.6
type VoiceServerUpdateHandler = func(s Session, h *VoiceServerUpdate)
VoiceServerUpdateHandler is triggered in VoiceServerUpdate events
type VoiceState ¶ added in v0.16.6
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://discord.com/developers/docs/resources/voice#voice-state-object reviewed 2018-09-29
func (*VoiceState) CopyOverTo ¶ added in v0.16.6
func (v *VoiceState) CopyOverTo(other interface{}) (err error)
CopyOverTo see interface at struct.go#Copier
func (*VoiceState) DeepCopy ¶ added in v0.16.6
func (v *VoiceState) DeepCopy() (copy interface{})
DeepCopy see interface at struct.go#DeepCopier
func (*VoiceState) Reset ¶ added in v0.16.6
func (v *VoiceState) Reset()
type VoiceStateUpdate ¶ added in v0.16.6
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.16.6
type VoiceStateUpdateHandler = func(s Session, h *VoiceStateUpdate)
VoiceStateUpdateHandler is triggered in VoiceStateUpdate events
type Webhook ¶ added in v0.16.6
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://discord.com/developers/docs/resources/webhook#webhook-object
func (*Webhook) CopyOverTo ¶ added in v0.16.6
CopyOverTo see interface at struct.go#Copier
type WebhooksUpdate ¶ added in v0.16.6
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.16.6
type WebhooksUpdateHandler = func(s Session, h *WebhooksUpdate)
WebhooksUpdateHandler is triggered in WebhooksUpdate events
Source Files
¶
- auditlog.go
- cache.go
- channel.go
- client.go
- disgord.go
- embed.go
- emoji.go
- errors.go
- events.go
- events_gen.go
- flag.go
- flag_string.go
- gateway_commands.go
- guild.go
- iface_internalupdaters_gen.go
- iface_reseter_gen.go
- iface_urlquerystringer_gen.go
- invite.go
- locking.go
- logging.go
- message.go
- pool.go
- reaction.go
- reactor.go
- reactor_gen.go
- rest.go
- restbuilders_gen.go
- role.go
- session.go
- sort_gen.go
- struct.go
- user.go
- utils.go
- voice.go
- voiceconnection.go
- webhook.go
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
docs
|
|
generate
|
|
internal
|
|
endpoint
Package endpoint holds all discord urls for the REST endpoints
|
Package endpoint holds all discord urls for the REST endpoints |
event
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). |