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 client to get access to the REST API and gateway functionality. In the following example, we listen for new messages and respond with "hello".
Session interface: https://pkg.go.dev/github.com/andersfylling/disgord?tab=doc#Session
client := disgord.New(disgord.Config{ BotToken: "my-secret-bot-token", }) defer client.Gateway().StayConnectedUntilInterrupted() client.Gateway().MessageCreate(func(s disgord.Session, evt *disgord.MessageCreate) { evt.Message.Reply(context.Background(), s, "hello") })
Listen for events using Channels ¶
You don't have to use a callback function, channels are supported too!
msgChan := make(chan *disgord.MessageCreate, 10) client.Gateway().MessageCreateChan(msgChan)
Never close a channel without removing the handler from Disgord, as it will cause a panic. You can control the lifetime of a handler or injected channel by in injecting a controller: disgord.HandlerCtrl. Since you are the owner of the channel, disgord will never close it for you.
ctrl := &disgord.Ctrl{Channel: msgCreateChan} client.Gateway().WithCtrl(ctrl).MessageCreateChan(msgChan) go func() { // close the channel after 20 seconds and safely remove it from the Disgord reactor <- time.After(20 * time.Second) ctrl.CloseChannel() }
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 ¶
You can inject your own cache implementation. By default a read only LFU implementation is used, this should be sufficient for the average user. But you can overwrite certain methods as well!
Say you dislike the implementation for MESSAGE_CREATE events, you can embed the default cache and define your own logic:
type MyCoolCache struct { disgord.BasicCache msgCache map[Snowflake]*Message // channelID => Message } func (c *BasicCache) MessageCreate(data []byte) (*MessageCreate, error) { // some smart implementation here }
> Note: if you inject your own cache, remember that the cache is also responsible for initiating the objects. > See disgord.CacheNop
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 := client.User(userID).Get() // bypass the cache checking. Same as before, but we insert a disgord.Flag type. user, err := client.User(userID).Get(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
`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.
Index ¶
- Constants
- Variables
- func AllEvents() []string
- func AllEventsExcept(except ...string) []string
- func CreateTermSigListener() <-chan os.Signal
- func DeepCopy(cp DeepCopier) interface{}
- func DeepCopyOver(dst Copier, src Copier) error
- func LibraryInfo() string
- func Reset(r Reseter)
- func ShardID(guildID Snowflake, nrOfShards uint) uint
- func Sort(v interface{}, fs ...Flag)
- func ValidateUsername(name string) (err error)
- type Activity
- type ActivityAssets
- type ActivityEmoji
- type ActivityFlag
- type ActivityParty
- type ActivitySecrets
- type ActivityTimestamp
- type ActivityType
- type AddGuildMemberParams
- type AllowedMentions
- type ApplicationCommandInteractionData
- type ApplicationCommandInteractionDataOption
- type ApplicationCommandInteractionDataResolved
- type Attachment
- type AuditLog
- type AuditLogChange
- type AuditLogChanges
- type AuditLogEntry
- type AuditLogEvt
- type AuditLogOption
- type AvatarParamHolder
- type Ban
- type BanMemberParams
- type BasicBuilder
- type BasicCache
- func (c *BasicCache) ChannelCreate(data []byte) (*ChannelCreate, error)
- func (c *BasicCache) ChannelDelete(data []byte) (*ChannelDelete, error)
- func (c *BasicCache) ChannelPinsUpdate(data []byte) (*ChannelPinsUpdate, error)
- func (c *BasicCache) ChannelUpdate(data []byte) (*ChannelUpdate, error)
- func (c *BasicCache) GetChannel(id Snowflake) (*Channel, error)
- func (c *BasicCache) GetCurrentUser() (*User, error)
- func (c *BasicCache) GetGuild(id Snowflake) (*Guild, error)
- func (c *BasicCache) GetGuildChannels(id Snowflake) ([]*Channel, error)
- func (c *BasicCache) GetGuildEmoji(guildID, emojiID Snowflake) (*Emoji, error)
- func (c *BasicCache) GetGuildEmojis(id Snowflake) ([]*Emoji, error)
- func (c *BasicCache) GetGuildRoles(id Snowflake) ([]*Role, error)
- func (c *BasicCache) GetMember(guildID, userID Snowflake) (*Member, error)
- func (c *BasicCache) GetUser(id Snowflake) (*User, error)
- func (c *BasicCache) GuildCreate(data []byte) (*GuildCreate, error)
- func (c *BasicCache) GuildDelete(data []byte) (*GuildDelete, error)
- func (c *BasicCache) GuildMemberAdd(data []byte) (*GuildMemberAdd, error)
- func (c *BasicCache) GuildMemberRemove(data []byte) (*GuildMemberRemove, error)
- func (c *BasicCache) GuildMemberUpdate(data []byte) (evt *GuildMemberUpdate, err error)
- func (c *BasicCache) GuildMembersChunk(data []byte) (evt *GuildMembersChunk, err error)
- func (c *BasicCache) GuildRoleCreate(data []byte) (evt *GuildRoleCreate, err error)
- func (c *BasicCache) GuildRoleDelete(data []byte) (evt *GuildRoleDelete, err error)
- func (c *BasicCache) GuildRoleUpdate(data []byte) (evt *GuildRoleUpdate, err error)
- func (c *BasicCache) GuildUpdate(data []byte) (*GuildUpdate, error)
- func (c *BasicCache) MessageCreate(data []byte) (*MessageCreate, error)
- func (c *BasicCache) Ready(data []byte) (*Ready, error)
- func (c *BasicCache) UserUpdate(data []byte) (*UserUpdate, error)
- func (c *BasicCache) VoiceServerUpdate(data []byte) (*VoiceServerUpdate, error)
- type ButtonStyle
- type Cache
- type CacheGetter
- type CacheNop
- func (c *CacheNop) ChannelCreate(data []byte) (evt *ChannelCreate, err error)
- func (c *CacheNop) ChannelDelete(data []byte) (evt *ChannelDelete, err error)
- func (c *CacheNop) ChannelPinsUpdate(data []byte) (evt *ChannelPinsUpdate, err error)
- func (c *CacheNop) ChannelUpdate(data []byte) (evt *ChannelUpdate, err error)
- func (c *CacheNop) GetChannel(id Snowflake) (*Channel, error)
- func (c *CacheNop) GetCurrentUser() (*User, error)
- func (c *CacheNop) GetCurrentUserGuilds(p *GetCurrentUserGuildsParams) ([]*Guild, error)
- func (c *CacheNop) GetGuild(id Snowflake) (*Guild, error)
- func (c *CacheNop) GetGuildChannels(id Snowflake) ([]*Channel, error)
- func (c *CacheNop) GetGuildEmoji(guildID, emojiID Snowflake) (*Emoji, error)
- func (c *CacheNop) GetGuildEmojis(id Snowflake) ([]*Emoji, error)
- func (c *CacheNop) GetGuildRoles(guildID Snowflake) ([]*Role, error)
- func (c *CacheNop) GetMember(guildID, userID Snowflake) (*Member, error)
- func (c *CacheNop) GetMembers(guildID Snowflake, p *GetMembersParams) ([]*Member, error)
- func (c *CacheNop) GetMessage(channelID, messageID Snowflake) (*Message, error)
- func (c *CacheNop) GetMessages(channel Snowflake, p *GetMessagesParams) ([]*Message, error)
- func (c *CacheNop) GetUser(id Snowflake) (*User, error)
- func (c *CacheNop) GuildBanAdd(data []byte) (evt *GuildBanAdd, err error)
- func (c *CacheNop) GuildBanRemove(data []byte) (evt *GuildBanRemove, err error)
- func (c *CacheNop) GuildCreate(data []byte) (evt *GuildCreate, err error)
- func (c *CacheNop) GuildDelete(data []byte) (evt *GuildDelete, err error)
- func (c *CacheNop) GuildEmojisUpdate(data []byte) (evt *GuildEmojisUpdate, err error)
- func (c *CacheNop) GuildIntegrationsUpdate(data []byte) (evt *GuildIntegrationsUpdate, err error)
- func (c *CacheNop) GuildMemberAdd(data []byte) (evt *GuildMemberAdd, err error)
- func (c *CacheNop) GuildMemberRemove(data []byte) (evt *GuildMemberRemove, err error)
- func (c *CacheNop) GuildMemberUpdate(data []byte) (evt *GuildMemberUpdate, err error)
- func (c *CacheNop) GuildMembersChunk(data []byte) (evt *GuildMembersChunk, err error)
- func (c *CacheNop) GuildRoleCreate(data []byte) (evt *GuildRoleCreate, err error)
- func (c *CacheNop) GuildRoleDelete(data []byte) (evt *GuildRoleDelete, err error)
- func (c *CacheNop) GuildRoleUpdate(data []byte) (evt *GuildRoleUpdate, err error)
- func (c *CacheNop) GuildUpdate(data []byte) (evt *GuildUpdate, err error)
- func (c *CacheNop) InteractionCreate(data []byte) (evt *InteractionCreate, err error)
- func (c *CacheNop) InviteCreate(data []byte) (evt *InviteCreate, err error)
- func (c *CacheNop) InviteDelete(data []byte) (evt *InviteDelete, err error)
- func (c *CacheNop) MessageCreate(data []byte) (evt *MessageCreate, err error)
- func (c *CacheNop) MessageDelete(data []byte) (evt *MessageDelete, err error)
- func (c *CacheNop) MessageDeleteBulk(data []byte) (evt *MessageDeleteBulk, err error)
- func (c *CacheNop) MessageReactionAdd(data []byte) (evt *MessageReactionAdd, err error)
- func (c *CacheNop) MessageReactionRemove(data []byte) (evt *MessageReactionRemove, err error)
- func (c *CacheNop) MessageReactionRemoveAll(data []byte) (evt *MessageReactionRemoveAll, err error)
- func (c *CacheNop) MessageReactionRemoveEmoji(data []byte) (evt *MessageReactionRemoveEmoji, err error)
- func (c *CacheNop) MessageUpdate(data []byte) (evt *MessageUpdate, err error)
- func (c *CacheNop) Patch(v interface{})
- func (c *CacheNop) PresenceUpdate(data []byte) (evt *PresenceUpdate, err error)
- func (c *CacheNop) Ready(data []byte) (evt *Ready, err error)
- func (c *CacheNop) Resumed(data []byte) (evt *Resumed, err error)
- func (c *CacheNop) TypingStart(data []byte) (evt *TypingStart, err error)
- func (c *CacheNop) UserUpdate(data []byte) (evt *UserUpdate, err error)
- func (c *CacheNop) VoiceServerUpdate(data []byte) (evt *VoiceServerUpdate, err error)
- func (c *CacheNop) VoiceStateUpdate(data []byte) (evt *VoiceStateUpdate, err error)
- func (c *CacheNop) WebhooksUpdate(data []byte) (evt *WebhooksUpdate, err error)
- type CacheUpdater
- type Channel
- func (c *Channel) Compare(other *Channel) bool
- func (c *Channel) GetPermissions(ctx context.Context, s GuildQueryBuilderCaller, member *Member, flags ...Flag) (permissions PermissionBit, err error)
- func (c *Channel) Mention() string
- func (c *Channel) SendMsg(ctx context.Context, s Session, message *Message) (msg *Message, err error)
- func (c *Channel) SendMsgString(ctx context.Context, s Session, content string) (msg *Message, err error)
- func (c *Channel) String() string
- type ChannelCreate
- type ChannelDelete
- type ChannelPinsUpdate
- type ChannelQueryBuilder
- type ChannelType
- type ChannelUpdate
- type Client
- func (c *Client) AddPermission(permission PermissionBit) (updatedPermissions PermissionBit)
- func (c *Client) AvgHeartbeatLatency() (duration time.Duration, err error)
- func (c Client) BotAuthorizeURL() (*url.URL, error)
- func (c *Client) Cache() Cache
- func (c Client) Channel(id Snowflake) ChannelQueryBuilder
- func (c Client) CreateGuild(guildName string, params *CreateGuildParams, flags ...Flag) (ret *Guild, err error)
- func (c Client) CurrentUser() CurrentUserQueryBuilder
- func (c *Client) EditInteractionResponse(ctx context.Context, interaction *InteractionCreate, message *Message) error
- func (c *Client) Gateway() GatewayQueryBuilder
- func (c *Client) GetConnectedGuilds() []Snowflake
- func (c *Client) GetPermissions() (permissions PermissionBit)
- func (c Client) GetVoiceRegions(flags ...Flag) (regions []*VoiceRegion, err error)
- func (c Client) Guild(id Snowflake) GuildQueryBuilder
- func (c *Client) HeartbeatLatencies() (latencies map[uint]time.Duration, err error)
- func (c Client) Invite(code string) InviteQueryBuilder
- func (c *Client) Logger() logger.Logger
- func (c *Client) Pool() *pools
- func (c *Client) RESTRatelimitBuckets() (group map[string][]string)
- func (c *Client) SendInteractionResponse(ctx context.Context, interaction *InteractionCreate, data *InteractionResponse) error
- func (c Client) SendMsg(channelID Snowflake, data ...interface{}) (msg *Message, err error)
- func (c *Client) String() string
- func (c *Client) UpdateStatus(s *UpdateStatusPayload) error
- func (c *Client) UpdateStatusString(s string) error
- func (c Client) User(id Snowflake) UserQueryBuilder
- func (c Client) Webhook(id Snowflake) WebhookQueryBuilder
- func (c Client) WithContext(ctx context.Context) ClientQueryBuilderExecutables
- type ClientQueryBuilder
- type ClientQueryBuilderExecutables
- type ClientStatus
- type CloseConnectionErr
- type Config
- type Copier
- type CreateChannelInviteBuilder
- type CreateDMBuilder
- type CreateGroupDMBuilder
- type CreateGroupDMParams
- type CreateGuildChannelParams
- type CreateGuildEmojiBuilder
- type CreateGuildEmojiParams
- type CreateGuildIntegrationParams
- type CreateGuildParams
- type CreateGuildRoleParams
- type CreateMessageFileParams
- type CreateMessageParams
- type CreateWebhookParams
- type Ctrl
- type CurrentUserQueryBuilder
- type DeepCopier
- type DefaultMessageNotificationLvl
- type DeleteMessagesParams
- type Discriminator
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedType
- type EmbedVideo
- type Emoji
- type Err
- type ErrRest
- type ErrorEmptyValue
- type ErrorMissingSnowflake
- type ErrorUnsupportedType
- type EventType
- type ExecuteWebhookParams
- type ExplicitContentFilterLvl
- type Flag
- type GatewayQueryBuilder
- type GetCurrentUserGuildsBuilder
- type GetCurrentUserGuildsParams
- type GetMembersParams
- type GetMessagesParams
- type GetReactionURLParams
- type GetUserBuilder
- type GetUserConnectionsBuilder
- type GetUserDMsBuilder
- 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) 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) Member(id Snowflake) (*Member, error)
- func (g *Guild) MembersByName(name string) (members []*Member)
- func (g *Guild) Role(id Snowflake) (*Role, error)
- func (g *Guild) RoleByName(name string) ([]*Role, error)
- func (g *Guild) String() string
- type GuildAuditLogsBuilder
- type GuildBanAdd
- type GuildBanRemove
- type GuildCreate
- type GuildDelete
- type GuildEmbed
- type GuildEmojiQueryBuilder
- type GuildEmojisUpdate
- type GuildIntegrationsUpdate
- type GuildMemberAdd
- type GuildMemberQueryBuilder
- type GuildMemberRemove
- type GuildMemberUpdate
- type GuildMembersChunk
- type GuildQueryBuilder
- type GuildQueryBuilderCaller
- type GuildRoleCreate
- type GuildRoleDelete
- type GuildRoleQueryBuilder
- type GuildRoleUpdate
- type GuildUnavailable
- type GuildUpdate
- 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 HandlerInteractionCreate
- type HandlerInviteCreate
- type HandlerInviteDelete
- type HandlerMessageCreate
- type HandlerMessageDelete
- type HandlerMessageDeleteBulk
- type HandlerMessageReactionAdd
- type HandlerMessageReactionRemove
- type HandlerMessageReactionRemoveAll
- type HandlerMessageReactionRemoveEmoji
- type HandlerMessageUpdate
- type HandlerPresenceUpdate
- type HandlerReady
- type HandlerResumed
- type HandlerSimple
- type HandlerSimplest
- type HandlerSpecErr
- type HandlerTypingStart
- type HandlerUserUpdate
- type HandlerVoiceServerUpdate
- type HandlerVoiceStateUpdate
- type HandlerWebhooksUpdate
- type HttpClientDoer
- type Integration
- type IntegrationAccount
- type Intent
- type InteractionApplicationCommandCallbackData
- type InteractionCallbackType
- type InteractionCreate
- type InteractionResponse
- type InteractionType
- type Invite
- type InviteCreate
- type InviteDelete
- type InviteMetadata
- type InviteQueryBuilder
- type Logger
- type MFALvl
- type Member
- func (m *Member) GetPermissions(ctx context.Context, s GuildQueryBuilderCaller, flags ...Flag) (permissions PermissionBit, err error)
- func (m *Member) GetUser(ctx context.Context, session Session) (usr *User, err error)
- func (m *Member) Mention() string
- func (m *Member) String() string
- func (m *Member) UpdateNick(ctx context.Context, client GuildQueryBuilderCaller, nickname string, ...) error
- type MentionChannel
- type Mentioner
- type Message
- 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, s Session, data ...interface{}) (*Message, error)
- func (m *Message) Send(ctx context.Context, s Session, 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 MessageComponent
- type MessageComponentType
- type MessageCreate
- type MessageDelete
- type MessageDeleteBulk
- type MessageFlag
- type MessageInteraction
- type MessageQueryBuilder
- type MessageReactionAdd
- type MessageReactionRemove
- type MessageReactionRemoveAll
- type MessageReactionRemoveEmoji
- type MessageReference
- type MessageSticker
- type MessageStickerFormatType
- type MessageType
- type MessageUpdate
- type Middleware
- type OptionType
- type PartialBan
- type PartialChannel
- type PartialEmoji
- type PartialInvite
- type PermissionBit
- type PermissionOverwrite
- type PermissionOverwriteType
- type Pool
- type PremiumTier
- type PremiumType
- type PresenceUpdate
- type RESTBuilder
- type Reaction
- type ReactionQueryBuilder
- type Ready
- type RequestGuildMembersPayload
- type Reseter
- type Resumed
- type Role
- type Session
- type ShardConfig
- type Snowflake
- type SocketHandlerRegistrator
- type StickerItem
- type Time
- type TypingStart
- type URLQueryStringer
- type UpdateChannelBuilder
- type UpdateChannelPermissionsParams
- type UpdateCurrentUserBuilder
- type UpdateGuildBuilder
- type UpdateGuildChannelPositionsParams
- type UpdateGuildEmbedBuilder
- type UpdateGuildEmojiBuilder
- type UpdateGuildIntegrationParams
- type UpdateGuildMemberBuilder
- type UpdateGuildRoleBuilder
- type UpdateGuildRolePositionsParams
- type UpdateMessageBuilder
- type UpdateStatusPayload
- type UpdateVoiceStatePayload
- type UpdateWebhookBuilder
- type User
- func (u *User) AvatarURL(size int, preferGIF bool) (url string, err error)
- func (u *User) Mention() string
- 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) Valid() bool
- type UserConnection
- type UserFlag
- type UserPresence
- type UserQueryBuilder
- type UserUpdate
- type VerificationLvl
- type VoiceChannelQueryBuilder
- type VoiceConnection
- type VoiceRegion
- type VoiceServerUpdate
- type VoiceState
- type VoiceStateUpdate
- type Webhook
- type WebhookQueryBuilder
- type WebhookWithTokenQueryBuilder
- type WebhooksUpdate
Constants ¶
const ( PermissionOverwriteTypeRole uint8 = iota PermissionOverwriteTypeMember )
Deprecated: use PermissionOverwrite* instead (note the Type keyword is removed) PermissionOverwriteTypeMember => PermissionOverwriteMember
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 = gateway.StatusOnline StatusOffline = gateway.StatusOffline StatusDnd = gateway.StatusDND StatusIdle = 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 ( IntentDirectMessageReactions = gateway.IntentDirectMessageReactions IntentDirectMessageTyping = gateway.IntentDirectMessageTyping IntentDirectMessages = gateway.IntentDirectMessages IntentGuildBans = gateway.IntentGuildBans IntentGuildEmojis = gateway.IntentGuildEmojis IntentGuildIntegrations = gateway.IntentGuildIntegrations IntentGuildInvites = gateway.IntentGuildInvites IntentGuildMembers = gateway.IntentGuildMembers IntentGuildMessageReactions = gateway.IntentGuildMessageReactions IntentGuildMessageTyping = gateway.IntentGuildMessageTyping IntentGuildMessages = gateway.IntentGuildMessages IntentGuildPresences = gateway.IntentGuildPresences IntentGuildVoiceStates = gateway.IntentGuildVoiceStates IntentGuildWebhooks = gateway.IntentGuildWebhooks IntentGuilds = gateway.IntentGuilds )
const ( MessageActivityTypeJoin MessageActivityTypeSpectate MessageActivityTypeListen MessageActivityTypeJoinRequest )
different message activity types
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.
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.
const EvtGuildIntegrationsUpdate = event.GuildIntegrationsUpdate
EvtGuildIntegrationsUpdate Sent when a guild integration is updated.
const EvtGuildMemberAdd = event.GuildMemberAdd
EvtGuildMemberAdd Sent when a new user joins a guild.
const EvtGuildMemberRemove = event.GuildMemberRemove
EvtGuildMemberRemove Sent when a user is removed from a guild (leave/kick/ban).
const EvtGuildMemberUpdate = event.GuildMemberUpdate
EvtGuildMemberUpdate Sent when a guild member is updated.
const EvtGuildMembersChunk = event.GuildMembersChunk
EvtGuildMembersChunk Sent in response to Gateway Request Guild Members.
const EvtGuildRoleCreate = event.GuildRoleCreate
EvtGuildRoleCreate Sent when a guild role is created.
const EvtGuildRoleDelete = event.GuildRoleDelete
EvtGuildRoleDelete Sent when a guild role is created.
const EvtGuildRoleUpdate = event.GuildRoleUpdate
EvtGuildRoleUpdate Sent when a guild role is created.
const EvtGuildUpdate = event.GuildUpdate
EvtGuildUpdate Sent when a guild is updated. The inner payload is a guild object.
const EvtInteractionCreate = event.InteractionCreate
EvtInteractionCreate Sent when a user in a guild uses a Slash Command.
const EvtInviteCreate = event.InviteCreate
EvtInviteCreate Sent when a guild's invite is created.
const EvtInviteDelete = event.InviteDelete
EvtInviteDelete Sent when an invite is deleted.
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.
const EvtMessageDeleteBulk = event.MessageDeleteBulk
EvtMessageDeleteBulk Sent when multiple messages are deleted at once.
const EvtMessageReactionAdd = event.MessageReactionAdd
EvtMessageReactionAdd Sent when a user adds a reaction to a message.
const EvtMessageReactionRemove = event.MessageReactionRemove
EvtMessageReactionRemove Sent when a user removes a reaction from a message.
const EvtMessageReactionRemoveAll = event.MessageReactionRemoveAll
EvtMessageReactionRemoveAll Sent when a user explicitly removes all reactions from a message.
const EvtMessageReactionRemoveEmoji = event.MessageReactionRemoveEmoji
EvtMessageReactionRemoveEmoji Sent when a bot removes all instances of a given emoji from the reactions of a message.
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.
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.
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).
const EvtTypingStart = event.TypingStart
EvtTypingStart Sent when a user starts typing in a channel.
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.
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.
const Name = constant.Name
const Version = constant.Version
Variables ¶
var CacheEntryAlreadyExistsErr = errors.New("cache entry already exists")
var CacheMissErr = errors.New("no matching entry found in cache")
var DefaultHttpClient = &http.Client{}
Functions ¶
func AllEventsExcept ¶ added in v0.21.0
func CreateTermSigListener ¶ added in v0.16.3
CreateTermSigListener create a channel to listen for termination signals (graceful shutdown)
func DeepCopy ¶ added in v0.21.0
func DeepCopy(cp DeepCopier) interface{}
func DeepCopyOver ¶ added in v0.21.0
func ShardID ¶ added in v0.12.0
ShardID calculate the shard id for a given guild. https://discord.com/developers/docs/topics/gateway#sharding-sharding-formula
func ValidateUsername ¶ added in v0.8.0
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.8.0
type Activity struct { Name string `json:"name"` Type ActivityType `json:"type"` URL string `json:"url,omitempty"` CreatedAt int `json:"created_at"` Timestamps *ActivityTimestamp `json:"timestamps,omitempty"` ApplicationID Snowflake `json:"application_id,omitempty"` Details string `json:"details,omitempty"` State string `json:"state,omitempty"` Emoji *ActivityEmoji `json:"emoji,omitempty"` Party *ActivityParty `json:"party,omitempty"` Assets *ActivityAssets `json:"assets,omitempty"` Secrets *ActivitySecrets `json:"secrets,omitempty"` Instance bool `json:"instance,omitempty"` Flags ActivityFlag `json:"flags,omitempty"` }
Activity https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
type ActivityAssets ¶ added in v0.7.0
type ActivityAssets struct { 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 ...
type ActivityEmoji ¶ added in v0.14.1
type ActivityEmoji struct { Name string `json:"name"` ID Snowflake `json:"id,omitempty"` Animated bool `json:"animated,omitempty"` }
ActivityEmoji ...
type ActivityFlag ¶ added in v0.25.0
type ActivityFlag uint
ActivityFlag https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
const ( ActivityFlagInstance ActivityFlag = 1 << iota ActivityFlagJoin ActivityFlagSpectate ActivityFlagJoinRequest ActivityFlagSync ActivityFlagPlay )
flags for the Activity object to signify the type of action taken place
type ActivityParty ¶ added in v0.7.0
type ActivityParty struct { 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) Limit ¶ added in v0.7.0
func (ap *ActivityParty) Limit() int
Limit shows the maximum number of guests/people allowed
func (*ActivityParty) NumberOfPeople ¶ added in v0.7.0
func (ap *ActivityParty) NumberOfPeople() int
NumberOfPeople shows the current number of people attending the Party
type ActivitySecrets ¶ added in v0.7.0
type ActivitySecrets struct { 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 ...
type ActivityTimestamp ¶ added in v0.7.0
type ActivityTimestamp struct { 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 ...
type ActivityType ¶ added in v0.25.0
type ActivityType uint
ActivityType https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
const ( ActivityTypeGame ActivityType = iota ActivityTypeStreaming ActivityTypeListening ActivityTypeCustom ActivityTypeCompeting )
type AddGuildMemberParams ¶ added in v0.6.0
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 AllowedMentions ¶ added in v0.19.0
type AllowedMentions struct { Parse []string `json:"parse"` // this is purposefully not marked as omitempty as to allow `parse: []` which blocks all mentions. Roles []Snowflake `json:"roles,omitempty"` Users []Snowflake `json:"users,omitempty"` RepliedUser bool `json:"replied_user,omitempty"` }
AllowedMentions allows finer control over mentions in a message, see https://discord.com/developers/docs/resources/channel#allowed-mentions-object for more info. Any strings in the Parse value must be any from ["everyone", "users", "roles"].
type ApplicationCommandInteractionData ¶ added in v0.27.0
type ApplicationCommandInteractionData struct { ID Snowflake `json:"id"` Name string `json:"name"` Resolved []*ApplicationCommandInteractionDataResolved `json:"resolved"` Options []*ApplicationCommandInteractionDataOption `json:"options"` CustomID string `json:"custom_id"` Type MessageComponentType `json:"component_type"` }
type ApplicationCommandInteractionDataOption ¶ added in v0.27.0
type ApplicationCommandInteractionDataOption struct { Name string `json:"name"` Type OptionType `json:"type"` Options []*ApplicationCommandInteractionDataOption `json:"options"` }
type ApplicationCommandInteractionDataResolved ¶ added in v0.27.0
type ApplicationCommandInteractionDataResolved struct { }
TODO ApplicationCommandInteractionDataResolved https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataresolved
type Attachment ¶ added in v0.6.0
type Attachment struct { ID Snowflake `json:"id"` Filename string `json:"filename"` Size uint `json:"size"` URL string `json:"url"` ProxyURL string `json:"proxy_url"` Height uint `json:"height"` Width uint `json:"width"` SpoilerTag bool `json:"-"` }
Attachment https://discord.com/developers/docs/resources/channel#attachment-object
type AuditLog ¶ added in v0.6.0
type AuditLog struct { Webhooks []*Webhook `json:"webhooks"` Users []*User `json:"users"` AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"` }
AuditLog ...
func (*AuditLog) Bans ¶ added in v0.10.0
func (l *AuditLog) Bans() (bans []*PartialBan)
type AuditLogChange ¶ added in v0.6.0
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.10.0
type AuditLogChanges struct { NewValue interface{} `json:"new_value,omitempty"` OldValue interface{} `json:"old_value,omitempty"` Key string `json:"key"` }
AuditLogChanges ...
type AuditLogEntry ¶ added in v0.6.0
type AuditLogEntry struct { 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 ...
type AuditLogEvt ¶ added in v0.10.0
type AuditLogEvt uint
const ( AuditLogEvtChannelCreate AuditLogEvt = 10 + iota AuditLogEvtChannelUpdate AuditLogEvtChannelDelete AuditLogEvtOverwriteCreate AuditLogEvtOverwriteUpdate AuditLogEvtOverwriteDelete )
const ( AuditLogEvtMemberKick AuditLogEvt = 20 + iota AuditLogEvtMemberPrune AuditLogEvtMemberBanAdd AuditLogEvtMemberBanRemove AuditLogEvtMemberUpdate AuditLogEvtMemberRoleUpdate AuditLogEvtMemberMove AuditLogEvtMemberDisconnect AuditLogEvtBotAdd )
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.6.0
type AuditLogOption struct { 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 ...
type AvatarParamHolder ¶ added in v0.8.0
type AvatarParamHolder interface { json.Marshaler Empty() bool SetAvatar(avatar string) UseDefaultAvatar() }
AvatarParamHolder is used when handling avatar related REST structs. since a Avatar can be reset by using nil, it causes some extra issues as omit empty cannot be used to get around this, the struct requires an internal state and must also handle custom marshalling
type Ban ¶ added in v0.6.0
Ban https://discord.com/developers/docs/resources/guild#ban-object
type BanMemberParams ¶ added in v0.10.0
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.10.0
func (b *BanMemberParams) FindErrors() error
func (*BanMemberParams) URLQueryString ¶ added in v0.10.0
func (b *BanMemberParams) URLQueryString() string
type BasicBuilder ¶ added in v0.19.0
type BasicBuilder interface { Execute() (err error) IgnoreCache() BasicBuilder CancelOnRatelimit() BasicBuilder URLParam(name string, v interface{}) BasicBuilder Set(name string, v interface{}) BasicBuilder }
BasicBuilder is the interface for the builder.
type BasicCache ¶ added in v0.27.0
type BasicCache struct { CacheNop CurrentUserMu sync.Mutex CurrentUser *User Users usersCache VoiceStates voiceStateCache Channels channelsCache Guilds guildsCache // contains filtered or unexported fields }
BasicCache cache with CRS support for Users and voice states use NewCacheLFUImmutable to instantiate it!
func NewBasicCache ¶ added in v0.27.0
func NewBasicCache() *BasicCache
func (*BasicCache) ChannelCreate ¶ added in v0.27.0
func (c *BasicCache) ChannelCreate(data []byte) (*ChannelCreate, error)
func (*BasicCache) ChannelDelete ¶ added in v0.27.0
func (c *BasicCache) ChannelDelete(data []byte) (*ChannelDelete, error)
func (*BasicCache) ChannelPinsUpdate ¶ added in v0.27.0
func (c *BasicCache) ChannelPinsUpdate(data []byte) (*ChannelPinsUpdate, error)
func (*BasicCache) ChannelUpdate ¶ added in v0.27.0
func (c *BasicCache) ChannelUpdate(data []byte) (*ChannelUpdate, error)
func (*BasicCache) GetChannel ¶ added in v0.27.0
func (c *BasicCache) GetChannel(id Snowflake) (*Channel, error)
func (*BasicCache) GetCurrentUser ¶ added in v0.27.0
func (c *BasicCache) GetCurrentUser() (*User, error)
func (*BasicCache) GetGuild ¶ added in v0.27.0
func (c *BasicCache) GetGuild(id Snowflake) (*Guild, error)
func (*BasicCache) GetGuildChannels ¶ added in v0.27.0
func (c *BasicCache) GetGuildChannels(id Snowflake) ([]*Channel, error)
func (*BasicCache) GetGuildEmoji ¶ added in v0.27.0
func (c *BasicCache) GetGuildEmoji(guildID, emojiID Snowflake) (*Emoji, error)
func (*BasicCache) GetGuildEmojis ¶ added in v0.27.0
func (c *BasicCache) GetGuildEmojis(id Snowflake) ([]*Emoji, error)
func (*BasicCache) GetGuildRoles ¶ added in v0.27.0
func (c *BasicCache) GetGuildRoles(id Snowflake) ([]*Role, error)
func (*BasicCache) GetMember ¶ added in v0.27.0
func (c *BasicCache) GetMember(guildID, userID Snowflake) (*Member, error)
GetMember fetches member and related user data from cache. User is not guaranteed to be populated. Tip: use Member.GetUser(..) instead of Member.User
func (*BasicCache) GetUser ¶ added in v0.27.0
func (c *BasicCache) GetUser(id Snowflake) (*User, error)
func (*BasicCache) GuildCreate ¶ added in v0.27.0
func (c *BasicCache) GuildCreate(data []byte) (*GuildCreate, error)
func (*BasicCache) GuildDelete ¶ added in v0.27.0
func (c *BasicCache) GuildDelete(data []byte) (*GuildDelete, error)
func (*BasicCache) GuildMemberAdd ¶ added in v0.27.0
func (c *BasicCache) GuildMemberAdd(data []byte) (*GuildMemberAdd, error)
func (*BasicCache) GuildMemberRemove ¶ added in v0.27.0
func (c *BasicCache) GuildMemberRemove(data []byte) (*GuildMemberRemove, error)
func (*BasicCache) GuildMemberUpdate ¶ added in v0.27.0
func (c *BasicCache) GuildMemberUpdate(data []byte) (evt *GuildMemberUpdate, err error)
func (*BasicCache) GuildMembersChunk ¶ added in v0.27.0
func (c *BasicCache) GuildMembersChunk(data []byte) (evt *GuildMembersChunk, err error)
func (*BasicCache) GuildRoleCreate ¶ added in v0.27.0
func (c *BasicCache) GuildRoleCreate(data []byte) (evt *GuildRoleCreate, err error)
func (*BasicCache) GuildRoleDelete ¶ added in v0.27.0
func (c *BasicCache) GuildRoleDelete(data []byte) (evt *GuildRoleDelete, err error)
func (*BasicCache) GuildRoleUpdate ¶ added in v0.27.0
func (c *BasicCache) GuildRoleUpdate(data []byte) (evt *GuildRoleUpdate, err error)
func (*BasicCache) GuildUpdate ¶ added in v0.27.0
func (c *BasicCache) GuildUpdate(data []byte) (*GuildUpdate, error)
func (*BasicCache) MessageCreate ¶ added in v0.27.0
func (c *BasicCache) MessageCreate(data []byte) (*MessageCreate, error)
func (*BasicCache) UserUpdate ¶ added in v0.27.0
func (c *BasicCache) UserUpdate(data []byte) (*UserUpdate, error)
func (*BasicCache) VoiceServerUpdate ¶ added in v0.27.0
func (c *BasicCache) VoiceServerUpdate(data []byte) (*VoiceServerUpdate, error)
type ButtonStyle ¶ added in v0.27.0
type ButtonStyle = int
const ( Primary ButtonStyle Secondary Success Danger Link )
type Cache ¶ added in v0.6.0
type Cache interface { CacheUpdater CacheGetter }
Cache interface for event handling and REST methods commented out fields are simply not supported yet. PR's are welcome
Note that on events you are expected to return a unmarshalled object. For delete methods you should return nil, and a nil error if the objected to be deleted was not found (nop!). Note that the error might change to a "CacheMiss" or something similar such that we can
get more metrics!
type CacheGetter ¶ added in v0.19.0
type CacheGetter interface { // GetGuildAuditLogs(guildID Snowflake) *guildAuditLogsBuilder // TODO GetMessages(channelID Snowflake, params *GetMessagesParams) ([]*Message, error) GetMessage(channelID, messageID Snowflake) (ret *Message, err error) //GetUsersWhoReacted(channelID, messageID Snowflake, emoji interface{}, params URLQueryStringer) (reactors []*User, err error) //GetPinnedMessages(channelID Snowflake) (ret []*Message, err error) GetChannel(id Snowflake) (ret *Channel, err error) //GetChannelInvites(id Snowflake) (ret []*Invite, err error) GetGuildEmoji(guildID, emojiID Snowflake) (*Emoji, error) GetGuildEmojis(id Snowflake) ([]*Emoji, error) GetGuild(id Snowflake) (*Guild, error) GetGuildChannels(id Snowflake) ([]*Channel, error) GetMember(guildID, userID Snowflake) (*Member, error) GetMembers(guildID Snowflake, params *GetMembersParams) ([]*Member, error) //GetGuildBans(id Snowflake) ([]*Ban, error) //GetGuildBan(guildID, userID Snowflake) (*Ban, error) GetGuildRoles(guildID Snowflake) ([]*Role, error) //GetMemberPermissions(guildID, userID Snowflake) (permissions PermissionBit, err error) //GetGuildVoiceRegions(id Snowflake) ([]*VoiceRegion, error) //GetGuildInvites(id Snowflake) ([]*Invite, error) //GetGuildIntegrations(id Snowflake) ([]*Integration, error) //GetGuildEmbed(guildID Snowflake) (*GuildEmbed, error) //GetGuildVanityURL(guildID Snowflake) (*PartialInvite, error) //GetInvite(inviteCode string, params URLQueryStringer) (*Invite, error) GetCurrentUser() (*User, error) GetUser(id Snowflake) (*User, error) GetCurrentUserGuilds(params *GetCurrentUserGuildsParams) (ret []*Guild, err error) }
type CacheNop ¶ added in v0.19.0
type CacheNop struct{}
nop cache
func (*CacheNop) ChannelCreate ¶ added in v0.19.0
func (c *CacheNop) ChannelCreate(data []byte) (evt *ChannelCreate, err error)
func (*CacheNop) ChannelDelete ¶ added in v0.19.0
func (c *CacheNop) ChannelDelete(data []byte) (evt *ChannelDelete, err error)
func (*CacheNop) ChannelPinsUpdate ¶ added in v0.19.0
func (c *CacheNop) ChannelPinsUpdate(data []byte) (evt *ChannelPinsUpdate, err error)
func (*CacheNop) ChannelUpdate ¶ added in v0.19.0
func (c *CacheNop) ChannelUpdate(data []byte) (evt *ChannelUpdate, err error)
func (*CacheNop) GetChannel ¶ added in v0.19.0
func (*CacheNop) GetCurrentUser ¶ added in v0.19.0
func (*CacheNop) GetCurrentUserGuilds ¶ added in v0.19.0
func (c *CacheNop) GetCurrentUserGuilds(p *GetCurrentUserGuildsParams) ([]*Guild, error)
func (*CacheNop) GetGuildChannels ¶ added in v0.19.0
func (*CacheNop) GetGuildEmoji ¶ added in v0.19.0
func (*CacheNop) GetGuildEmojis ¶ added in v0.19.0
func (*CacheNop) GetGuildRoles ¶ added in v0.19.0
func (*CacheNop) GetMembers ¶ added in v0.19.0
func (c *CacheNop) GetMembers(guildID Snowflake, p *GetMembersParams) ([]*Member, error)
func (*CacheNop) GetMessage ¶ added in v0.19.0
REST lookup
func (*CacheNop) GetMessages ¶ added in v0.19.0
func (c *CacheNop) GetMessages(channel Snowflake, p *GetMessagesParams) ([]*Message, error)
func (*CacheNop) GuildBanAdd ¶ added in v0.19.0
func (c *CacheNop) GuildBanAdd(data []byte) (evt *GuildBanAdd, err error)
func (*CacheNop) GuildBanRemove ¶ added in v0.19.0
func (c *CacheNop) GuildBanRemove(data []byte) (evt *GuildBanRemove, err error)
func (*CacheNop) GuildCreate ¶ added in v0.19.0
func (c *CacheNop) GuildCreate(data []byte) (evt *GuildCreate, err error)
func (*CacheNop) GuildDelete ¶ added in v0.19.0
func (c *CacheNop) GuildDelete(data []byte) (evt *GuildDelete, err error)
func (*CacheNop) GuildEmojisUpdate ¶ added in v0.19.0
func (c *CacheNop) GuildEmojisUpdate(data []byte) (evt *GuildEmojisUpdate, err error)
func (*CacheNop) GuildIntegrationsUpdate ¶ added in v0.19.0
func (c *CacheNop) GuildIntegrationsUpdate(data []byte) (evt *GuildIntegrationsUpdate, err error)
func (*CacheNop) GuildMemberAdd ¶ added in v0.19.0
func (c *CacheNop) GuildMemberAdd(data []byte) (evt *GuildMemberAdd, err error)
func (*CacheNop) GuildMemberRemove ¶ added in v0.19.0
func (c *CacheNop) GuildMemberRemove(data []byte) (evt *GuildMemberRemove, err error)
func (*CacheNop) GuildMemberUpdate ¶ added in v0.19.0
func (c *CacheNop) GuildMemberUpdate(data []byte) (evt *GuildMemberUpdate, err error)
func (*CacheNop) GuildMembersChunk ¶ added in v0.19.0
func (c *CacheNop) GuildMembersChunk(data []byte) (evt *GuildMembersChunk, err error)
func (*CacheNop) GuildRoleCreate ¶ added in v0.19.0
func (c *CacheNop) GuildRoleCreate(data []byte) (evt *GuildRoleCreate, err error)
func (*CacheNop) GuildRoleDelete ¶ added in v0.19.0
func (c *CacheNop) GuildRoleDelete(data []byte) (evt *GuildRoleDelete, err error)
func (*CacheNop) GuildRoleUpdate ¶ added in v0.19.0
func (c *CacheNop) GuildRoleUpdate(data []byte) (evt *GuildRoleUpdate, err error)
func (*CacheNop) GuildUpdate ¶ added in v0.19.0
func (c *CacheNop) GuildUpdate(data []byte) (evt *GuildUpdate, err error)
func (*CacheNop) InteractionCreate ¶ added in v0.27.0
func (c *CacheNop) InteractionCreate(data []byte) (evt *InteractionCreate, err error)
func (*CacheNop) InviteCreate ¶ added in v0.19.0
func (c *CacheNop) InviteCreate(data []byte) (evt *InviteCreate, err error)
func (*CacheNop) InviteDelete ¶ added in v0.19.0
func (c *CacheNop) InviteDelete(data []byte) (evt *InviteDelete, err error)
func (*CacheNop) MessageCreate ¶ added in v0.19.0
func (c *CacheNop) MessageCreate(data []byte) (evt *MessageCreate, err error)
func (*CacheNop) MessageDelete ¶ added in v0.19.0
func (c *CacheNop) MessageDelete(data []byte) (evt *MessageDelete, err error)
func (*CacheNop) MessageDeleteBulk ¶ added in v0.19.0
func (c *CacheNop) MessageDeleteBulk(data []byte) (evt *MessageDeleteBulk, err error)
func (*CacheNop) MessageReactionAdd ¶ added in v0.19.0
func (c *CacheNop) MessageReactionAdd(data []byte) (evt *MessageReactionAdd, err error)
func (*CacheNop) MessageReactionRemove ¶ added in v0.19.0
func (c *CacheNop) MessageReactionRemove(data []byte) (evt *MessageReactionRemove, err error)
func (*CacheNop) MessageReactionRemoveAll ¶ added in v0.19.0
func (c *CacheNop) MessageReactionRemoveAll(data []byte) (evt *MessageReactionRemoveAll, err error)
func (*CacheNop) MessageReactionRemoveEmoji ¶ added in v0.20.0
func (c *CacheNop) MessageReactionRemoveEmoji(data []byte) (evt *MessageReactionRemoveEmoji, err error)
func (*CacheNop) MessageUpdate ¶ added in v0.19.0
func (c *CacheNop) MessageUpdate(data []byte) (evt *MessageUpdate, err error)
func (*CacheNop) PresenceUpdate ¶ added in v0.19.0
func (c *CacheNop) PresenceUpdate(data []byte) (evt *PresenceUpdate, err error)
func (*CacheNop) TypingStart ¶ added in v0.19.0
func (c *CacheNop) TypingStart(data []byte) (evt *TypingStart, err error)
func (*CacheNop) UserUpdate ¶ added in v0.19.0
func (c *CacheNop) UserUpdate(data []byte) (evt *UserUpdate, err error)
func (*CacheNop) VoiceServerUpdate ¶ added in v0.19.0
func (c *CacheNop) VoiceServerUpdate(data []byte) (evt *VoiceServerUpdate, err error)
func (*CacheNop) VoiceStateUpdate ¶ added in v0.19.0
func (c *CacheNop) VoiceStateUpdate(data []byte) (evt *VoiceStateUpdate, err error)
func (*CacheNop) WebhooksUpdate ¶ added in v0.19.0
func (c *CacheNop) WebhooksUpdate(data []byte) (evt *WebhooksUpdate, err error)
type CacheUpdater ¶ added in v0.19.0
type CacheUpdater interface { // Gateway events ChannelCreate(data []byte) (*ChannelCreate, error) ChannelDelete(data []byte) (*ChannelDelete, error) ChannelPinsUpdate(data []byte) (*ChannelPinsUpdate, error) ChannelUpdate(data []byte) (*ChannelUpdate, error) GuildBanAdd(data []byte) (*GuildBanAdd, error) GuildBanRemove(data []byte) (*GuildBanRemove, error) GuildCreate(data []byte) (*GuildCreate, error) GuildDelete(data []byte) (*GuildDelete, error) GuildEmojisUpdate(data []byte) (*GuildEmojisUpdate, error) GuildIntegrationsUpdate(data []byte) (*GuildIntegrationsUpdate, error) GuildMemberAdd(data []byte) (*GuildMemberAdd, error) GuildMemberRemove(data []byte) (*GuildMemberRemove, error) GuildMemberUpdate(data []byte) (*GuildMemberUpdate, error) GuildMembersChunk(data []byte) (*GuildMembersChunk, error) GuildRoleCreate(data []byte) (*GuildRoleCreate, error) GuildRoleDelete(data []byte) (*GuildRoleDelete, error) GuildRoleUpdate(data []byte) (*GuildRoleUpdate, error) GuildUpdate(data []byte) (*GuildUpdate, error) InteractionCreate(data []byte) (*InteractionCreate, error) InviteCreate(data []byte) (*InviteCreate, error) InviteDelete(data []byte) (*InviteDelete, error) MessageCreate(data []byte) (*MessageCreate, error) MessageDelete(data []byte) (*MessageDelete, error) MessageDeleteBulk(data []byte) (*MessageDeleteBulk, error) MessageReactionAdd(data []byte) (*MessageReactionAdd, error) MessageReactionRemove(data []byte) (*MessageReactionRemove, error) MessageReactionRemoveAll(data []byte) (*MessageReactionRemoveAll, error) MessageReactionRemoveEmoji(data []byte) (*MessageReactionRemoveEmoji, error) MessageUpdate(data []byte) (*MessageUpdate, error) PresenceUpdate(data []byte) (*PresenceUpdate, error) Ready(data []byte) (*Ready, error) Resumed(data []byte) (*Resumed, error) TypingStart(data []byte) (*TypingStart, error) UserUpdate(data []byte) (*UserUpdate, error) VoiceServerUpdate(data []byte) (*VoiceServerUpdate, error) VoiceStateUpdate(data []byte) (*VoiceStateUpdate, error) WebhooksUpdate(data []byte) (*WebhooksUpdate, error) }
type Channel ¶ added in v0.6.0
type Channel struct { ID Snowflake `json:"id"` Type ChannelType `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:"recipients,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"` }
Channel ...
func (*Channel) GetPermissions ¶ added in v0.18.0
func (c *Channel) GetPermissions(ctx context.Context, s GuildQueryBuilderCaller, member *Member, flags ...Flag) (permissions PermissionBit, err error)
GetPermissions is used to get a members permissions in a channel.
func (*Channel) Mention ¶ added in v0.6.0
Mention creates a channel mention string. Mention format is according the Discord protocol.
func (*Channel) SendMsg ¶ added in v0.6.0
func (c *Channel) SendMsg(ctx context.Context, s Session, message *Message) (msg *Message, err error)
SendMsg sends a message to a channel
type ChannelCreate ¶ added in v0.6.0
ChannelCreate new channel created
func (*ChannelCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelDelete ¶ added in v0.6.0
ChannelDelete channel was deleted
func (*ChannelDelete) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type ChannelPinsUpdate ¶ added in v0.6.0
type ChannelPinsUpdate struct { ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id,omitempty"` LastPinTimestamp Time `json:"last_pin_timestamp,omitempty"` ShardID uint `json:"-"` }
ChannelPinsUpdate message was pinned or unpinned. Not sent when a message is deleted.
type ChannelQueryBuilder ¶ added in v0.19.0
type ChannelQueryBuilder interface { WithContext(ctx context.Context) ChannelQueryBuilder // 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(flags ...Flag) error // GetChannel Get a channel by Snowflake. Returns a channel object. Get(flags ...Flag) (*Channel, 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. UpdateBuilder(flags ...Flag) *updateChannelBuilder // Deprecated: use UpdateBuilder Update(flags ...Flag) *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. Delete(flags ...Flag) (*Channel, 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. UpdatePermissions(overwriteID Snowflake, params *UpdateChannelPermissionsParams, flags ...Flag) error // GetChannelInvites Returns a list of invite objects (with invite metadata) for the channel. Only usable for // guild Channels. Requires the 'MANAGE_CHANNELS' permission. GetInvites(flags ...Flag) ([]*Invite, error) // CreateChannelInvite 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. CreateInvite(flags ...Flag) *createChannelInviteBuilder // 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 DeletePermission(overwriteID Snowflake, flags ...Flag) error // AddDMParticipant Adds a recipient to a Group DM using their access token. Returns a 204 empty response // on success. AddDMParticipant(participant *GroupDMParticipant, flags ...Flag) error // KickParticipant Removes a recipient from a Group DM. Returns a 204 empty response on success. KickParticipant(userID Snowflake, flags ...Flag) error // GetPinnedMessages Returns all pinned messages in the channel as an array of message objects. GetPinnedMessages(flags ...Flag) ([]*Message, 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(params *DeleteMessagesParams, flags ...Flag) error // 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(params *GetMessagesParams, flags ...Flag) ([]*Message, 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(params *CreateMessageParams, flags ...Flag) (*Message, error) // CreateWebhook Create a new webhook. Requires the 'MANAGE_WEBHOOKS' permission. // Returns a webhook object on success. CreateWebhook(params *CreateWebhookParams, flags ...Flag) (ret *Webhook, err error) // GetChannelWebhooks Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. GetWebhooks(flags ...Flag) (ret []*Webhook, err error) Message(id Snowflake) MessageQueryBuilder }
ChannelQueryBuilder REST interface for all Channel endpoints
type ChannelType ¶ added in v0.25.0
type ChannelType uint
Channel types https://discord.com/developers/docs/resources/channel#channel-object-channel-types
const ( ChannelTypeGuildText ChannelType = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory ChannelTypeGuildNews ChannelTypeGuildStore )
type ChannelUpdate ¶ added in v0.6.0
ChannelUpdate channel was updated
func (*ChannelUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *ChannelUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
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 context is required since a single external request is made to verify bot details
func (*Client) AddPermission ¶ added in v0.10.0
func (c *Client) AddPermission(permission PermissionBit) (updatedPermissions PermissionBit)
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.12.0
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) BotAuthorizeURL ¶ added in v0.19.0
BotAuthorizeURL 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) Channel ¶ added in v0.19.0
func (c Client) Channel(id Snowflake) ChannelQueryBuilder
func (Client) CreateGuild ¶
func (c Client) CreateGuild(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) CurrentUser ¶ added in v0.19.0
func (c Client) CurrentUser() CurrentUserQueryBuilder
Guild is used to create a guild query builder.
func (*Client) EditInteractionResponse ¶ added in v0.27.0
func (*Client) Gateway ¶ added in v0.21.0
func (c *Client) Gateway() GatewayQueryBuilder
func (*Client) GetConnectedGuilds ¶ added in v0.10.0
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) GetPermissions ¶ added in v0.10.0
func (c *Client) GetPermissions() (permissions PermissionBit)
GetPermissions returns the minimum bot requirements.
func (Client) GetVoiceRegions ¶
func (c Client) GetVoiceRegions(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) Guild ¶ added in v0.19.0
func (c Client) Guild(id Snowflake) GuildQueryBuilder
Guild is used to create a guild query builder.
func (*Client) HeartbeatLatencies ¶ added in v0.12.0
HeartbeatLatencies returns latencies mapped to each shard, by their respective ID. shardID => latency.
func (Client) Invite ¶ added in v0.19.0
func (c Client) Invite(code string) InviteQueryBuilder
func (*Client) Logger ¶ added in v0.10.0
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) Pool ¶ added in v0.10.0
func (c *Client) Pool() *pools
////////////////////////////////////////////////////
METHODS ¶
////////////////////////////////////////////////////
func (*Client) RESTRatelimitBuckets ¶ added in v0.16.5
RESTBucketGrouping shows which hashed endpoints belong to which bucket hash for the REST API. Note that these bucket hashes are eventual consistent.
func (*Client) SendInteractionResponse ¶ added in v0.27.0
func (c *Client) SendInteractionResponse(ctx context.Context, interaction *InteractionCreate, data *InteractionResponse) error
func (Client) SendMsg ¶ added in v0.4.0
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) UpdateStatus ¶ added in v0.8.4
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.8.4
UpdateStatusString sets the Client's game activity to the provided string, status to online and type to Playing
func (Client) User ¶ added in v0.19.0
func (c Client) User(id Snowflake) UserQueryBuilder
Guild is used to create a guild query builder.
func (Client) Webhook ¶ added in v0.19.0
func (c Client) Webhook(id Snowflake) WebhookQueryBuilder
func (Client) WithContext ¶ added in v0.19.0
func (c Client) WithContext(ctx context.Context) ClientQueryBuilderExecutables
type ClientQueryBuilder ¶ added in v0.19.0
type ClientQueryBuilder interface { WithContext(ctx context.Context) ClientQueryBuilderExecutables ClientQueryBuilderExecutables Invite(code string) InviteQueryBuilder Channel(cid Snowflake) ChannelQueryBuilder User(uid Snowflake) UserQueryBuilder CurrentUser() CurrentUserQueryBuilder Guild(id Snowflake) GuildQueryBuilder Gateway() GatewayQueryBuilder }
type ClientQueryBuilderExecutables ¶ added in v0.19.0
type ClientQueryBuilderExecutables interface { // CreateGuild Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. CreateGuild(guildName string, params *CreateGuildParams, flags ...Flag) (*Guild, error) // GetVoiceRegionsBuilder Returns an array of voice region objects that can be used when creating servers. GetVoiceRegions(flags ...Flag) ([]*VoiceRegion, error) BotAuthorizeURL() (*url.URL, error) SendMsg(channelID Snowflake, data ...interface{}) (*Message, error) }
type ClientStatus ¶ added in v0.25.0
type CloseConnectionErr ¶ added in v0.16.4
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 allows for different wrappers or alternative http logic as long as they have the same // .Do(..).. method as the http.Client. // Note that rate limiting is not done in the roundtripper layer at this point, so anything with re-tries, logic // that triggers a new http request without going through Disgord interface, will not be rate limited and this // can cause you to get banned in the long term. Be careful. HttpClient HttpClientDoer WebsocketHttpClient *http.Client // no way around this, sadly. At least for now. // Deprecated: use WebsocketHttpClient and HttpClient HTTPClient *http.Client // Deprecated: use WebsocketHttpClient and HttpClient Proxy proxy.Dialer // Deprecated: use DMIntents (values here are copied to DMIntents for now) // For direct communication with you bot you must specify intents Intents Intent // DMIntents specify intents related to direct message capabilities. Guild related intents are derived // from the RejectEvents config option (I hope that one day Intents can be removed all together, and // such optimizations can be handled in the background). // // You can see sent intents by enabling debug logging. Remember that derived from RejectIntents are appended. DMIntents Intent // your project name, name of bot, or application ProjectName string 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 // 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 Cache Cache 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 // Deprecated: use RejectEvents instead (nothing changed, just better naming) IgnoreEvents []string RejectEvents []string // contains filtered or unexported fields }
Config Configuration for the Disgord Client
type Copier ¶ added in v0.7.0
type Copier interface {
// contains filtered or unexported methods
}
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 CreateChannelInviteBuilder ¶ added in v0.19.0
type CreateChannelInviteBuilder interface { Execute() (invite *Invite, err error) IgnoreCache() CreateChannelInviteBuilder CancelOnRatelimit() CreateChannelInviteBuilder URLParam(name string, v interface{}) CreateChannelInviteBuilder Set(name string, v interface{}) CreateChannelInviteBuilder SetMaxAge(maxAge int) CreateChannelInviteBuilder SetMaxUses(maxUses int) CreateChannelInviteBuilder SetTemporary(temporary bool) CreateChannelInviteBuilder SetUnique(unique bool) CreateChannelInviteBuilder }
CreateChannelInviteBuilder is the interface for the builder.
type CreateDMBuilder ¶ added in v0.19.0
type CreateDMBuilder interface { Execute() (channel *Channel, err error) IgnoreCache() CreateDMBuilder CancelOnRatelimit() CreateDMBuilder URLParam(name string, v interface{}) CreateDMBuilder Set(name string, v interface{}) CreateDMBuilder }
CreateDMBuilder is the interface for the builder.
type CreateGroupDMBuilder ¶ added in v0.19.0
type CreateGroupDMBuilder interface { Execute() (channel *Channel, err error) IgnoreCache() CreateGroupDMBuilder CancelOnRatelimit() CreateGroupDMBuilder URLParam(name string, v interface{}) CreateGroupDMBuilder Set(name string, v interface{}) CreateGroupDMBuilder }
CreateGroupDMBuilder is the interface for the builder.
type CreateGroupDMParams ¶ added in v0.6.0
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.6.0
type CreateGuildChannelParams struct { Name string `json:"name"` // required Type ChannelType `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 CreateGuildEmojiBuilder ¶ added in v0.19.0
type CreateGuildEmojiBuilder interface { Execute() (emoji *Emoji, err error) IgnoreCache() CreateGuildEmojiBuilder CancelOnRatelimit() CreateGuildEmojiBuilder URLParam(name string, v interface{}) CreateGuildEmojiBuilder Set(name string, v interface{}) CreateGuildEmojiBuilder SetRoles(roles []Snowflake) CreateGuildEmojiBuilder }
CreateGuildEmojiBuilder is the interface for the builder.
type CreateGuildEmojiParams ¶ added in v0.6.0
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.6.0
CreateGuildIntegrationParams ... https://discord.com/developers/docs/resources/guild#create-guild-integration-json-params
type CreateGuildParams ¶ added in v0.6.0
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.6.0
type CreateGuildRoleParams struct { Name string `json:"name,omitempty"` Permissions uint64 `json:"permissions,omitempty"` Color uint `json:"color,omitempty"` Hoist bool `json:"hoist,omitempty"` Mentionable bool `json:"mentionable,omitempty"` // 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.9.3
type CreateMessageFileParams struct { Reader io.Reader `json:"-"` // always omit as we don't want this as part of the JSON payload FileName string `json:"-"` // SpoilerTag lets discord know that this image should be blurred out. // Current Discord behaviour is that whenever a message with one or more images is marked as // spoiler tag, all the images in that message are blurred out. (independent of msg.Content) SpoilerTag bool `json:"-"` }
CreateMessageFileParams contains the information needed to upload a file to Discord, it is part of the CreateMessageParams struct.
type CreateMessageParams ¶ added in v0.9.3
type CreateMessageParams struct { Content string `json:"content"` Nonce 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 Components []*MessageComponent `json:"components"` Files []CreateMessageFileParams `json:"-"` // Always omit as this is included in multipart, not JSON payload SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` // The allowed mentions object for the message. MessageReference *MessageReference `json:"message_reference,omitempty"` }
CreateMessageParams JSON params for CreateChannelMessage
type CreateWebhookParams ¶ added in v0.6.0
type CreateWebhookParams struct { Name string `json:"name"` // name of the webhook (2-32 characters) Avatar string `json:"avatar"` // avatar data uri scheme, image for the default webhook avatar // 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.10.0
func (c *CreateWebhookParams) FindErrors() error
type Ctrl ¶ added in v0.10.0
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.12.0
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 CurrentUserQueryBuilder ¶ added in v0.19.0
type CurrentUserQueryBuilder interface { WithContext(ctx context.Context) CurrentUserQueryBuilder // 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. Get(flags ...Flag) (*User, error) // UpdateCurrentUser Modify the requester's user account settings. Returns a user object on success. UpdateBuilder(flags ...Flag) UpdateCurrentUserBuilder // Deprecated: use UpdateBuilder Update(flags ...Flag) UpdateCurrentUserBuilder // GetCurrentUserGuilds Returns a list of partial guild objects the current user is a member of. // Requires the Guilds OAuth2 scope. GetGuilds(params *GetCurrentUserGuildsParams, flags ...Flag) (ret []*Guild, err error) // LeaveGuild Leave a guild. Returns a 204 empty response on success. LeaveGuild(id Snowflake, flags ...Flag) (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(params *CreateGroupDMParams, flags ...Flag) (ret *Channel, err error) // GetUserConnections Returns a list of connection objects. Requires the connections OAuth2 scope. GetUserConnections(flags ...Flag) (ret []*UserConnection, err error) }
type DeepCopier ¶ added in v0.7.0
type DeepCopier interface {
// contains filtered or unexported methods
}
DeepCopier holds the DeepCopy method which creates and returns a deep copy of any struct.
type DefaultMessageNotificationLvl ¶ added in v0.6.0
type DefaultMessageNotificationLvl uint
DefaultMessageNotificationLvl ... https://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.6.0
func (dmnl *DefaultMessageNotificationLvl) AllMessages() bool
AllMessages ...
func (*DefaultMessageNotificationLvl) OnlyMentions ¶ added in v0.6.0
func (dmnl *DefaultMessageNotificationLvl) OnlyMentions() bool
OnlyMentions ...
type DeleteMessagesParams ¶ added in v0.10.0
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.10.0
func (p *DeleteMessagesParams) AddMessage(msg *Message) (err error)
AddMessage Adds a message to be deleted
func (*DeleteMessagesParams) Valid ¶ added in v0.10.0
func (p *DeleteMessagesParams) Valid() (err error)
Valid validates the DeleteMessagesParams data
type Discriminator ¶ added in v0.8.0
type Discriminator uint16
Discriminator value
func NewDiscriminator ¶ added in v0.8.0
func NewDiscriminator(d string) (discriminator Discriminator, err error)
NewDiscriminator Discord user discriminator hashtag
func (Discriminator) MarshalJSON ¶ added in v0.8.0
func (d Discriminator) MarshalJSON() (data []byte, err error)
MarshalJSON see interface json.Marshaler
func (Discriminator) NotSet ¶ added in v0.8.0
func (d Discriminator) NotSet() bool
NotSet checks if the discriminator is not set
func (Discriminator) String ¶ added in v0.8.0
func (d Discriminator) String() (str string)
func (*Discriminator) UnmarshalJSON ¶ added in v0.8.0
func (d *Discriminator) UnmarshalJSON(data []byte) error
UnmarshalJSON see interface json.Unmarshaler
type Embed ¶ added in v0.10.0
type Embed struct { Title string `json:"title,omitempty"` // title of embed Type EmbedType `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
type EmbedAuthor ¶ added in v0.10.0
type EmbedAuthor struct { 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 }
EmbedAuthor https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure
type EmbedField ¶ added in v0.10.0
type EmbedField struct { 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 }
EmbedField https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure
type EmbedFooter ¶ added in v0.10.0
type EmbedFooter struct {}
EmbedFooter https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure
type EmbedImage ¶ added in v0.10.0
type EmbedImage struct { 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 }
EmbedImage https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure
type EmbedProvider ¶ added in v0.10.0
type EmbedProvider struct { 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
type EmbedThumbnail ¶ added in v0.10.0
type EmbedThumbnail struct { 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
type EmbedVideo ¶ added in v0.10.0
type EmbedVideo struct { 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 }
EmbedVideo https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure
type Emoji ¶ added in v0.6.0
type Emoji struct { ID Snowflake `json:"id"` Name string `json:"name"` Roles []Snowflake `json:"roles,omitempty"` User *User `json:"user,omitempty"` // the user who created the emoji RequireColons bool `json:"require_colons,omitempty"` Managed bool `json:"managed,omitempty"` Animated bool `json:"animated,omitempty"` Available bool `json:"available,omitempty"` }
Emoji ...
type ErrorEmptyValue ¶ added in v0.7.0
type ErrorEmptyValue struct {
// contains filtered or unexported fields
}
ErrorEmptyValue when a required value was set as empty
func (*ErrorEmptyValue) Error ¶ added in v0.7.0
func (e *ErrorEmptyValue) Error() string
type ErrorMissingSnowflake ¶ added in v0.7.0
type ErrorMissingSnowflake struct {
// contains filtered or unexported fields
}
ErrorMissingSnowflake used by methods about to communicate with the Discord API. If a snowflake value is required this is used to identify that you must set the value before being able to interact with the Discord API
func (*ErrorMissingSnowflake) Error ¶ added in v0.7.0
func (e *ErrorMissingSnowflake) Error() string
type ErrorUnsupportedType ¶ added in v0.7.0
type ErrorUnsupportedType struct {
// contains filtered or unexported fields
}
ErrorUnsupportedType used when the given param type is not supported
func (*ErrorUnsupportedType) Error ¶ added in v0.7.0
func (e *ErrorUnsupportedType) Error() string
type EventType ¶ added in v0.19.0
type EventType interface {
// contains filtered or unexported methods
}
type ExecuteWebhookParams ¶ added in v0.6.0
type ExecuteWebhookParams struct { 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
type ExplicitContentFilterLvl ¶ added in v0.6.0
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.6.0
func (ecfl *ExplicitContentFilterLvl) AllMembers() bool
AllMembers if the filter applies for all members regardles of them having a role or not
func (*ExplicitContentFilterLvl) Disabled ¶ added in v0.6.0
func (ecfl *ExplicitContentFilterLvl) Disabled() bool
Disabled if the content filter is disabled
func (*ExplicitContentFilterLvl) MembersWithoutRoles ¶ added in v0.6.0
func (ecfl *ExplicitContentFilterLvl) MembersWithoutRoles() bool
MembersWithoutRoles if the filter only applies for members without a role
type Flag ¶ added in v0.10.0
type Flag uint32
func (Flag) IgnoreEmptyParams ¶ added in v0.10.0
func (Flag) Ignorecache ¶ added in v0.10.0
type GatewayQueryBuilder ¶ added in v0.21.0
type GatewayQueryBuilder interface { WithContext(ctx context.Context) GatewayQueryBuilder Get() (gateway *gateway.Gateway, err error) GetBot() (gateway *gateway.GatewayBot, err error) BotReady(func()) BotGuildsReady(func()) Dispatch(name gatewayCmdName, payload gateway.CmdPayload) (unchandledGuildIDs []Snowflake, err error) // Connect establishes a websocket connection to the discord API Connect() error StayConnectedUntilInterrupted() error // Disconnect closes the discord websocket connection Disconnect() error DisconnectOnInterrupt() error SocketHandlerRegistrator }
type GetCurrentUserGuildsBuilder ¶ added in v0.19.0
type GetCurrentUserGuildsBuilder interface { Execute() (guilds []*Guild, err error) IgnoreCache() GetCurrentUserGuildsBuilder CancelOnRatelimit() GetCurrentUserGuildsBuilder URLParam(name string, v interface{}) GetCurrentUserGuildsBuilder Set(name string, v interface{}) GetCurrentUserGuildsBuilder SetBefore(before Snowflake) GetCurrentUserGuildsBuilder SetAfter(after Snowflake) GetCurrentUserGuildsBuilder SetLimit(limit int) GetCurrentUserGuildsBuilder }
GetCurrentUserGuildsBuilder is the interface for the builder.
type GetCurrentUserGuildsParams ¶ added in v0.6.0
type GetCurrentUserGuildsParams struct { Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit int `urlparam:"limit,omitempty"` }
GetCurrentUserGuildsParams JSON params for func GetCurrentUserGuilds
func (*GetCurrentUserGuildsParams) URLQueryString ¶ added in v0.10.0
func (g *GetCurrentUserGuildsParams) URLQueryString() string
type GetMembersParams ¶ added in v0.10.0
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.9.3
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.10.0
func (g *GetMessagesParams) URLQueryString() string
func (*GetMessagesParams) Validate ¶ added in v0.12.0
func (g *GetMessagesParams) Validate() error
type GetReactionURLParams ¶ added in v0.6.0
type GetReactionURLParams struct { Before Snowflake `urlparam:"before,omitempty"` // get Users before this user Snowflake After Snowflake `urlparam:"after,omitempty"` // get Users after this user Snowflake Limit int `urlparam:"limit,omitempty"` // max number of Users to return (1-100) }
GetReactionURLParams https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params
func (*GetReactionURLParams) URLQueryString ¶ added in v0.10.0
func (g *GetReactionURLParams) URLQueryString() string
type GetUserBuilder ¶ added in v0.19.0
type GetUserBuilder interface { IgnoreCache() GetUserBuilder CancelOnRatelimit() GetUserBuilder URLParam(name string, v interface{}) GetUserBuilder Set(name string, v interface{}) GetUserBuilder }
GetUserBuilder is the interface for the builder.
type GetUserConnectionsBuilder ¶ added in v0.19.0
type GetUserConnectionsBuilder interface { Execute() (cons []*UserConnection, err error) IgnoreCache() GetUserConnectionsBuilder CancelOnRatelimit() GetUserConnectionsBuilder URLParam(name string, v interface{}) GetUserConnectionsBuilder Set(name string, v interface{}) GetUserConnectionsBuilder }
GetUserConnectionsBuilder is the interface for the builder.
type GetUserDMsBuilder ¶ added in v0.19.0
type GetUserDMsBuilder interface { Execute() (channels []*Channel, err error) IgnoreCache() GetUserDMsBuilder CancelOnRatelimit() GetUserDMsBuilder URLParam(name string, v interface{}) GetUserDMsBuilder Set(name string, v interface{}) GetUserDMsBuilder }
GetUserDMsBuilder is the interface for the builder.
type GroupDMParticipant ¶ added in v0.10.0
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.10.0
func (g *GroupDMParticipant) FindErrors() error
type Guild ¶ added in v0.6.0
type Guild struct { 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 PermissionBit `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"` 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"` // |? DiscoverySplash string `json:"discovery_splash,omitempty"` VanityUrl string `json:"vanity_url_code,omitempty"` Description string `json:"description,omitempty"` Banner string `json:"banner,omitempty"` PremiumTier PremiumTier `json:"premium_tier"` PremiumSubscriptionCount uint `json:"premium_subscription_count,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 (*Guild) AddChannel ¶ added in v0.6.0
AddChannel adds a channel to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMember ¶ added in v0.6.0
AddMember adds a member to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddMembers ¶ added in v0.7.0
AddMembers adds multiple members to the Guild object. Note that this method does not interact with Discord.
func (*Guild) AddRole ¶ added in v0.6.0
AddRole adds a role to the Guild object. Note that this does not interact with Discord.
func (*Guild) DeleteChannel ¶ added in v0.6.0
DeleteChannel removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteChannelByID ¶ added in v0.6.0
DeleteChannelByID removes a channel from the Guild object. Note that this method does not interact with Discord.
func (*Guild) DeleteRoleByID ¶ added in v0.6.0
DeleteRoleByID remove a role from the guild struct
func (*Guild) GetMemberWithHighestSnowflake ¶ added in v0.7.0
GetMemberWithHighestSnowflake finds the member with the highest snowflake value.
func (*Guild) GetMembersCountEstimate ¶ added in v0.12.0
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) MembersByName ¶ added in v0.7.0
MembersByName retrieve a slice of members with same username or nickname
func (*Guild) RoleByName ¶ added in v0.6.0
RoleByName retrieves a slice of roles with same name
type GuildAuditLogsBuilder ¶ added in v0.19.0
type GuildAuditLogsBuilder interface { Execute() (log *AuditLog, err error) IgnoreCache() GuildAuditLogsBuilder CancelOnRatelimit() GuildAuditLogsBuilder URLParam(name string, v interface{}) GuildAuditLogsBuilder Set(name string, v interface{}) GuildAuditLogsBuilder SetUserID(userID Snowflake) GuildAuditLogsBuilder SetActionType(actionType uint) GuildAuditLogsBuilder SetBefore(before Snowflake) GuildAuditLogsBuilder SetLimit(limit int) GuildAuditLogsBuilder }
GuildAuditLogsBuilder is the interface for the builder.
type GuildBanAdd ¶ added in v0.6.0
type GuildBanAdd struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` ShardID uint `json:"-"` }
GuildBanAdd user was banned from a guild
type GuildBanRemove ¶ added in v0.6.0
type GuildBanRemove struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` ShardID uint `json:"-"` }
GuildBanRemove user was unbanned from a guild
type GuildCreate ¶ added in v0.6.0
GuildCreate This event can be sent in three different scenarios:
- When a user is initially connecting, to lazily load and backfill information for all unavailable Guilds sent in the Ready event.
- When a Guild becomes available again to the Client.
- When the current user joins a new Guild.
func (*GuildCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildDelete ¶ added in v0.6.0
type GuildDelete struct { ShardID uint `json:"-"` }
GuildDelete guild became unavailable, or user left/was removed from a guild
func (*GuildDelete) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildDelete) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
func (*GuildDelete) UserWasRemoved ¶ added in v0.8.0
func (obj *GuildDelete) UserWasRemoved() bool
UserWasRemoved ... TODO
type GuildEmbed ¶ added in v0.6.0
GuildEmbed https://discord.com/developers/docs/resources/guild#guild-embed-object
type GuildEmojiQueryBuilder ¶ added in v0.19.0
type GuildEmojiQueryBuilder interface { WithContext(ctx context.Context) GuildEmojiQueryBuilder Get(flags ...Flag) (*Emoji, error) UpdateBuilder(flags ...Flag) UpdateGuildEmojiBuilder Delete(flags ...Flag) error // Deprecated: use UpdateBuilder Update(flags ...Flag) UpdateGuildEmojiBuilder }
type GuildEmojisUpdate ¶ added in v0.6.0
type GuildEmojisUpdate struct { GuildID Snowflake `json:"guild_id"` Emojis []*Emoji `json:"emojis"` ShardID uint `json:"-"` }
GuildEmojisUpdate guild emojis were updated
type GuildIntegrationsUpdate ¶ added in v0.6.0
GuildIntegrationsUpdate guild integration was updated
type GuildMemberAdd ¶ added in v0.6.0
GuildMemberAdd new user joined a guild
func (*GuildMemberAdd) UnmarshalJSON ¶ added in v0.9.0
func (obj *GuildMemberAdd) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type GuildMemberQueryBuilder ¶ added in v0.19.0
type GuildMemberQueryBuilder interface { WithContext(ctx context.Context) GuildMemberQueryBuilder Get(flags ...Flag) (*Member, error) UpdateBuilder(flags ...Flag) UpdateGuildMemberBuilder AddRole(roleID Snowflake, flags ...Flag) error RemoveRole(roleID Snowflake, flags ...Flag) error Kick(reason string, flags ...Flag) error Ban(params *BanMemberParams, flags ...Flag) error GetPermissions(flags ...Flag) (PermissionBit, error) // Deprecated: use UpdateBuilder Update(flags ...Flag) UpdateGuildMemberBuilder }
type GuildMemberRemove ¶ added in v0.6.0
type GuildMemberRemove struct { GuildID Snowflake `json:"guild_id"` User *User `json:"user"` ShardID uint `json:"-"` }
GuildMemberRemove user was removed from a guild
type GuildMemberUpdate ¶ added in v0.6.0
GuildMemberUpdate guild member was updated
type GuildMembersChunk ¶ added in v0.6.0
type GuildMembersChunk struct { GuildID Snowflake `json:"guild_id"` Members []*Member `json:"members"` ChunkIndex uint `json:"chunk_index"` ChunkCount uint `json:"chunk_count"` NotFound []interface{} `json:"not_found"` Presences []*PresenceUpdate `json:"presences"` Nonce string `json:"nonce"` ShardID uint `json:"-"` }
GuildMembersChunk response to Request Guild Members
type GuildQueryBuilder ¶ added in v0.19.0
type GuildQueryBuilder interface { WithContext(ctx context.Context) GuildQueryBuilder // TODO: Add more guild attribute things. Waiting for caching changes before then. Get(flags ...Flag) (guild *Guild, err error) // TODO: For GetChannels, it might sense to have the option for a function to filter before each channel ends up deep copied. // TODO-2: This could be much more performant in guilds with a large number of channels. GetChannels(flags ...Flag) ([]*Channel, error) // TODO: For GetMembers, it might sense to have the option for a function to filter before each member ends up deep copied. // TODO-2: This could be much more performant in larger guilds where this is needed. GetMembers(params *GetMembersParams, flags ...Flag) ([]*Member, error) UpdateBuilder(flags ...Flag) UpdateGuildBuilder Delete(flags ...Flag) error // Deprecated: Use UpdateBuilder Update(flags ...Flag) UpdateGuildBuilder CreateChannel(name string, params *CreateGuildChannelParams, flags ...Flag) (*Channel, error) UpdateChannelPositions(params []UpdateGuildChannelPositionsParams, flags ...Flag) error CreateMember(userID Snowflake, accessToken string, params *AddGuildMemberParams, flags ...Flag) (*Member, error) Member(userID Snowflake) GuildMemberQueryBuilder KickVoiceParticipant(userID Snowflake) error SetCurrentUserNick(nick string, flags ...Flag) (newNick string, err error) GetBans(flags ...Flag) ([]*Ban, error) GetBan(userID Snowflake, flags ...Flag) (*Ban, error) UnbanUser(userID Snowflake, reason string, flags ...Flag) error // TODO: For GetRoles, it might sense to have the option for a function to filter before each role ends up deep copied. // TODO-2: This could be much more performant in larger guilds where this is needed. // TODO-3: Add GetRole. GetRoles(flags ...Flag) ([]*Role, error) UpdateRolePositions(params []UpdateGuildRolePositionsParams, flags ...Flag) ([]*Role, error) CreateRole(params *CreateGuildRoleParams, flags ...Flag) (*Role, error) Role(roleID Snowflake) GuildRoleQueryBuilder EstimatePruneMembersCount(days int, flags ...Flag) (estimate int, err error) PruneMembers(days int, reason string, flags ...Flag) error GetVoiceRegions(flags ...Flag) ([]*VoiceRegion, error) GetInvites(flags ...Flag) ([]*Invite, error) GetIntegrations(flags ...Flag) ([]*Integration, error) CreateIntegration(params *CreateGuildIntegrationParams, flags ...Flag) error UpdateIntegration(integrationID Snowflake, params *UpdateGuildIntegrationParams, flags ...Flag) error DeleteIntegration(integrationID Snowflake, flags ...Flag) error SyncIntegration(integrationID Snowflake, flags ...Flag) error GetEmbed(flags ...Flag) (*GuildEmbed, error) UpdateEmbedBuilder(flags ...Flag) UpdateGuildEmbedBuilder GetVanityURL(flags ...Flag) (*PartialInvite, error) GetAuditLogs(flags ...Flag) GuildAuditLogsBuilder VoiceChannel(channelID Snowflake) VoiceChannelQueryBuilder // TODO: For GetEmojis, it might sense to have the option for a function to filter before each emoji ends up deep copied. // TODO-2: This could be much more performant in guilds with a large number of channels. GetEmojis(flags ...Flag) ([]*Emoji, error) CreateEmoji(params *CreateGuildEmojiParams, flags ...Flag) (*Emoji, error) Emoji(emojiID Snowflake) GuildEmojiQueryBuilder GetWebhooks(flags ...Flag) (ret []*Webhook, err error) }
GuildQueryBuilder defines the exposed functions from the guild query builder.
type GuildQueryBuilderCaller ¶ added in v0.19.0
type GuildQueryBuilderCaller interface {
Guild(id Snowflake) GuildQueryBuilder
}
type GuildRoleCreate ¶ added in v0.6.0
type GuildRoleCreate struct { GuildID Snowflake `json:"guild_id"` Role *Role `json:"role"` ShardID uint `json:"-"` }
GuildRoleCreate guild role was created
type GuildRoleDelete ¶ added in v0.6.0
type GuildRoleDelete struct { GuildID Snowflake `json:"guild_id"` RoleID Snowflake `json:"role_id"` ShardID uint `json:"-"` }
GuildRoleDelete a guild role was deleted
type GuildRoleQueryBuilder ¶ added in v0.19.0
type GuildRoleQueryBuilder interface { WithContext(ctx context.Context) GuildRoleQueryBuilder UpdateBuilder(flags ...Flag) (builder UpdateGuildRoleBuilder) Delete(flags ...Flag) error // Deprecated: use UpdateBuilder Update(flags ...Flag) UpdateGuildRoleBuilder }
type GuildRoleUpdate ¶ added in v0.6.0
type GuildRoleUpdate struct { GuildID Snowflake `json:"guild_id"` Role *Role `json:"role"` ShardID uint `json:"-"` }
GuildRoleUpdate guild role was updated
type GuildUnavailable ¶ added in v0.6.0
type GuildUnavailable struct {}
GuildUnavailable is a partial Guild object.
type GuildUpdate ¶ added in v0.6.0
GuildUpdate guild was updated
func (*GuildUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type Handler ¶ added in v0.9.2
type Handler = interface{}
Handler needs to match one of the *Handler signatures
type HandlerChannelCreate ¶ added in v0.17.0
type HandlerChannelCreate = func(s Session, h *ChannelCreate)
HandlerChannelCreate is triggered by ChannelCreate events
type HandlerChannelDelete ¶ added in v0.17.0
type HandlerChannelDelete = func(s Session, h *ChannelDelete)
HandlerChannelDelete is triggered by ChannelDelete events
type HandlerChannelPinsUpdate ¶ added in v0.17.0
type HandlerChannelPinsUpdate = func(s Session, h *ChannelPinsUpdate)
HandlerChannelPinsUpdate is triggered by ChannelPinsUpdate events
type HandlerChannelUpdate ¶ added in v0.17.0
type HandlerChannelUpdate = func(s Session, h *ChannelUpdate)
HandlerChannelUpdate is triggered by ChannelUpdate events
type HandlerCtrl ¶ added in v0.9.2
type HandlerCtrl interface { OnInsert(Session) error OnRemove(Session) error // IsDead does not need to be locked as the demultiplexer access it synchronously. IsDead() bool // Update For every time Update is called, it's internal trackers must be updated. // you should assume that .Update() means the handler was used. Update() }
HandlerCtrl used when inserting a handler to dictate whether or not the handler(s) should still be kept in the handlers list..
type HandlerGuildBanAdd ¶ added in v0.17.0
type HandlerGuildBanAdd = func(s Session, h *GuildBanAdd)
HandlerGuildBanAdd is triggered by GuildBanAdd events
type HandlerGuildBanRemove ¶ added in v0.17.0
type HandlerGuildBanRemove = func(s Session, h *GuildBanRemove)
HandlerGuildBanRemove is triggered by GuildBanRemove events
type HandlerGuildCreate ¶ added in v0.17.0
type HandlerGuildCreate = func(s Session, h *GuildCreate)
HandlerGuildCreate is triggered by GuildCreate events
type HandlerGuildDelete ¶ added in v0.17.0
type HandlerGuildDelete = func(s Session, h *GuildDelete)
HandlerGuildDelete is triggered by GuildDelete events
type HandlerGuildEmojisUpdate ¶ added in v0.17.0
type HandlerGuildEmojisUpdate = func(s Session, h *GuildEmojisUpdate)
HandlerGuildEmojisUpdate is triggered by GuildEmojisUpdate events
type HandlerGuildIntegrationsUpdate ¶ added in v0.17.0
type HandlerGuildIntegrationsUpdate = func(s Session, h *GuildIntegrationsUpdate)
HandlerGuildIntegrationsUpdate is triggered by GuildIntegrationsUpdate events
type HandlerGuildMemberAdd ¶ added in v0.17.0
type HandlerGuildMemberAdd = func(s Session, h *GuildMemberAdd)
HandlerGuildMemberAdd is triggered by GuildMemberAdd events
type HandlerGuildMemberRemove ¶ added in v0.17.0
type HandlerGuildMemberRemove = func(s Session, h *GuildMemberRemove)
HandlerGuildMemberRemove is triggered by GuildMemberRemove events
type HandlerGuildMemberUpdate ¶ added in v0.17.0
type HandlerGuildMemberUpdate = func(s Session, h *GuildMemberUpdate)
HandlerGuildMemberUpdate is triggered by GuildMemberUpdate events
type HandlerGuildMembersChunk ¶ added in v0.17.0
type HandlerGuildMembersChunk = func(s Session, h *GuildMembersChunk)
HandlerGuildMembersChunk is triggered by GuildMembersChunk events
type HandlerGuildRoleCreate ¶ added in v0.17.0
type HandlerGuildRoleCreate = func(s Session, h *GuildRoleCreate)
HandlerGuildRoleCreate is triggered by GuildRoleCreate events
type HandlerGuildRoleDelete ¶ added in v0.17.0
type HandlerGuildRoleDelete = func(s Session, h *GuildRoleDelete)
HandlerGuildRoleDelete is triggered by GuildRoleDelete events
type HandlerGuildRoleUpdate ¶ added in v0.17.0
type HandlerGuildRoleUpdate = func(s Session, h *GuildRoleUpdate)
HandlerGuildRoleUpdate is triggered by GuildRoleUpdate events
type HandlerGuildUpdate ¶ added in v0.17.0
type HandlerGuildUpdate = func(s Session, h *GuildUpdate)
HandlerGuildUpdate is triggered by GuildUpdate events
type HandlerInteractionCreate ¶ added in v0.27.0
type HandlerInteractionCreate = func(s Session, h *InteractionCreate)
HandlerInteractionCreate is triggered by InteractionCreate events
type HandlerInviteCreate ¶ added in v0.17.0
type HandlerInviteCreate = func(s Session, h *InviteCreate)
HandlerInviteCreate is triggered by InviteCreate events
type HandlerInviteDelete ¶ added in v0.17.0
type HandlerInviteDelete = func(s Session, h *InviteDelete)
HandlerInviteDelete is triggered by InviteDelete events
type HandlerMessageCreate ¶ added in v0.17.0
type HandlerMessageCreate = func(s Session, h *MessageCreate)
HandlerMessageCreate is triggered by MessageCreate events
type HandlerMessageDelete ¶ added in v0.17.0
type HandlerMessageDelete = func(s Session, h *MessageDelete)
HandlerMessageDelete is triggered by MessageDelete events
type HandlerMessageDeleteBulk ¶ added in v0.17.0
type HandlerMessageDeleteBulk = func(s Session, h *MessageDeleteBulk)
HandlerMessageDeleteBulk is triggered by MessageDeleteBulk events
type HandlerMessageReactionAdd ¶ added in v0.17.0
type HandlerMessageReactionAdd = func(s Session, h *MessageReactionAdd)
HandlerMessageReactionAdd is triggered by MessageReactionAdd events
type HandlerMessageReactionRemove ¶ added in v0.17.0
type HandlerMessageReactionRemove = func(s Session, h *MessageReactionRemove)
HandlerMessageReactionRemove is triggered by MessageReactionRemove events
type HandlerMessageReactionRemoveAll ¶ added in v0.17.0
type HandlerMessageReactionRemoveAll = func(s Session, h *MessageReactionRemoveAll)
HandlerMessageReactionRemoveAll is triggered by MessageReactionRemoveAll events
type HandlerMessageReactionRemoveEmoji ¶ added in v0.20.0
type HandlerMessageReactionRemoveEmoji = func(s Session, h *MessageReactionRemoveEmoji)
HandlerMessageReactionRemoveEmoji is triggered by MessageReactionRemoveEmoji events
type HandlerMessageUpdate ¶ added in v0.17.0
type HandlerMessageUpdate = func(s Session, h *MessageUpdate)
HandlerMessageUpdate is triggered by MessageUpdate events
type HandlerPresenceUpdate ¶ added in v0.17.0
type HandlerPresenceUpdate = func(s Session, h *PresenceUpdate)
HandlerPresenceUpdate is triggered by PresenceUpdate events
type HandlerReady ¶ added in v0.17.0
HandlerReady is triggered by Ready events
type HandlerResumed ¶ added in v0.17.0
HandlerResumed is triggered by Resumed events
type HandlerSimple ¶ added in v0.22.0
type HandlerSimple = func(Session)
type HandlerSimplest ¶ added in v0.22.0
type HandlerSimplest = func()
these "simple" handler can be used, if you don't care about the actual event data
type HandlerSpecErr ¶ added in v0.16.5
type HandlerSpecErr = disgorderr.HandlerSpecErr
type HandlerTypingStart ¶ added in v0.17.0
type HandlerTypingStart = func(s Session, h *TypingStart)
HandlerTypingStart is triggered by TypingStart events
type HandlerUserUpdate ¶ added in v0.17.0
type HandlerUserUpdate = func(s Session, h *UserUpdate)
HandlerUserUpdate is triggered by UserUpdate events
type HandlerVoiceServerUpdate ¶ added in v0.17.0
type HandlerVoiceServerUpdate = func(s Session, h *VoiceServerUpdate)
HandlerVoiceServerUpdate is triggered by VoiceServerUpdate events
type HandlerVoiceStateUpdate ¶ added in v0.17.0
type HandlerVoiceStateUpdate = func(s Session, h *VoiceStateUpdate)
HandlerVoiceStateUpdate is triggered by VoiceStateUpdate events
type HandlerWebhooksUpdate ¶ added in v0.17.0
type HandlerWebhooksUpdate = func(s Session, h *WebhooksUpdate)
HandlerWebhooksUpdate is triggered by WebhooksUpdate events
type HttpClientDoer ¶ added in v0.27.0
type Integration ¶ added in v0.6.0
type Integration struct { 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
type IntegrationAccount ¶ added in v0.6.0
type IntegrationAccount struct { 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
type Intent ¶ added in v0.20.0
func AllIntents ¶ added in v0.17.0
func AllIntents() Intent
func AllIntentsExcept ¶ added in v0.22.0
type InteractionApplicationCommandCallbackData ¶ added in v0.27.0
type InteractionApplicationCommandCallbackData struct { Tts bool `json:"tts"` Content string `json:"content"` Embeds []*Embed `json:"embeds"` Flags int `json:"flags"` AllowedMentions *AllowedMentions `json:"allowed_mentions"` Components []*MessageComponent `json:"components"` }
type InteractionCallbackType ¶ added in v0.27.0
type InteractionCallbackType = int
const ( Pong InteractionCallbackType ChannelMessageWithSource DeferredChannelMessageWithSource DeferredUpdateMessage UpdateMessage )
type InteractionCreate ¶ added in v0.27.0
type InteractionCreate struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data *ApplicationCommandInteractionData `json:"data"` GuildID Snowflake `json:"guild_id"` ChannelID Snowflake `json:"channel_id"` Member *Member `json:"member"` User *User `json:"user"` Token string `json:"token"` Version int `json:"version"` Message *Message `json:"message"` ShardID uint `json:"-"` }
type InteractionResponse ¶ added in v0.27.0
type InteractionResponse struct { Type InteractionCallbackType `json:"type"` Data *InteractionApplicationCommandCallbackData `json:"data"` }
type InteractionType ¶ added in v0.27.0
type InteractionType = int
const ( InteractionPing InteractionType InteractionApplicationCommand InteractionMessageComponent )
type Invite ¶ added in v0.6.0
type Invite struct { // Code the invite code (unique Snowflake) Code string `json:"code"` // Guild the guild this invite is for Guild *Guild `json:"guild"` // Channel the channel this invite is for Channel *PartialChannel `json:"channel"` // Inviter the user that created the invite Inviter *User `json:"inviter"` // CreatedAt the time at which the invite was created CreatedAt Time `json:"created_at"` // MaxAge how long the invite is valid for (in seconds) MaxAge int `json:"max_age"` // MaxUses the maximum number of times the invite can be used MaxUses int `json:"max_uses"` // Temporary whether or not the invite is temporary (invited Users will be kicked on disconnect unless they're assigned a role) Temporary bool `json:"temporary"` // Uses how many times the invite has been used (always will be 0) Uses int `json:"uses"` Revoked bool `json:"revoked"` 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
type InviteCreate ¶ added in v0.17.0
type InviteCreate struct { ChannelID Snowflake `json:"channel_id"` Code string `json:"code"` CreatedAt Time `json:"created_at"` GuildID Snowflake `json:"guild_id,omitempty"` Inviter *User `json:"inviter"` MaxAge int `json:"max_age"` MaxUses int `json:"max_uses"` Target *User `json:"target_user,omitempty"` TargetType int `json:"target_user_type"` Temporary bool `json:"temporary"` Uses int `json:"uses"` ShardID uint `json:"-"` }
InviteCreate guild invite was created
type InviteDelete ¶ added in v0.17.0
type InviteDelete struct { ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id"` Code string `json:"code"` ShardID uint `json:"-"` }
InviteDelete Sent when an invite is deleted.
type InviteMetadata ¶ added in v0.6.0
type InviteMetadata struct { // 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
type InviteQueryBuilder ¶ added in v0.19.0
type InviteQueryBuilder interface { WithContext(ctx context.Context) InviteQueryBuilder // Get Returns an invite object for the given code. Get(withMemberCount bool, flags ...Flag) (*Invite, error) // Delete an invite. Requires the MANAGE_CHANNELS permission. Returns an invite object on success. Delete(flags ...Flag) (deleted *Invite, err error) }
type MFALvl ¶ added in v0.6.0
type MFALvl uint
MFALvl ... https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
type Member ¶ added in v0.6.0
type Member struct { 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"` PremiumSince Time `json:"premium_since,omitempty"` Deaf bool `json:"deaf"` Mute bool `json:"mute"` Pending bool `json:"pending"` // custom UserID Snowflake `json:"-"` }
Member https://discord.com/developers/docs/resources/guild#guild-member-object
func (*Member) GetPermissions ¶ added in v0.10.1
func (m *Member) GetPermissions(ctx context.Context, s GuildQueryBuilderCaller, flags ...Flag) (permissions PermissionBit, err error)
GetPermissions populates a uint64 with all the permission flags
func (*Member) GetUser ¶ added in v0.9.0
GetUser tries to ensure that you get a user object and not a nil. The user can be nil if the guild was fetched from the cache.
func (*Member) Mention ¶ added in v0.7.0
Mention creates a string which is parsed into a member mention on Discord GUI's
func (*Member) UpdateNick ¶ added in v0.12.0
type MentionChannel ¶ added in v0.12.0
type MentionChannel struct { ID Snowflake `json:"id"` GuildID Snowflake `json:"guild_id"` Type ChannelType `json:"type"` Name string `json:"name"` }
type Mentioner ¶ added in v0.16.0
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.6.0
type Message struct { ID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_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"` ReferencedMessage *Message `json:"referenced_message"` Flags MessageFlag `json:"flags"` StickerItems []*StickerItem `json:"sticker_items"` // Deprecated Stickers []*MessageSticker `json:"stickers"` Components []*MessageComponent `json:"components"` Interaction *MessageInteraction `json:"interaction"` // SpoilerTagContent is only true if the entire message text is tagged as a spoiler (aka completely wrapped in ||) SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` HasSpoilerImage bool `json:"-"` }
Message https://discord.com/developers/docs/resources/channel#message-object-message-structure
func (*Message) DiscordURL ¶ added in v0.16.0
DiscordURL returns the Discord link to the message. This can be used to jump directly to a message from within the client.
Example: https://discord.com/channels/319567980491046913/644376487331495967/646925626523254795
func (*Message) IsDirectMessage ¶ added in v0.16.0
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.10.0
Reply input any type as an reply. int, string, an object, etc.
type MessageActivity ¶ added in v0.6.0
MessageActivity https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure
type MessageApplication ¶ added in v0.6.0
type MessageApplication struct { ID Snowflake `json:"id"` CoverImage string `json:"cover_image"` Description string `json:"description"` Icon string `json:"icon"` Name string `json:"name"` }
MessageApplication https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
type MessageComponent ¶ added in v0.27.0
type MessageComponent struct { Type MessageComponentType `json:"type"` Style ButtonStyle `json:"style"` Label string `json:"label"` Emoji *Emoji `json:"emoji"` CustomID string `json:"custom_id"` Url string `json:"url"` Disabled bool `json:"disabled"` Components []*MessageComponent `json:"components"` }
type MessageComponentType ¶ added in v0.27.0
type MessageComponentType = int
const ( MessageComponentActionRow MessageComponentType MessageComponentButton )
type MessageCreate ¶ added in v0.6.0
MessageCreate message was created
func (*MessageCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *MessageCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type MessageDelete ¶ added in v0.6.0
type MessageDelete struct { MessageID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id,omitempty"` ShardID uint `json:"-"` }
MessageDelete message was deleted
type MessageDeleteBulk ¶ added in v0.6.0
type MessageDeleteBulk struct { MessageIDs []Snowflake `json:"ids"` ChannelID Snowflake `json:"channel_id"` ShardID uint `json:"-"` }
MessageDeleteBulk multiple messages were deleted at once
type MessageFlag ¶ added in v0.12.0
type MessageFlag uint
MessageFlag https://discord.com/developers/docs/resources/channel#message-object-message-flags
const ( MessageFlagCrossposted MessageFlag = 1 << iota MessageFlagIsCrosspost MessageFlagSupressEmbeds MessageFlagSourceMessageDeleted MessageFlagUrgent )
type MessageInteraction ¶ added in v0.27.0
type MessageInteraction struct { ID Snowflake `json:"id"` Type InteractionType `json:"type"` Name string `json:"name"` User *User `json:"user"` }
type MessageQueryBuilder ¶ added in v0.19.0
type MessageQueryBuilder interface { WithContext(ctx context.Context) MessageQueryBuilder // PinMessageID Pin a message by its ID and channel ID. Requires the 'MANAGE_MESSAGES' permission. Pin(flags ...Flag) error // UnpinMessageID Delete a pinned message in a channel. Requires the 'MANAGE_MESSAGES' permission. Unpin(flags ...Flag) 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. Get(flags ...Flag) (*Message, 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. UpdateBuilder(flags ...Flag) *updateMessageBuilder SetContent(content string) (*Message, error) SetEmbed(embed *Embed) (*Message, error) CrossPost(flags ...Flag) (*Message, error) // Deprecated: use UpdateBuilder instead Update(flags ...Flag) *updateMessageBuilder // 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. Fires a Message Delete Gateway event. Delete(flags ...Flag) error // DeleteAllReactions Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' // permission to be present on the current user. DeleteAllReactions(flags ...Flag) error Reaction(emoji interface{}) ReactionQueryBuilder }
type MessageReactionAdd ¶ added in v0.6.0
type MessageReactionAdd struct { UserID Snowflake `json:"user_id"` ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` // PartialEmoji id and name. id might be nil PartialEmoji *Emoji `json:"emoji"` 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 MessageReactionRemove ¶ added in v0.6.0
type MessageReactionRemove struct { UserID Snowflake `json:"user_id"` ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` // PartialEmoji id and name. id might be nil PartialEmoji *Emoji `json:"emoji"` 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.6.0
type MessageReactionRemoveAll struct { ChannelID Snowflake `json:"channel_id"` MessageID Snowflake `json:"message_id"` ShardID uint `json:"-"` }
MessageReactionRemoveAll all reactions were explicitly removed from a message
type MessageReactionRemoveEmoji ¶ added in v0.20.0
type MessageReactionRemoveEmoji struct { ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id"` MessageID Snowflake `json:"message_id"` Emoji *Emoji `json:"emoji"` ShardID uint `json:"-"` }
MessageReactionRemoveEmoji Sent when a bot removes all instances of a given emoji from the reactions of a message
type MessageReference ¶ added in v0.12.0
type MessageSticker ¶ added in v0.25.0
type MessageSticker struct { ID Snowflake `json:"id"` PackID Snowflake `json:"pack_id"` Name string `json:"name"` Description string `json:"description"` Tags string `json:"tags"` Asset string `json:"asset"` PreviewAsset string `json:"preview_asset"` FormatType MessageStickerFormatType `json:"format_type"` }
type MessageStickerFormatType ¶ added in v0.22.0
type MessageStickerFormatType int
const ( MessageStickerFormatPNG MessageStickerFormatType MessageStickerFormatAPNG MessageStickerFormatLOTTIE )
type MessageType ¶ added in v0.12.0
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 MessageTypeGuildDiscoveryDisqualified MessageTypeGuildDiscoveryRequalified MessageTypeReply MessageTypeApplicationCommand )
type MessageUpdate ¶ added in v0.6.0
MessageUpdate message was edited
func (*MessageUpdate) UnmarshalJSON ¶ added in v0.8.0
func (obj *MessageUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type Middleware ¶ added in v0.9.2
type Middleware = func(interface{}) interface{}
Middleware allows you to manipulate data during the "stream"
type OptionType ¶ added in v0.27.0
type OptionType = int
const ( SUB_COMMAND OptionType SUB_COMMAND_GROUP STRING INTEGER BOOLEAN USER CHANNEL ROLE MENTIONABLE )
type PartialBan ¶ added in v0.10.0
PartialBan is used by audit logs
func (*PartialBan) String ¶ added in v0.10.0
func (p *PartialBan) String() string
type PartialChannel ¶ added in v0.6.0
type PartialChannel struct { ID Snowflake `json:"id"` Name string `json:"name"` Type ChannelType `json:"type"` }
PartialChannel ... example of partial channel // "channel": { // "id": "165176875973476352", // "name": "illuminati", // "type": 0 // }
type PartialInvite ¶ added in v0.6.0
type PartialInvite = Invite
PartialInvite ...
{ "code": "abc" }
type PermissionBit ¶ added in v0.10.3
type PermissionBit uint64
PermissionBit is used to define the permission bit(s) which are set.
const ( PermissionReadMessages PermissionBit = 1 << (iota + 10) PermissionSendMessages PermissionSendTTSMessages PermissionManageMessages PermissionEmbedLinks PermissionAttachFiles PermissionReadMessageHistory PermissionMentionEveryone PermissionUseExternalEmojis PermissionViewGuildInsights )
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) PermissionStream )
Constants for the different bit offsets of voice permissions
const ( PermissionChangeNickname PermissionBit = 1 << (iota + 26) PermissionManageNicknames PermissionManageRoles PermissionManageWebhooks PermissionManageEmojis )
Constants for general management.
func (PermissionBit) Contains ¶ added in v0.19.0
func (b PermissionBit) Contains(Bits PermissionBit) bool
Contains is used to check if the permission bits contains the bits specified.
func (*PermissionBit) MarshalJSON ¶ added in v0.20.0
func (b *PermissionBit) MarshalJSON() ([]byte, error)
func (*PermissionBit) UnmarshalJSON ¶ added in v0.20.0
func (b *PermissionBit) UnmarshalJSON(bytes []byte) error
type PermissionOverwrite ¶ added in v0.6.0
type PermissionOverwrite struct { ID Snowflake `json:"id"` // role or user id Type PermissionOverwriteType `json:"type"` Allow PermissionBit `json:"allow"` Deny PermissionBit `json:"deny"` }
PermissionOverwrite https://discord.com/developers/docs/resources/channel#overwrite-object
WARNING! Discord is bugged, and the Type field needs to be a string to read Permission Overwrites from audit log
type PermissionOverwriteType ¶ added in v0.25.0
type PermissionOverwriteType uint8
const ( PermissionOverwriteRole PermissionOverwriteType = iota PermissionOverwriteMember )
type PremiumTier ¶ added in v0.27.0
type PremiumTier uint
PremiumTier ... https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
const ( PremiumTierNone PremiumTier = iota PremiumTier1 PremiumTier2 PremiumTier3 )
the different premium tier levels
type PremiumType ¶ added in v0.9.3
type PremiumType int
const ( PremiumTypeNone PremiumType = iota PremiumTypeNitroClassic PremiumTypeNitro )
func (PremiumType) String ¶ added in v0.9.3
func (p PremiumType) String() (t string)
type PresenceUpdate ¶ added in v0.6.0
type PresenceUpdate struct { User *User `json:"user"` GuildID Snowflake `json:"guild_id"` Status string `json:"status"` Activities []*Activity `json:"activities"` ClientStatus ClientStatus `json:"client_status"` ShardID uint `json:"-"` }
PresenceUpdate user's presence was updated in a guild
func (*PresenceUpdate) Game ¶ added in v0.6.0
func (h *PresenceUpdate) Game() (*Activity, error)
type RESTBuilder ¶ added in v0.9.3
type RESTBuilder struct {
// contains filtered or unexported fields
}
func (*RESTBuilder) CancelOnRatelimit ¶ added in v0.9.3
func (b *RESTBuilder) CancelOnRatelimit() *RESTBuilder
func (*RESTBuilder) IgnoreCache ¶ added in v0.9.3
func (b *RESTBuilder) IgnoreCache() *RESTBuilder
type Reaction ¶ added in v0.6.0
type Reaction struct { Count uint `json:"count"` Me bool `json:"me"` Emoji *PartialEmoji `json:"Emoji"` }
Reaction ... https://discord.com/developers/docs/resources/channel#reaction-object
type ReactionQueryBuilder ¶ added in v0.19.0
type ReactionQueryBuilder interface { WithContext(ctx context.Context) ReactionQueryBuilder // 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. Create(flags ...Flag) (err error) // GetReaction Get a list of Users that reacted with this emoji. Returns an array of user objects on success. Get(params URLQueryStringer, flags ...Flag) (reactors []*User, err error) // DeleteOwnReaction Delete a reaction the current user has made for the message. // Returns a 204 empty response on success. DeleteOwn(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. DeleteUser(userID Snowflake, flags ...Flag) (err error) }
type Ready ¶ added in v0.6.0
type Ready struct { APIVersion int `json:"v"` User *User `json:"user"` Guilds []*GuildUnavailable `json:"guilds"` // not really needed, as it is handled on the socket layer. SessionID string `json:"session_id"` ShardID uint `json:"-"` }
Ready contains the initial state information
type RequestGuildMembersPayload ¶ added in v0.12.0
type RequestGuildMembersPayload = gateway.RequestGuildMembersPayload
################################################################# 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.10.0
type Reseter interface {
// contains filtered or unexported methods
}
Reseter Reset() zero initialises or empties a struct instance
type Resumed ¶ added in v0.6.0
type Resumed struct {
ShardID uint `json:"-"`
}
Resumed response to Resume
type Role ¶ added in v0.6.0
type Role struct { ID Snowflake `json:"id"` Name string `json:"name"` Color uint `json:"color"` Hoist bool `json:"hoist"` Position int `json:"position"` // can be -1 Permissions PermissionBit `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) Mention ¶ added in v0.6.0
Mention gives a formatted version of the role such that it can be parsed by Discord clients
func (*Role) SetGuildID ¶ added in v0.7.0
SetGuildID link role to a guild before running session.SaveToDiscord(*Role)
type Session ¶
type Session interface { // Logger returns the injected logger instance. If nothing was injected, a empty wrapper is returned // to avoid nil panics. Logger() logger.Logger // 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) // AddPermission is to store the permissions required by the bot to function as intended. AddPermission(permission PermissionBit) (updatedPermissions PermissionBit) GetPermissions() (permissions PermissionBit) Pool() *pools ClientQueryBuilder EditInteractionResponse(ctx context.Context, interaction *InteractionCreate, message *Message) error SendInteractionResponse(context context.Context, interaction *InteractionCreate, data *InteractionResponse) error // Status update functions UpdateStatus(s *UpdateStatusPayload) error UpdateStatusString(s string) error GetConnectedGuilds() []Snowflake }
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.12.0
type ShardConfig = gateway.ShardConfig
type Snowflake ¶ added in v0.6.0
Snowflake twitter snowflake identification for Discord
func GetSnowflake ¶ added in v0.6.0
GetSnowflake see snowflake.GetSnowflake
func ParseSnowflakeString ¶ added in v0.6.0
ParseSnowflakeString see snowflake.ParseSnowflakeString
type SocketHandlerRegistrator ¶ added in v0.19.0
type SocketHandlerRegistrator interface { ChannelCreate(handler HandlerChannelCreate, moreHandlers ...HandlerChannelCreate) ChannelCreateChan(handler chan *ChannelCreate, moreHandlers ...chan *ChannelCreate) ChannelDelete(handler HandlerChannelDelete, moreHandlers ...HandlerChannelDelete) ChannelDeleteChan(handler chan *ChannelDelete, moreHandlers ...chan *ChannelDelete) ChannelPinsUpdate(handler HandlerChannelPinsUpdate, moreHandlers ...HandlerChannelPinsUpdate) ChannelPinsUpdateChan(handler chan *ChannelPinsUpdate, moreHandlers ...chan *ChannelPinsUpdate) ChannelUpdate(handler HandlerChannelUpdate, moreHandlers ...HandlerChannelUpdate) ChannelUpdateChan(handler chan *ChannelUpdate, moreHandlers ...chan *ChannelUpdate) GuildBanAdd(handler HandlerGuildBanAdd, moreHandlers ...HandlerGuildBanAdd) GuildBanAddChan(handler chan *GuildBanAdd, moreHandlers ...chan *GuildBanAdd) GuildBanRemove(handler HandlerGuildBanRemove, moreHandlers ...HandlerGuildBanRemove) GuildBanRemoveChan(handler chan *GuildBanRemove, moreHandlers ...chan *GuildBanRemove) GuildCreate(handler HandlerGuildCreate, moreHandlers ...HandlerGuildCreate) GuildCreateChan(handler chan *GuildCreate, moreHandlers ...chan *GuildCreate) GuildDelete(handler HandlerGuildDelete, moreHandlers ...HandlerGuildDelete) GuildDeleteChan(handler chan *GuildDelete, moreHandlers ...chan *GuildDelete) GuildEmojisUpdate(handler HandlerGuildEmojisUpdate, moreHandlers ...HandlerGuildEmojisUpdate) GuildEmojisUpdateChan(handler chan *GuildEmojisUpdate, moreHandlers ...chan *GuildEmojisUpdate) GuildIntegrationsUpdate(handler HandlerGuildIntegrationsUpdate, moreHandlers ...HandlerGuildIntegrationsUpdate) GuildIntegrationsUpdateChan(handler chan *GuildIntegrationsUpdate, moreHandlers ...chan *GuildIntegrationsUpdate) GuildMemberAdd(handler HandlerGuildMemberAdd, moreHandlers ...HandlerGuildMemberAdd) GuildMemberAddChan(handler chan *GuildMemberAdd, moreHandlers ...chan *GuildMemberAdd) GuildMemberRemove(handler HandlerGuildMemberRemove, moreHandlers ...HandlerGuildMemberRemove) GuildMemberRemoveChan(handler chan *GuildMemberRemove, moreHandlers ...chan *GuildMemberRemove) GuildMemberUpdate(handler HandlerGuildMemberUpdate, moreHandlers ...HandlerGuildMemberUpdate) GuildMemberUpdateChan(handler chan *GuildMemberUpdate, moreHandlers ...chan *GuildMemberUpdate) GuildMembersChunk(handler HandlerGuildMembersChunk, moreHandlers ...HandlerGuildMembersChunk) GuildMembersChunkChan(handler chan *GuildMembersChunk, moreHandlers ...chan *GuildMembersChunk) GuildRoleCreate(handler HandlerGuildRoleCreate, moreHandlers ...HandlerGuildRoleCreate) GuildRoleCreateChan(handler chan *GuildRoleCreate, moreHandlers ...chan *GuildRoleCreate) GuildRoleDelete(handler HandlerGuildRoleDelete, moreHandlers ...HandlerGuildRoleDelete) GuildRoleDeleteChan(handler chan *GuildRoleDelete, moreHandlers ...chan *GuildRoleDelete) GuildRoleUpdate(handler HandlerGuildRoleUpdate, moreHandlers ...HandlerGuildRoleUpdate) GuildRoleUpdateChan(handler chan *GuildRoleUpdate, moreHandlers ...chan *GuildRoleUpdate) GuildUpdate(handler HandlerGuildUpdate, moreHandlers ...HandlerGuildUpdate) GuildUpdateChan(handler chan *GuildUpdate, moreHandlers ...chan *GuildUpdate) InteractionCreate(handler HandlerInteractionCreate, moreHandlers ...HandlerInteractionCreate) InteractionCreateChan(handler chan *InteractionCreate, moreHandlers ...chan *InteractionCreate) InviteCreate(handler HandlerInviteCreate, moreHandlers ...HandlerInviteCreate) InviteCreateChan(handler chan *InviteCreate, moreHandlers ...chan *InviteCreate) InviteDelete(handler HandlerInviteDelete, moreHandlers ...HandlerInviteDelete) InviteDeleteChan(handler chan *InviteDelete, moreHandlers ...chan *InviteDelete) MessageCreate(handler HandlerMessageCreate, moreHandlers ...HandlerMessageCreate) MessageCreateChan(handler chan *MessageCreate, moreHandlers ...chan *MessageCreate) MessageDelete(handler HandlerMessageDelete, moreHandlers ...HandlerMessageDelete) MessageDeleteChan(handler chan *MessageDelete, moreHandlers ...chan *MessageDelete) MessageDeleteBulk(handler HandlerMessageDeleteBulk, moreHandlers ...HandlerMessageDeleteBulk) MessageDeleteBulkChan(handler chan *MessageDeleteBulk, moreHandlers ...chan *MessageDeleteBulk) MessageReactionAdd(handler HandlerMessageReactionAdd, moreHandlers ...HandlerMessageReactionAdd) MessageReactionAddChan(handler chan *MessageReactionAdd, moreHandlers ...chan *MessageReactionAdd) MessageReactionRemove(handler HandlerMessageReactionRemove, moreHandlers ...HandlerMessageReactionRemove) MessageReactionRemoveChan(handler chan *MessageReactionRemove, moreHandlers ...chan *MessageReactionRemove) MessageReactionRemoveAll(handler HandlerMessageReactionRemoveAll, moreHandlers ...HandlerMessageReactionRemoveAll) MessageReactionRemoveAllChan(handler chan *MessageReactionRemoveAll, moreHandlers ...chan *MessageReactionRemoveAll) MessageReactionRemoveEmoji(handler HandlerMessageReactionRemoveEmoji, moreHandlers ...HandlerMessageReactionRemoveEmoji) MessageReactionRemoveEmojiChan(handler chan *MessageReactionRemoveEmoji, moreHandlers ...chan *MessageReactionRemoveEmoji) MessageUpdate(handler HandlerMessageUpdate, moreHandlers ...HandlerMessageUpdate) MessageUpdateChan(handler chan *MessageUpdate, moreHandlers ...chan *MessageUpdate) PresenceUpdate(handler HandlerPresenceUpdate, moreHandlers ...HandlerPresenceUpdate) PresenceUpdateChan(handler chan *PresenceUpdate, moreHandlers ...chan *PresenceUpdate) Ready(handler HandlerReady, moreHandlers ...HandlerReady) ReadyChan(handler chan *Ready, moreHandlers ...chan *Ready) Resumed(handler HandlerResumed, moreHandlers ...HandlerResumed) ResumedChan(handler chan *Resumed, moreHandlers ...chan *Resumed) TypingStart(handler HandlerTypingStart, moreHandlers ...HandlerTypingStart) TypingStartChan(handler chan *TypingStart, moreHandlers ...chan *TypingStart) UserUpdate(handler HandlerUserUpdate, moreHandlers ...HandlerUserUpdate) UserUpdateChan(handler chan *UserUpdate, moreHandlers ...chan *UserUpdate) VoiceServerUpdate(handler HandlerVoiceServerUpdate, moreHandlers ...HandlerVoiceServerUpdate) VoiceServerUpdateChan(handler chan *VoiceServerUpdate, moreHandlers ...chan *VoiceServerUpdate) VoiceStateUpdate(handler HandlerVoiceStateUpdate, moreHandlers ...HandlerVoiceStateUpdate) VoiceStateUpdateChan(handler chan *VoiceStateUpdate, moreHandlers ...chan *VoiceStateUpdate) WebhooksUpdate(handler HandlerWebhooksUpdate, moreHandlers ...HandlerWebhooksUpdate) WebhooksUpdateChan(handler chan *WebhooksUpdate, moreHandlers ...chan *WebhooksUpdate) WithCtrl(HandlerCtrl) SocketHandlerRegistrator WithMiddleware(first Middleware, extra ...Middleware) SocketHandlerRegistrator }
type StickerItem ¶ added in v0.28.3
type StickerItem struct { ID Snowflake `json:"id"` Name string `json:"name"` FormatType MessageStickerFormatType `json:"format_type"` }
type Time ¶ added in v0.10.0
Time handles Discord timestamps
func (Time) MarshalJSON ¶ added in v0.10.0
MarshalJSON implements json.Marshaler. error: https://stackoverflow.com/questions/28464711/go-strange-json-hyphen-unmarshall-error
func (Time) String ¶ added in v0.10.0
String returns the timestamp as a Discord formatted timestamp. Formatting with time.RFC3331 does not suffice.
func (*Time) UnmarshalJSON ¶ added in v0.10.0
UnmarshalJSON implements json.Unmarshaler.
type TypingStart ¶ added in v0.6.0
type TypingStart struct { ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id"` UserID Snowflake `json:"user_id"` Member *Member `json:"member"` TimestampUnix int `json:"timestamp"` ShardID uint `json:"-"` }
TypingStart user started typing in a channel
type URLQueryStringer ¶ added in v0.10.0
type URLQueryStringer interface {
URLQueryString() string
}
URLQueryStringer converts a struct of values to a valid URL query string
type UpdateChannelBuilder ¶ added in v0.19.0
type UpdateChannelBuilder interface { Execute() (channel *Channel, err error) IgnoreCache() UpdateChannelBuilder CancelOnRatelimit() UpdateChannelBuilder URLParam(name string, v interface{}) UpdateChannelBuilder Set(name string, v interface{}) UpdateChannelBuilder SetParentID(parentID Snowflake) UpdateChannelBuilder SetPermissionOverwrites(permissionOverwrites []PermissionOverwrite) UpdateChannelBuilder SetUserLimit(userLimit uint) UpdateChannelBuilder SetBitrate(bitrate uint) UpdateChannelBuilder SetRateLimitPerUser(rateLimitPerUser uint) UpdateChannelBuilder SetNsfw(nsfw bool) UpdateChannelBuilder SetTopic(topic string) UpdateChannelBuilder SetPosition(position int) UpdateChannelBuilder SetName(name string) UpdateChannelBuilder }
UpdateChannelBuilder is the interface for the builder.
type UpdateChannelPermissionsParams ¶ added in v0.10.0
type UpdateChannelPermissionsParams struct { Allow PermissionBit `json:"allow"` // the bitwise value of all allowed permissions Deny PermissionBit `json:"deny"` // the bitwise value of all disallowed permissions Type uint `json:"type"` // 0=role, 1=member }
UpdateChannelPermissionsParams https://discord.com/developers/docs/resources/channel#edit-channel-permissions-json-params
type UpdateCurrentUserBuilder ¶ added in v0.19.0
type UpdateCurrentUserBuilder interface { Execute() (user *User, err error) IgnoreCache() UpdateCurrentUserBuilder CancelOnRatelimit() UpdateCurrentUserBuilder URLParam(name string, v interface{}) UpdateCurrentUserBuilder Set(name string, v interface{}) UpdateCurrentUserBuilder SetUsername(username string) UpdateCurrentUserBuilder SetAvatar(avatar string) UpdateCurrentUserBuilder }
UpdateCurrentUserBuilder is the interface for the builder.
type UpdateGuildBuilder ¶ added in v0.19.0
type UpdateGuildBuilder interface { Execute() (guild *Guild, err error) IgnoreCache() UpdateGuildBuilder CancelOnRatelimit() UpdateGuildBuilder URLParam(name string, v interface{}) UpdateGuildBuilder Set(name string, v interface{}) UpdateGuildBuilder SetName(name string) UpdateGuildBuilder SetRegion(region string) UpdateGuildBuilder SetVerificationLevel(verificationLevel int) UpdateGuildBuilder SetDefaultMessageNotifications(defaultMessageNotifications DefaultMessageNotificationLvl) UpdateGuildBuilder SetExplicitContentFilter(explicitContentFilter ExplicitContentFilterLvl) UpdateGuildBuilder SetAfkChannelID(afkChannelID Snowflake) UpdateGuildBuilder SetAfkTimeout(afkTimeout int) UpdateGuildBuilder SetIcon(icon string) UpdateGuildBuilder SetOwnerID(ownerID Snowflake) UpdateGuildBuilder SetSplash(splash string) UpdateGuildBuilder SetSystemChannelID(systemChannelID Snowflake) UpdateGuildBuilder }
UpdateGuildBuilder is the interface for the builder.
type UpdateGuildChannelPositionsParams ¶ added in v0.10.0
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 UpdateGuildEmbedBuilder ¶ added in v0.19.0
type UpdateGuildEmbedBuilder interface { Execute() (embed *GuildEmbed, err error) IgnoreCache() UpdateGuildEmbedBuilder CancelOnRatelimit() UpdateGuildEmbedBuilder URLParam(name string, v interface{}) UpdateGuildEmbedBuilder Set(name string, v interface{}) UpdateGuildEmbedBuilder SetEnabled(enabled bool) UpdateGuildEmbedBuilder SetChannelID(channelID Snowflake) UpdateGuildEmbedBuilder }
UpdateGuildEmbedBuilder is the interface for the builder.
type UpdateGuildEmojiBuilder ¶ added in v0.19.0
type UpdateGuildEmojiBuilder interface { Execute() (emoji *Emoji, err error) IgnoreCache() UpdateGuildEmojiBuilder CancelOnRatelimit() UpdateGuildEmojiBuilder URLParam(name string, v interface{}) UpdateGuildEmojiBuilder Set(name string, v interface{}) UpdateGuildEmojiBuilder SetName(name string) UpdateGuildEmojiBuilder SetRoles(roles []Snowflake) UpdateGuildEmojiBuilder }
UpdateGuildEmojiBuilder is the interface for the builder.
type UpdateGuildIntegrationParams ¶ added in v0.10.0
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 UpdateGuildMemberBuilder ¶ added in v0.19.0
type UpdateGuildMemberBuilder interface { Execute() (err error) IgnoreCache() UpdateGuildMemberBuilder CancelOnRatelimit() UpdateGuildMemberBuilder URLParam(name string, v interface{}) UpdateGuildMemberBuilder Set(name string, v interface{}) UpdateGuildMemberBuilder SetNick(nick string) UpdateGuildMemberBuilder SetRoles(roles []Snowflake) UpdateGuildMemberBuilder SetMute(mute bool) UpdateGuildMemberBuilder SetDeaf(deaf bool) UpdateGuildMemberBuilder SetChannelID(channelID Snowflake) UpdateGuildMemberBuilder KickFromVoice() UpdateGuildMemberBuilder DeleteNick() UpdateGuildMemberBuilder }
UpdateGuildMemberBuilder is the interface for the builder.
type UpdateGuildRoleBuilder ¶ added in v0.19.0
type UpdateGuildRoleBuilder interface { Execute() (role *Role, err error) IgnoreCache() UpdateGuildRoleBuilder CancelOnRatelimit() UpdateGuildRoleBuilder URLParam(name string, v interface{}) UpdateGuildRoleBuilder Set(name string, v interface{}) UpdateGuildRoleBuilder SetName(name string) UpdateGuildRoleBuilder SetPermissions(permissions PermissionBit) UpdateGuildRoleBuilder SetColor(color uint) UpdateGuildRoleBuilder SetHoist(hoist bool) UpdateGuildRoleBuilder SetMentionable(mentionable bool) UpdateGuildRoleBuilder }
UpdateGuildRoleBuilder is the interface for the builder.
type UpdateGuildRolePositionsParams ¶ added in v0.10.0
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.10.0
func NewUpdateGuildRolePositionsParams(rs []*Role) (p []UpdateGuildRolePositionsParams)
type UpdateMessageBuilder ¶ added in v0.19.0
type UpdateMessageBuilder interface { Execute() (message *Message, err error) IgnoreCache() UpdateMessageBuilder CancelOnRatelimit() UpdateMessageBuilder URLParam(name string, v interface{}) UpdateMessageBuilder Set(name string, v interface{}) UpdateMessageBuilder SetContent(content string) UpdateMessageBuilder SetEmbed(embed *Embed) UpdateMessageBuilder }
UpdateMessageBuilder is the interface for the builder.
type UpdateStatusPayload ¶ added in v0.12.0
type UpdateStatusPayload = gateway.UpdateStatusPayload
UpdateStatusPayload payload for socket command UPDATE_STATUS. see UpdateStatus
Wrapper for websocket.UpdateStatusPayload
type UpdateVoiceStatePayload ¶ added in v0.12.0
type UpdateVoiceStatePayload = gateway.UpdateVoiceStatePayload
UpdateVoiceStatePayload payload for socket command UPDATE_VOICE_STATE. see UpdateVoiceState
Wrapper for websocket.UpdateVoiceStatePayload
type UpdateWebhookBuilder ¶ added in v0.19.0
type UpdateWebhookBuilder interface { Execute() (webhook *Webhook, err error) IgnoreCache() UpdateWebhookBuilder CancelOnRatelimit() UpdateWebhookBuilder URLParam(name string, v interface{}) UpdateWebhookBuilder Set(name string, v interface{}) UpdateWebhookBuilder SetName(name string) UpdateWebhookBuilder SetAvatar(avatar string) UpdateWebhookBuilder SetChannelID(channelID Snowflake) UpdateWebhookBuilder }
UpdateWebhookBuilder is the interface for the builder.
type User ¶ added in v0.6.0
type User struct { ID Snowflake `json:"id,omitempty"` Username string `json:"username,omitempty"` Discriminator Discriminator `json:"discriminator,omitempty"` Avatar string `json:"avatar"` // data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA Bot bool `json:"bot,omitempty"` System bool `json:"system,omitempty"` MFAEnabled bool `json:"mfa_enabled,omitempty"` Locale string `json:"locale,omitempty"` Verified bool `json:"verified,omitempty"` Email string `json:"email,omitempty"` Flags UserFlag `json:"flag,omitempty"` PremiumType PremiumType `json:"premium_type,omitempty"` PublicFlags UserFlag `json:"public_flag,omitempty"` PartialMember *Member `json:"member"` // may be populated by Message }
User the Discord user object which is reused in most other data structures.
func (*User) AvatarURL ¶ added in v0.12.0
AvatarURL returns a link to the Users avatar with the given size.
func (*User) Mention ¶ added in v0.6.0
Mention returns the a string that Discord clients can format into a valid Discord mention
func (*User) SendMsg ¶ added in v0.6.0
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.6.0
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.
type UserConnection ¶ added in v0.6.0
type UserConnection struct { 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 ...
type UserFlag ¶ added in v0.17.3
type UserFlag uint64
const ( UserFlagNone UserFlag = 0 UserFlagDiscordEmployee UserFlag = 1 << iota UserFlagDiscordPartner UserFlagHypeSquadEvents UserFlagBugHunterLevel1 UserFlagHouseBravery UserFlagHouseBrilliance UserFlagHouseBalance UserFlagEarlySupporter UserFlagTeamUser UserFlagSystem UserFlagBugHunterLevel2 UserFlagVerifiedBot UserFlagVerifiedBotDeveloper UserFlagDiscordCertifiedModerator )
type UserPresence ¶ added in v0.6.0
type UserPresence struct { 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 (*UserPresence) String ¶ added in v0.6.0
func (p *UserPresence) String() string
type UserQueryBuilder ¶ added in v0.19.0
type UserQueryBuilder interface { WithContext(ctx context.Context) UserQueryBuilder // GetUser Returns a user object for a given user Snowflake. Get(flags ...Flag) (*User, error) // CreateDM Create a new DM channel with a user. Returns a DM channel object. CreateDM(flags ...Flag) (ret *Channel, err error) }
RESTUser REST interface for all user endpoints
type UserUpdate ¶ added in v0.6.0
UserUpdate properties about a user changed
func (*UserUpdate) UnmarshalJSON ¶ added in v0.17.3
func (obj *UserUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type VerificationLvl ¶ added in v0.6.0
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.6.0
func (vl *VerificationLvl) High() bool
High (╯°□°)╯︵ ┻━┻ - must be a member of the server for longer than 10 minutes
func (*VerificationLvl) Low ¶ added in v0.6.0
func (vl *VerificationLvl) Low() bool
Low must have verified email on account
func (*VerificationLvl) Medium ¶ added in v0.6.0
func (vl *VerificationLvl) Medium() bool
Medium must be registered on Discord for longer than 5 minutes
func (*VerificationLvl) None ¶ added in v0.6.0
func (vl *VerificationLvl) None() bool
None unrestricted
func (*VerificationLvl) VeryHigh ¶ added in v0.6.0
func (vl *VerificationLvl) VeryHigh() bool
VeryHigh ┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻ - must have a verified phone number
type VoiceChannelQueryBuilder ¶ added in v0.22.0
type VoiceChannelQueryBuilder interface { WithContext(ctx context.Context) ChannelQueryBuilder // GetChannel Get a channel by Snowflake. Returns a channel object. Get(flags ...Flag) (*Channel, 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. UpdateBuilder(flags ...Flag) *updateChannelBuilder // Deprecated: use UpdateBuilder Update(flags ...Flag) *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. Delete(flags ...Flag) (*Channel, 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. UpdatePermissions(overwriteID Snowflake, params *UpdateChannelPermissionsParams, flags ...Flag) error // GetChannelInvites Returns a list of invite objects (with invite metadata) for the channel. Only usable for // guild Channels. Requires the 'MANAGE_CHANNELS' permission. GetInvites(flags ...Flag) ([]*Invite, error) // CreateChannelInvite 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. CreateInvite(flags ...Flag) *createChannelInviteBuilder // 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 DeletePermission(overwriteID Snowflake, flags ...Flag) error // param{deaf} is deprecated Connect(mute, deaf bool) (VoiceConnection, error) JoinManual(mute, deaf bool) (*VoiceStateUpdate, *VoiceServerUpdate, error) }
type VoiceConnection ¶ added in v0.9.0
type VoiceConnection interface { // StartSpeaking should be sent before sending voice data. StartSpeaking() error // StopSpeaking should be sent after sending voice data. If there's a break in the sent data, you should not simply // stop sending data. Instead you have to send five frames of silence ([]byte{0xF8, 0xFF, 0xFE}) before stopping // to avoid unintended Opus interpolation with subsequent transmissions. StopSpeaking() error // SendOpusFrame sends a single frame of opus data to the UDP server. Frames are sent every 20ms with 960 samples (48kHz). // // 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 VoiceRegion ¶ added in v0.6.0
type VoiceRegion struct { // 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
type VoiceServerUpdate ¶ added in v0.6.0
type VoiceServerUpdate struct { Token string `json:"token"` GuildID Snowflake `json:"guild_id"` Endpoint string `json:"endpoint"` 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 VoiceState ¶ added in v0.6.0
type VoiceState struct { // 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) UnmarshalJSON ¶ added in v0.19.0
func (v *VoiceState) UnmarshalJSON(data []byte) error
UnmarshalJSON is used to unmarshal Discord's JSON.
type VoiceStateUpdate ¶ added in v0.6.0
type VoiceStateUpdate struct { *VoiceState ShardID uint `json:"-"` }
VoiceStateUpdate someone joined, left, or moved a voice channel
func (*VoiceStateUpdate) UnmarshalJSON ¶ added in v0.19.0
func (h *VoiceStateUpdate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type Webhook ¶ added in v0.6.0
type Webhook struct { 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
type WebhookQueryBuilder ¶ added in v0.19.0
type WebhookQueryBuilder interface { WithContext(ctx context.Context) WebhookQueryBuilder // GetWebhook Returns the new webhook object for the given id. Get(flags ...Flag) (*Webhook, error) // UpdateBuilder Modify a webhook. Requires the 'MANAGE_WEBHOOKS' permission. // Returns the updated webhook object on success. UpdateBuilder(flags ...Flag) *updateWebhookBuilder // Deprecated: use UpdateBuilder Update(flags ...Flag) *updateWebhookBuilder // Delete Deletes a webhook permanently. User must be owner. Returns a 204 NO CONTENT response on success. Delete(flags ...Flag) error // Execute Trigger a webhook in Discord. Execute(params *ExecuteWebhookParams, wait bool, URLSuffix string, flags ...Flag) (*Message, error) // ExecuteSlackWebhook Trigger a webhook in Discord from the Slack app. ExecuteSlackWebhook(params *ExecuteWebhookParams, wait bool, flags ...Flag) (*Message, error) // ExecuteGitHubWebhook Trigger a webhook in Discord from the GitHub app. ExecuteGitHubWebhook(params *ExecuteWebhookParams, wait bool, flags ...Flag) (*Message, error) WithToken(token string) WebhookWithTokenQueryBuilder }
type WebhookWithTokenQueryBuilder ¶ added in v0.19.0
type WebhookWithTokenQueryBuilder interface { WithContext(ctx context.Context) WebhookWithTokenQueryBuilder // Get Same as GetWebhook, except this call does not require authentication and // returns no user in the webhook object. Get(flags ...Flag) (*Webhook, error) // UpdateBuilder 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. UpdateBuilder(flags ...Flag) *updateWebhookBuilder // Deprecated: use UpdateBuilder Update(flags ...Flag) *updateWebhookBuilder // Delete Same as DeleteWebhook, except this call does not require authentication. Delete(flags ...Flag) error Execute(params *ExecuteWebhookParams, wait bool, URLSuffix string, flags ...Flag) (*Message, error) }
type WebhooksUpdate ¶ added in v0.6.0
type WebhooksUpdate struct { GuildID Snowflake `json:"guild_id"` ChannelID Snowflake `json:"channel_id"` ShardID uint `json:"-"` }
WebhooksUpdate guild channel webhook was created, update, or deleted
Source Files ¶
- auditlog.go
- cache.go
- cache_gen.go
- channel.go
- client.go
- deprecated.go
- disgord.go
- embed.go
- emoji.go
- errors.go
- events.go
- events_gen.go
- flag.go
- flag_string.go
- gateway.go
- guild.go
- iface_copier_gen.go
- iface_deepcopier_gen.go
- iface_internalupdaters_gen.go
- iface_reseter_gen.go
- iface_urlquerystringer_gen.go
- intents_gen.go
- interaction.go
- invite.go
- logging.go
- member.go
- message.go
- pool.go
- reaction.go
- reactor.go
- reactor_gen.go
- rest.go
- rest_nop_query_impl.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 |
---|---|
generate
|
|
discorddocs
Module
|
|
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). |