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
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 ActiveGuildThreads
- type Activity
- type ActivityAssets
- type ActivityEmoji
- type ActivityFlag
- type ActivityParty
- type ActivitySecrets
- type ActivityTimestamp
- type ActivityType
- type AddGuildMember
- type AllowedMentions
- type Application
- type ApplicationCommand
- type ApplicationCommandDataOption
- type ApplicationCommandFunctions
- type ApplicationCommandInteractionData
- type ApplicationCommandInteractionDataResolved
- type ApplicationCommandOption
- type ApplicationCommandOptionChoice
- type ApplicationCommandPermissionType
- type ApplicationCommandPermissions
- type ApplicationCommandQueryBuilder
- type ApplicationCommandType
- type ArchivedThreads
- type Attachment
- type AuditLog
- type AuditLogChange
- type AuditLogChanges
- type AuditLogEntry
- type AuditLogEvt
- type AuditLogOption
- type AutoArchiveDurationTime
- type AvatarParamHolder
- type Ban
- type BanMember
- 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 *GetCurrentUserGuilds) ([]*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 *GetMembers) ([]*Member, error)
- func (c *CacheNop) GetMessage(channelID, messageID Snowflake) (*Message, error)
- func (c *CacheNop) GetMessages(channel Snowflake, p *GetMessages) ([]*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) GuildScheduledEventCreate(data []byte) (evt *GuildScheduledEventCreate, err error)
- func (c *CacheNop) GuildScheduledEventDelete(data []byte) (evt *GuildScheduledEventDelete, err error)
- func (c *CacheNop) GuildScheduledEventUpdate(data []byte) (evt *GuildScheduledEventUpdate, err error)
- func (c *CacheNop) GuildScheduledEventUserAdd(data []byte) (evt *GuildScheduledEventUserAdd, err error)
- func (c *CacheNop) GuildScheduledEventUserRemove(data []byte) (evt *GuildScheduledEventUserRemove, err error)
- func (c *CacheNop) GuildStickersUpdate(data []byte) (evt *GuildStickersUpdate, 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) ThreadCreate(data []byte) (evt *ThreadCreate, err error)
- func (c *CacheNop) ThreadDelete(data []byte) (evt *ThreadDelete, err error)
- func (c *CacheNop) ThreadListSync(data []byte) (evt *ThreadListSync, err error)
- func (c *CacheNop) ThreadMemberUpdate(data []byte) (evt *ThreadMemberUpdate, err error)
- func (c *CacheNop) ThreadMembersUpdate(data []byte) (evt *ThreadMembersUpdate, err error)
- func (c *CacheNop) ThreadUpdate(data []byte) (evt *ThreadUpdate, 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) (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) ApplicationCommand(id Snowflake) ApplicationCommandQueryBuilder
- func (c *Client) AvgHeartbeatLatency() (duration time.Duration, err error)
- func (c Client) BotAuthorizeURL(permissions PermissionBit, scopes []string) (*url.URL, error)
- func (c *Client) Cache() Cache
- func (c Client) Channel(id Snowflake) ChannelQueryBuilder
- func (c Client) CreateGuild(guildName string, params *CreateGuild) (ret *Guild, err error)
- func (c Client) CurrentUser() CurrentUserQueryBuilder
- func (c *Client) EditInteractionResponse(ctx context.Context, interaction *InteractionCreate, message *UpdateMessage) error
- func (c *Client) Gateway() GatewayQueryBuilder
- func (c *Client) GetConnectedGuilds() []Snowflake
- func (c Client) GetVoiceRegions() (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, ...) 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
- func (c Client) WithContextAndFlags(ctx context.Context, flags ...Flag) ClientQueryBuilderExecutables
- func (c Client) WithFlags(flags ...Flag) ClientQueryBuilderExecutables
- type ClientQueryBuilder
- type ClientQueryBuilderExecutables
- type ClientStatus
- type CloseConnectionErr
- type Config
- type Copier
- type CreateApplicationCommand
- type CreateGroupDM
- type CreateGuild
- type CreateGuildChannel
- type CreateGuildEmoji
- type CreateGuildIntegration
- type CreateGuildRole
- type CreateInteractionResponse
- type CreateInteractionResponseData
- type CreateInvite
- type CreateMessage
- type CreateMessageFile
- type CreateScheduledEvent
- type CreateThread
- type CreateThreadWithoutMessage
- type CreateWebhook
- type Ctrl
- type CurrentUserQueryBuilder
- type DeepCopier
- type DefaultMessageNotificationLvl
- type DeleteMessages
- 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 ExecuteWebhook
- type ExplicitContentFilterLvl
- type Flag
- type GatewayCmdName
- type GatewayQueryBuilder
- type GetArchivedThreads
- type GetAuditLogs
- type GetCurrentUserGuilds
- type GetMembers
- type GetMessages
- type GetPruneMembersCount
- type GetReactionURL
- type GetScheduledEvent
- type GetScheduledEventMembers
- type GetScheduledEvents
- 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 GuildApplicationCommandPermissions
- type GuildBanAdd
- type GuildBanRemove
- type GuildCreate
- type GuildDelete
- 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 GuildScheduledEvent
- type GuildScheduledEventCreate
- type GuildScheduledEventDelete
- type GuildScheduledEventEntityTypes
- type GuildScheduledEventPrivacyLevel
- type GuildScheduledEventQueryBuilder
- type GuildScheduledEventStatus
- type GuildScheduledEventUpdate
- type GuildScheduledEventUserAdd
- type GuildScheduledEventUserRemove
- type GuildScheduledEventUsers
- type GuildStickersUpdate
- type GuildUnavailable
- type GuildUpdate
- type GuildWidget
- 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 HandlerGuildScheduledEventCreate
- type HandlerGuildScheduledEventDelete
- type HandlerGuildScheduledEventUpdate
- type HandlerGuildScheduledEventUserAdd
- type HandlerGuildScheduledEventUserRemove
- type HandlerGuildStickersUpdate
- 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 HandlerThreadCreate
- type HandlerThreadDelete
- type HandlerThreadListSync
- type HandlerThreadMemberUpdate
- type HandlerThreadMembersUpdate
- type HandlerThreadUpdate
- type HandlerTypingStart
- type HandlerUserUpdate
- type HandlerVoiceServerUpdate
- type HandlerVoiceStateUpdate
- type HandlerWebhooksUpdate
- type HttpClientDoer
- type Integration
- type IntegrationAccount
- type Intent
- type InteractionCallbackType
- type InteractionCreate
- 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) (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{}) error
- func (m *Message) Reply(ctx context.Context, s Session, data ...interface{}) (*Message, error)
- func (m *Message) Send(ctx context.Context, s Session) (msg *Message, err error)
- func (m *Message) String() string
- func (m *Message) Unreact(ctx context.Context, s Session, emoji interface{}) 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 PruneMembers
- type RESTBuilder
- type Reaction
- type ReactionQueryBuilder
- type Ready
- type RequestGuildMembersPayload
- type Reseter
- type Resumed
- type Role
- type ScheduledEventEntityMetadata
- type SelectMenuOption
- type Session
- type ShardConfig
- type Snowflake
- type SocketHandlerRegistrator
- type StickerItem
- type TextInputStyle
- type ThreadCreate
- type ThreadDelete
- type ThreadListSync
- type ThreadMember
- type ThreadMemberUpdate
- type ThreadMembersUpdate
- type ThreadMetadata
- type ThreadUpdate
- type Time
- type TypingStart
- type URLQueryStringer
- type UpdateApplicationCommand
- type UpdateChannel
- type UpdateChannelPermissions
- type UpdateEmoji
- type UpdateGuild
- type UpdateGuildChannelPositions
- type UpdateGuildIntegration
- type UpdateGuildRolePositions
- type UpdateGuildWidget
- type UpdateMember
- type UpdateMessage
- type UpdateRole
- type UpdateScheduledEvent
- type UpdateStatusPayload
- type UpdateUser
- type UpdateVoiceStatePayload
- type UpdateWebhook
- 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 VideoQualityMode
- type VoiceChannelQueryBuilder
- type VoiceConnection
- type VoiceRegion
- type VoiceServerUpdate
- type VoiceState
- type VoiceStateUpdate
- type Webhook
- type WebhookQueryBuilder
- type WebhookWithTokenQueryBuilder
- type WebhooksUpdate
Constants ¶
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 PermissionViewChannel PermissionTextAll = PermissionReadMessages | PermissionSendMessages | PermissionSendTTSMessages | PermissionManageMessages | PermissionEmbedLinks | PermissionAttachFiles | PermissionReadMessageHistory | PermissionMentionEveryone | PermissionUseExternalEmojis | PermissionViewGuildInsights | PermissionUseExternalStickers | PermissionUseSlashCommands PermissionVoiceAll = PermissionVoiceConnect | PermissionVoiceSpeak | PermissionVoiceMuteMembers | PermissionVoiceDeafenMembers | PermissionVoiceMoveMembers | PermissionVoiceUseVAD | PermissionVoicePrioritySpeaker | PermissionVoiceStream | PermissionUseEmbeddedActivites PermissionChannelAll = PermissionTextAll | PermissionCreateInstantInvite | PermissionAddReactions | PermissionViewAuditLogs | PermissionViewChannel | PermissionSendMessagesInThreads | PermissionCreatePublicThreads | PermissionCreatePrivateThreads // I don't really think changing your own nickname counts as management but I don't want to create a whole new catergory. // Also idk if some sort of system was being followed when doing this or if it's just based on opinion PermissionManagementAll = PermissionManageRoles | PermissionManageChannels | PermissionKickMembers | PermissionBanMembers | PermissionManageServer | PermissionAdministrator | PermissionChangeNickname | PermissionManageNicknames | PermissionManageWebhooks | PermissionManageEmojis | PermissionManageEvents | PermissionManageThreads | PermissionTimeoutMembers PermissionAll = PermissionTextAll | PermissionVoiceAll | PermissionChannelAll | PermissionManagementAll )
Constants for the different bit offsets of general permissions
const ( IntentDirectMessageReactions = gateway.IntentDirectMessageReactions IntentDirectMessageTyping = gateway.IntentDirectMessageTyping IntentDirectMessages = gateway.IntentDirectMessages IntentGuildBans = gateway.IntentGuildBans IntentGuildEmojisAndStickers = gateway.IntentGuildEmojisAndStickers IntentGuildIntegrations = gateway.IntentGuildIntegrations IntentGuildInvites = gateway.IntentGuildInvites IntentGuildMembers = gateway.IntentGuildMembers IntentGuildMessageReactions = gateway.IntentGuildMessageReactions IntentGuildMessageTyping = gateway.IntentGuildMessageTyping IntentGuildMessages = gateway.IntentGuildMessages IntentGuildPresences = gateway.IntentGuildPresences IntentGuildScheduledEvents = gateway.IntentGuildScheduledEvents 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 EvtGuildScheduledEventCreate = event.GuildScheduledEventCreate
EvtGuildScheduledEventCreate ...
const EvtGuildScheduledEventDelete = event.GuildScheduledEventDelete
EvtGuildScheduledEventDelete ...
const EvtGuildScheduledEventUpdate = event.GuildScheduledEventUpdate
EvtGuildScheduledEventUpdate ...
const EvtGuildScheduledEventUserAdd = event.GuildScheduledEventUserAdd
EvtGuildScheduledEventUserAdd ...
const EvtGuildScheduledEventUserRemove = event.GuildScheduledEventUserRemove
EvtGuildScheduledEventUserRemove ...
const EvtGuildStickersUpdate = event.GuildStickersUpdate
EvtGuildStickersUpdate ...
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 EvtThreadCreate = event.ThreadCreate
EvtThreadCreate Sent when a thread is created, relevant to the current user, or when the current user is added to a thread.
const EvtThreadDelete = event.ThreadDelete
EvtThreadDelete Sent when a thread relevant to the current user is deleted.
const EvtThreadListSync = event.ThreadListSync
EvtThreadListSync Sent when the current user gains access to a channel.
const EvtThreadMemberUpdate = event.ThreadMemberUpdate
EvtThreadMemberUpdate Sent when the thread member object for the current user is updated.
const EvtThreadMembersUpdate = event.ThreadMembersUpdate
EvtThreadMembersUpdate Sent when anyone is added to or removed from a thread.
const EvtThreadUpdate = event.ThreadUpdate
EvtThreadUpdate Sent when a thread is updated.
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 DefaultHttpClient = &http.Client{}
var ErrCacheEntryAlreadyExists = errors.New("cache entry already exists")
var ErrCacheMiss = errors.New("no matching entry found in cache")
var ErrIllegalScheduledEventPrivacyLevelValue = fmt.Errorf("scheduled event privacy level: %w", ErrIllegalValue)
var ErrIllegalValue = errors.New("illegal value")
var ErrMissingChannelID = fmt.Errorf("channel: %w", ErrMissingID)
var ErrMissingChannelName = fmt.Errorf("channel: %w", ErrMissingName)
var ErrMissingClientInstance = errors.New("client instance was not specified")
var ErrMissingEmojiID = fmt.Errorf("emoji: %w", ErrMissingID)
var ErrMissingGuildID = fmt.Errorf("guild: %w", ErrMissingID)
var ErrMissingGuildName = fmt.Errorf("guild: %w", ErrMissingName)
var ErrMissingID = fmt.Errorf("id: %w", ErrMissingRequiredField)
var ErrMissingMessageID = fmt.Errorf("message: %w", ErrMissingID)
var ErrMissingName = fmt.Errorf("name: %w", ErrMissingRequiredField)
var ErrMissingPermissionOverwriteID = fmt.Errorf("channel permission overwrite: %w", ErrMissingID)
var ErrMissingRESTParams = errors.New("this method requires REST parameters, but none were given")
var ErrMissingRequiredField = errors.New("missing required field")
var ErrMissingRoleID = fmt.Errorf("role: %w", ErrMissingID)
var ErrMissingScheduledEventEndTime = fmt.Errorf("scheduled event end: %w", ErrMissingTime)
var ErrMissingScheduledEventEntityType = fmt.Errorf("scheduled event entity: %w", ErrMissingType)
var ErrMissingScheduledEventLocation = fmt.Errorf("scheduled event: %w", ErrMissingRequiredField)
var ErrMissingScheduledEventName = fmt.Errorf("scheduled event name: %w", ErrMissingName)
var ErrMissingScheduledEventStartTime = fmt.Errorf("scheduled event start: %w", ErrMissingTime)
var ErrMissingThreadName = fmt.Errorf("thread: %w", ErrMissingName)
var ErrMissingTime = fmt.Errorf("time: %w", ErrMissingRequiredField)
var ErrMissingType = fmt.Errorf("type: %w", ErrMissingRequiredField)
var ErrMissingUserID = fmt.Errorf("user: %w", ErrMissingID)
var ErrMissingWebhookID = fmt.Errorf("webhook: %w", ErrMissingID)
var ErrMissingWebhookName = fmt.Errorf("webhook: %w", ErrMissingName)
var ErrMissingWebhookToken = errors.New("webhook token was not set")
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 ActiveGuildThreads ¶ added in v0.30.0
type ActiveGuildThreads struct { Threads []*Channel `json:"threads"` Members []*ThreadMember `json:"members"` }
ActiveGuildThreads https://discord.com/developers/docs/resources/guild#list-active-threads-response-body
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 AddGuildMember ¶ added in v0.6.0
type AddGuildMember 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"` }
AddGuildMember ... 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 Application ¶ added in v0.31.0
type ApplicationCommand ¶ added in v0.30.0
type ApplicationCommand struct { ID Snowflake `json:"id"` Type ApplicationCommandType `json:"type"` ApplicationID Snowflake `json:"application_id"` GuildID Snowflake `json:"guild_id"` Name string `json:"name"` Description string `json:"description"` Options []*ApplicationCommandOption `json:"options"` DefaultPermission bool `json:"default_permission,omitempty"` }
type ApplicationCommandDataOption ¶ added in v0.30.0
type ApplicationCommandDataOption struct { Name string `json:"name"` Type OptionType `json:"type"` Value interface{} `json:"value"` Options []*ApplicationCommandDataOption `json:"options"` }
type ApplicationCommandFunctions ¶ added in v0.30.0
type ApplicationCommandFunctions interface { Delete(commandId Snowflake) error Create(command *CreateApplicationCommand) error Update(commandId Snowflake, command *UpdateApplicationCommand) error }
type ApplicationCommandInteractionData ¶ added in v0.27.0
type ApplicationCommandInteractionData struct { ID Snowflake `json:"id"` Name string `json:"name"` Resolved *ApplicationCommandInteractionDataResolved `json:"resolved"` Options []*ApplicationCommandDataOption `json:"options"` CustomID string `json:"custom_id"` Type ApplicationCommandType `json:"type"` Values []string `json:"values"` ComponentType MessageComponentType `json:"component_type"` TargetID Snowflake `json:"target_id"` Components []*MessageComponent `json:"components"` }
type ApplicationCommandInteractionDataResolved ¶ added in v0.27.0
type ApplicationCommandInteractionDataResolved struct { Users map[Snowflake]*User `json:"users"` Members map[Snowflake]*Member `json:"members"` Roles map[Snowflake]*Role `json:"roles"` Channels map[Snowflake]*Channel `json:"channels"` Messages map[Snowflake]*Message `json:"messages"` }
ApplicationCommandInteractionDataResolved https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure
type ApplicationCommandOption ¶ added in v0.30.0
type ApplicationCommandOption struct { Type OptionType `json:"type"` Name string `json:"name"` Description string `json:"description"` Required bool `json:"required"` Choices []*ApplicationCommandOptionChoice `json:"choices"` Options []*ApplicationCommandOption `json:"options"` ChannelTypes []ChannelType `json:"channel_types"` MinValue float64 `json:"min_value"` MaxValue float64 `json:"max_value"` Autocomplete bool `json:"autocomplete"` }
type ApplicationCommandOptionChoice ¶ added in v0.30.0
type ApplicationCommandOptionChoice struct { Name string `json:"name"` Value interface{} `json:"value"` }
type ApplicationCommandPermissionType ¶ added in v0.30.0
type ApplicationCommandPermissionType int
const ( ApplicationCommandPermissionRole ApplicationCommandPermissionType ApplicationCommandPermissionUser )
type ApplicationCommandPermissions ¶ added in v0.30.0
type ApplicationCommandPermissions struct { ID Snowflake `json:"id"` Type ApplicationCommandPermissionType `json:"type"` Permission bool `json:"permission"` }
type ApplicationCommandQueryBuilder ¶ added in v0.30.0
type ApplicationCommandQueryBuilder interface { WithContext(ctx context.Context) ApplicationCommandQueryBuilder Global() ApplicationCommandFunctions Guild(guildID Snowflake) ApplicationCommandFunctions }
type ApplicationCommandType ¶ added in v0.30.0
type ApplicationCommandType int
const ( ApplicationCommandChatInput ApplicationCommandType ApplicationCommandUser ApplicationCommandMessage )
type ArchivedThreads ¶ added in v0.30.0
type ArchivedThreads struct { Threads []*Channel `json:"threads"` Members []*ThreadMember `json:"members"` HasMore bool `json:"has_more"` }
ArchivedThreads https://discord.com/developers/docs/resources/channel#list-public-archived-threads-response-body
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 AutoArchiveDurationTime ¶ added in v0.30.0
type AutoArchiveDurationTime int
const ( AutoArchiveThreadMinute AutoArchiveDurationTime = 60 AutoArchiveThreadDay AutoArchiveDurationTime = 1440 // guild must be boosted to use the below auto archive durations. // ref: https://discord.com/developers/docs/resources/channel#start-thread-with-message-json-params AutoArchiveThreadThreeDays AutoArchiveDurationTime = 4320 AutoArchiveThreadWeek AutoArchiveDurationTime = 10080 )
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 BanMember ¶ added in v0.30.0
type BanMember 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 }
BanMember ... https://discord.com/developers/docs/resources/guild#create-guild-ban-query-string-params
func (*BanMember) FindErrors ¶ added in v0.30.0
func (*BanMember) URLQueryString ¶ added in v0.30.0
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 *GetMessages) ([]*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 *GetMembers) ([]*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 *GetCurrentUserGuilds) (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 *GetCurrentUserGuilds) ([]*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 *GetMembers) ([]*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 *GetMessages) ([]*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) GuildScheduledEventCreate ¶ added in v0.30.0
func (c *CacheNop) GuildScheduledEventCreate(data []byte) (evt *GuildScheduledEventCreate, err error)
func (*CacheNop) GuildScheduledEventDelete ¶ added in v0.30.0
func (c *CacheNop) GuildScheduledEventDelete(data []byte) (evt *GuildScheduledEventDelete, err error)
func (*CacheNop) GuildScheduledEventUpdate ¶ added in v0.30.0
func (c *CacheNop) GuildScheduledEventUpdate(data []byte) (evt *GuildScheduledEventUpdate, err error)
func (*CacheNop) GuildScheduledEventUserAdd ¶ added in v0.30.0
func (c *CacheNop) GuildScheduledEventUserAdd(data []byte) (evt *GuildScheduledEventUserAdd, err error)
func (*CacheNop) GuildScheduledEventUserRemove ¶ added in v0.30.0
func (c *CacheNop) GuildScheduledEventUserRemove(data []byte) (evt *GuildScheduledEventUserRemove, err error)
func (*CacheNop) GuildStickersUpdate ¶ added in v0.30.0
func (c *CacheNop) GuildStickersUpdate(data []byte) (evt *GuildStickersUpdate, 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) ThreadCreate ¶ added in v0.30.0
func (c *CacheNop) ThreadCreate(data []byte) (evt *ThreadCreate, err error)
func (*CacheNop) ThreadDelete ¶ added in v0.30.0
func (c *CacheNop) ThreadDelete(data []byte) (evt *ThreadDelete, err error)
func (*CacheNop) ThreadListSync ¶ added in v0.30.0
func (c *CacheNop) ThreadListSync(data []byte) (evt *ThreadListSync, err error)
func (*CacheNop) ThreadMemberUpdate ¶ added in v0.30.0
func (c *CacheNop) ThreadMemberUpdate(data []byte) (evt *ThreadMemberUpdate, err error)
func (*CacheNop) ThreadMembersUpdate ¶ added in v0.30.0
func (c *CacheNop) ThreadMembersUpdate(data []byte) (evt *ThreadMembersUpdate, err error)
func (*CacheNop) ThreadUpdate ¶ added in v0.30.0
func (c *CacheNop) ThreadUpdate(data []byte) (evt *ThreadUpdate, 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) GuildScheduledEventCreate(data []byte) (*GuildScheduledEventCreate, error) GuildScheduledEventDelete(data []byte) (*GuildScheduledEventDelete, error) GuildScheduledEventUpdate(data []byte) (*GuildScheduledEventUpdate, error) GuildScheduledEventUserAdd(data []byte) (*GuildScheduledEventUserAdd, error) GuildScheduledEventUserRemove(data []byte) (*GuildScheduledEventUserRemove, error) GuildStickersUpdate(data []byte) (*GuildStickersUpdate, 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) ThreadCreate(data []byte) (*ThreadCreate, error) ThreadDelete(data []byte) (*ThreadDelete, error) ThreadListSync(data []byte) (*ThreadListSync, error) ThreadMemberUpdate(data []byte) (*ThreadMemberUpdate, error) ThreadMembersUpdate(data []byte) (*ThreadMembersUpdate, error) ThreadUpdate(data []byte) (*ThreadUpdate, 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"` MessageCount int `json:"message_count,omitempty"` //threads only. stops counting at 50 MemberCount int `json:"member_count,omitempty"` //threads only. stops counting at 50 ThreadMetadata ThreadMetadata `json:"thread_metadata,omitempty"` //threads only Member ThreadMember `json:"member,omitempty"` //threads only DefaultAutoArchiveDuration int `json:"default_auto_archive_duration,omitempty"` //threads only }
Channel ...
func (*Channel) GetPermissions ¶ added in v0.18.0
func (c *Channel) GetPermissions(ctx context.Context, s GuildQueryBuilderCaller, member *Member) (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 (c *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 WithFlags(flags ...Flag) 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() error // Get Get a channel by Snowflake. Returns a channel object. Get() (*Channel, error) // 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. Update(params *UpdateChannel) (*Channel, error) // 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() (*Channel, error) // UpdatePermissions 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 *UpdateChannelPermissions) error // GetInvites Returns a list of invite objects (with invite metadata) for the channel. Only usable for // guild Channels. Requires the 'MANAGE_CHANNELS' permission. GetInvites() ([]*Invite, error) // CreateInvite 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(params *CreateInvite) (*Invite, error) // DeletePermission 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) error // AddDMParticipant Adds a recipient to a Group DM using their access token. Returns a 204 empty response // on success. AddDMParticipant(participant *GroupDMParticipant) error // KickParticipant Removes a recipient from a Group DM. Returns a 204 empty response on success. KickParticipant(userID Snowflake) error // GetPinnedMessages Returns all pinned messages in the channel as an array of message objects. GetPinnedMessages() ([]*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 *DeleteMessages) 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 *GetMessages) ([]*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 *CreateMessage) (*Message, error) // CreateWebhook Create a new webhook. Requires the 'MANAGE_WEBHOOKS' permission. // Returns a webhook object on success. CreateWebhook(params *CreateWebhook) (ret *Webhook, err error) // GetWebhooks Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. GetWebhooks() (ret []*Webhook, err error) Message(id Snowflake) MessageQueryBuilder // CreateThread Create a thread that is not connected to an existing message. CreateThread(params *CreateThreadWithoutMessage) (*Channel, error) // JoinThread Adds the current user to a thread. Also requires the thread is not archived. // Returns a 204 empty response on success. JoinThread() error // AddThreadMember Adds another member to a thread. Requires the ability to send messages in the thread. // Also requires the thread is not archived. Returns a 204 empty response if the member // is successfully added or was already a member of the thread. AddThreadMember(userID Snowflake) error // LeaveThread Removes the current user from a thread. Also requires the thread is not archived. // Returns a 204 empty response on success. LeaveThread() error // RemoveThreadMember Removes another member from a thread. Requires the MANAGE_THREADS permission, or the // creator of the thread if it is a GUILD_PRIVATE_THREAD. Also requires the thread is not archived. // Returns a 204 empty response on success. RemoveThreadMember(userID Snowflake) error // GetThreadMember Returns a thread member object for the specified user if // they are a member of the thread, returns a 404 response otherwise. GetThreadMember(userID Snowflake) (*ThreadMember, error) // GetThreadMembers Returns array of thread members objects that are members of the thread. // This endpoint is restricted according to whether the GUILD_MEMBERS Privileged Intent is enabled for your application. GetThreadMembers() ([]*ThreadMember, error) // GetPublicArchivedThreads Returns archived threads in the channel that are public. When called on a GUILD_TEXT channel, returns // threads of type GUILD_PUBLIC_THREAD. When called on a GUILD_NEWS channel returns threads of type // GUILD_NEWS_THREAD. Threads are ordered by archive_timestamp, in descending order. Requires the READ_MESSAGE_HISTORY // permission. GetPublicArchivedThreads(params *GetArchivedThreads) (*ArchivedThreads, error) // GetPrivateArchivedThreads Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD. Threads are ordered by // archive_timestamp, in descending order. Requires both the READ_MESSAGE_HISTORY and MANAGE_THREADS permissions. GetPrivateArchivedThreads(params *GetArchivedThreads) (*ArchivedThreads, error) // GetJoinedPrivateArchivedThreads Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined. // Threads are ordered by their id, in descending order. Requires the READ_MESSAGE_HISTORY permission. GetJoinedPrivateArchivedThreads(params *GetArchivedThreads) (*ArchivedThreads, error) }
ChannelQueryBuilder REST interface for all Channel endpoints
type ChannelType ¶ added in v0.25.0
type ChannelType uint
ChannelType https://discord.com/developers/docs/resources/channel#channel-object-channel-types
const ( ChannelTypeGuildText ChannelType = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory ChannelTypeGuildNews ChannelTypeGuildStore ChannelTypeGuildNewsThread ChannelTypeGuildPublicThread // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those // invited and those with the MANAGE_THREADS permission ChannelTypeGuildPrivateThread )
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) ApplicationCommand ¶ added in v0.30.0
func (c Client) ApplicationCommand(id Snowflake) ApplicationCommandQueryBuilder
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
func (c Client) BotAuthorizeURL(permissions PermissionBit, scopes []string) (*url.URL, error)
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.
Use 0 if you do not want to specify any required permissions.
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 *CreateGuild) (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
CurrentUser is used to create a guild query builder.
func (*Client) EditInteractionResponse ¶ added in v0.27.0
func (c *Client) EditInteractionResponse(ctx context.Context, interaction *InteractionCreate, message *UpdateMessage) error
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) GetVoiceRegions ¶
func (c Client) GetVoiceRegions() (regions []*VoiceRegion, err error)
GetVoiceRegions [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) RESTRatelimitBuckets ¶ added in v0.16.5
RESTRatelimitBuckets 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 *CreateInteractionResponse) 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 MessageCreate. 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
User 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
func (Client) WithContextAndFlags ¶ added in v0.29.0
func (c Client) WithContextAndFlags(ctx context.Context, flags ...Flag) ClientQueryBuilderExecutables
func (Client) WithFlags ¶ added in v0.29.0
func (c Client) WithFlags(flags ...Flag) ClientQueryBuilderExecutables
type ClientQueryBuilder ¶ added in v0.19.0
type ClientQueryBuilder interface { WithContext(ctx context.Context) ClientQueryBuilderExecutables WithFlags(flags ...Flag) ClientQueryBuilderExecutables ClientQueryBuilderExecutables Invite(code string) InviteQueryBuilder Channel(cid Snowflake) ChannelQueryBuilder User(uid Snowflake) UserQueryBuilder CurrentUser() CurrentUserQueryBuilder Guild(id Snowflake) GuildQueryBuilder Gateway() GatewayQueryBuilder ApplicationCommand(appID Snowflake) ApplicationCommandQueryBuilder }
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 *CreateGuild) (*Guild, error) // GetVoiceRegions Returns an array of voice region objects that can be used when creating servers. GetVoiceRegions() ([]*VoiceRegion, error) BotAuthorizeURL(permissions PermissionBit, scopes []string) (*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 // Intents can be specified to reduce traffic sent from the discord gateway. // Intents = IntentDirectMessages | IntentGuildMessages Intents 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 // Deprecated: use Intents RejectEvents []string // Deprecated: use Intents DMIntents Intent // 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 CreateApplicationCommand ¶ added in v0.31.0
type CreateApplicationCommand struct { Name string `json:"name"` Description string `json:"description"` Type ApplicationCommandType `json:"type,omitempty"` Options []*ApplicationCommandOption `json:"options,omitempty"` DefaultPermission bool `json:"default_permission,omitempty"` }
type CreateGroupDM ¶ added in v0.6.0
type CreateGroupDM 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"` }
CreateGroupDM required JSON params for func CreateGroupDM https://discord.com/developers/docs/resources/user#create-group-dm
type CreateGuild ¶ added in v0.6.0
type CreateGuild 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"` }
CreateGuild ... https://discord.com/developers/docs/resources/guild#create-guild-json-params example partial channel object:
{ "name": "naming-things-is-hard", "type": 0 }
type CreateGuildChannel ¶ added in v0.6.0
type CreateGuildChannel 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:"-"` }
CreateGuildChannel https://discord.com/developers/docs/resources/guild#create-guild-channel-json-params
type CreateGuildEmoji ¶ added in v0.6.0
type CreateGuildEmoji 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:"-"` }
CreateGuildEmoji JSON params for func CreateGuildEmoji
type CreateGuildIntegration ¶ added in v0.6.0
CreateGuildIntegration ... https://discord.com/developers/docs/resources/guild#create-guild-integration-json-params
type CreateGuildRole ¶ added in v0.6.0
type CreateGuildRole struct { Name string `json:"name,omitempty"` Permissions PermissionBit `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:"-"` }
CreateGuildRole ... https://discord.com/developers/docs/resources/guild#create-guild-role-json-params
type CreateInteractionResponse ¶ added in v0.34.0
type CreateInteractionResponse struct { Type InteractionCallbackType `json:"type"` Data *CreateInteractionResponseData `json:"data"` }
type CreateInteractionResponseData ¶ added in v0.34.0
type CreateInteractionResponseData struct { Content string `json:"content"` Title string `json:"title"` CustomID string `json:"custom_id"` Tts bool `json:"tts,omitempty"` Embeds []*Embed `json:"embeds,omitempty"` Components []*MessageComponent `json:"components"` Attachments []*Attachment `json:"attachments"` AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` Flags MessageFlag `json:"flags,omitempty"` // Only SUPPRESS_EMBEDS and EPHEMERAL flags allowed. Files []CreateMessageFile `json:"-"` SpoilerTagContent bool `json:"-"` SpoilerTagAllAttachments bool `json:"-"` }
type CreateInvite ¶ added in v0.30.0
type CreateInvite struct { MaxAge int `json:"max_age"` MaxUses int `json:"max_uses,omitempty"` Temporary bool `json:"temporary,omitempty"` Unique bool `json:"unique,omitempty"` TargetType int `json:"target_type,omitempty"` TargetUserID Snowflake `json:"target_user_id,omitempty"` TargetApplicationID Snowflake `json:"target_application_id,omitempty"` AuditLogReason string `json:"-"` }
type CreateMessage ¶ added in v0.9.3
type CreateMessage struct { Content string `json:"content"` Nonce string `json:"nonce,omitempty"` // THIS IS A STRING. NOT A SNOWFLAKE! DONT TOUCH! Tts bool `json:"tts,omitempty"` Embeds []*Embed `json:"embeds,omitempty"` Components []*MessageComponent `json:"components"` Files []CreateMessageFile `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"` // Deprecated: use Embeds Embed *Embed `json:"embed,omitempty"` }
CreateMessage JSON params for CreateChannelMessage
type CreateMessageFile ¶ added in v0.30.0
type CreateMessageFile 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:"-"` }
CreateMessageFile contains the information needed to upload a file to Discord, it is part of the CreateMessage struct.
type CreateScheduledEvent ¶ added in v0.35.0
type CreateScheduledEvent struct { ChannelID Snowflake `json:"channel_id"` // optional if EntityType is EXTERNAL EntityMetadata ScheduledEventEntityMetadata `json:"entity_metadata"` Name string `json:"name,omitempty"` PrivacyLevel GuildScheduledEventPrivacyLevel `json:"privacy_level"` ScheduledStartTime Time `json:"scheduled_start_time"` ScheduledEndTime Time `json:"scheduled_end_time,omitempty"` Description string `json:"description,omitempty"` EntityType GuildScheduledEventEntityTypes `json:"entity_type"` AuditLogReason string `json:"-"` }
CreateScheduledEvent ... https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event-json-params
type CreateThread ¶ added in v0.30.0
type CreateThread struct { Name string `json:"name"` AutoArchiveDuration AutoArchiveDurationTime `json:"auto_archive_duration,omitempty"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` // AuditLogReason is an X-Audit-Log-Reason header field that will show up on the audit log for this action. AuditLogReason string `json:"-"` // Deprecated: use AuditLogReason Reason string `json:"-"` }
CreateThread https://discord.com/developers/docs/resources/channel#start-thread-with-message-json-params
type CreateThreadWithoutMessage ¶ added in v0.30.0
type CreateThreadWithoutMessage struct { Name string `json:"name"` AutoArchiveDuration AutoArchiveDurationTime `json:"auto_archive_duration,omitempty"` // In API v9, type defaults to PRIVATE_THREAD in order to match the behavior when // thread documentation was first published. In API v10 this will be changed to be a required field, with no default. Type ChannelType `json:"type,omitempty"` Invitable bool `json:"invitable,omitempty"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` // AuditLogReason is an X-Audit-Log-Reason header field that will show up on the audit log for this action. AuditLogReason string `json:"-"` // Deprecated: use AuditLogReason Reason string `json:"-"` }
CreateThreadWithoutMessage https://discord.com/developers/docs/resources/channel#start-thread-without-message-json-params
type CreateWebhook ¶ added in v0.6.0
type CreateWebhook 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:"-"` }
CreateWebhook json params for the create webhook rest request avatar string https://discord.com/developers/docs/resources/user#avatar-data
func (*CreateWebhook) FindErrors ¶ added in v0.30.0
func (c *CreateWebhook) 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 WithFlags(flags ...Flag) CurrentUserQueryBuilder // Get 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() (*User, error) // GetGuilds Returns a list of partial guild objects the current user is a member of. // Requires the Guilds OAuth2 scope. GetGuilds(params *GetCurrentUserGuilds) (ret []*Guild, err error) Update(params *UpdateUser) (*User, 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 *CreateGroupDM) (ret *Channel, err error) // GetConnections Returns a list of connection objects. Requires the connections OAuth2 scope. GetConnections() (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 DeleteMessages ¶ added in v0.30.0
type DeleteMessages struct { Messages []Snowflake `json:"messages"` // contains filtered or unexported fields }
DeleteMessages https://discord.com/developers/docs/resources/channel#bulk-delete-messages-json-params
func (*DeleteMessages) AddMessage ¶ added in v0.30.0
func (p *DeleteMessages) AddMessage(msg *Message) (err error)
AddMessage Adds a message to be deleted
func (*DeleteMessages) Valid ¶ added in v0.30.0
func (p *DeleteMessages) Valid() (err error)
Valid validates the DeleteMessages 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 Err ¶ added in v0.12.2
type Err = disgorderr.Err
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 ExecuteWebhook ¶ added in v0.6.0
type ExecuteWebhook 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"` }
ExecuteWebhook 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 GatewayCmdName ¶ added in v0.29.0
type GatewayCmdName string
GatewayCmdName is the gateway command name for the payload to be sent to Discord over a websocket connection.
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 )
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 GetArchivedThreads ¶ added in v0.30.0
type GetArchivedThreads struct { Before Time `urlparam:"before,omitempty"` Limit int `urlparam:"limit,omitempty"` }
GetArchivedThreads https://discord.com/developers/docs/resources/channel#list-public-archived-threads-query-string-params
func (*GetArchivedThreads) URLQueryString ¶ added in v0.30.0
func (g *GetArchivedThreads) URLQueryString() string
type GetAuditLogs ¶ added in v0.30.0
type GetAuditLogs struct { UserID Snowflake `urlparam:"user_id"` ActionType int `urlparam:"action_type"` Before Snowflake `urlparam:"before,omitempty"` Limit int `urlparam:"limit,omitempty"` }
func (*GetAuditLogs) URLQueryString ¶ added in v0.30.0
func (g *GetAuditLogs) URLQueryString() string
type GetCurrentUserGuilds ¶ added in v0.6.0
type GetCurrentUserGuilds struct { Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit int `urlparam:"limit,omitempty"` }
GetCurrentUserGuilds JSON params for func GetCurrentUserGuilds
func (*GetCurrentUserGuilds) URLQueryString ¶ added in v0.30.0
func (g *GetCurrentUserGuilds) URLQueryString() string
type GetMembers ¶ added in v0.30.0
type GetMembers struct { After Snowflake `urlparam:"after,omitempty"` Limit uint32 `urlparam:"limit,omitempty"` // 0 will fetch everyone }
GetMembers 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 GetMessages ¶ added in v0.9.3
type GetMessages struct { Around Snowflake `urlparam:"around,omitempty"` Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` Limit uint `urlparam:"limit,omitempty"` }
GetMessages https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params TODO: ensure limits
func (*GetMessages) URLQueryString ¶ added in v0.30.0
func (g *GetMessages) URLQueryString() string
func (*GetMessages) Validate ¶ added in v0.30.0
func (g *GetMessages) Validate() error
type GetPruneMembersCount ¶ added in v0.30.0
type GetReactionURL ¶ added in v0.30.0
type GetReactionURL 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) }
GetReactionURL https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params
func (*GetReactionURL) URLQueryString ¶ added in v0.30.0
func (g *GetReactionURL) URLQueryString() string
type GetScheduledEvent ¶ added in v0.35.0
type GetScheduledEvent struct {
WithUserCount bool `urlparam:"with_user_count,omitempty"`
}
func (*GetScheduledEvent) FindErrors ¶ added in v0.35.0
func (gse *GetScheduledEvent) FindErrors() error
func (*GetScheduledEvent) URLQueryString ¶ added in v0.35.0
func (g *GetScheduledEvent) URLQueryString() string
type GetScheduledEventMembers ¶ added in v0.35.0
type GetScheduledEventMembers struct { Limit uint32 `urlparam:"limit,omitempty"` WithMember bool `urlparam:"with_member,omitempty"` Before Snowflake `urlparam:"before,omitempty"` After Snowflake `urlparam:"after,omitempty"` }
func (*GetScheduledEventMembers) FindErrors ¶ added in v0.35.0
func (gse *GetScheduledEventMembers) FindErrors() error
func (*GetScheduledEventMembers) URLQueryString ¶ added in v0.35.0
func (g *GetScheduledEventMembers) URLQueryString() string
type GetScheduledEvents ¶ added in v0.35.0
type GetScheduledEvents struct {
WithUserCount bool `urlparam:"with_user_count,omitempty"`
}
func (*GetScheduledEvents) FindErrors ¶ added in v0.35.0
func (gse *GetScheduledEvents) FindErrors() error
func (*GetScheduledEvents) URLQueryString ¶ added in v0.35.0
func (g *GetScheduledEvents) URLQueryString() string
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 Will skip checking username of members missing user data. The user data might be missing due to cache misses.
func (*Guild) RoleByName ¶ added in v0.6.0
RoleByName retrieves a slice of roles with same name
type GuildApplicationCommandPermissions ¶ added in v0.30.0
type GuildApplicationCommandPermissions struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` GuildID Snowflake `json:"guild_id"` Permissions []*ApplicationCommandPermissions `json:"permissions"` }
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
type GuildCreate struct { Guild *Guild `json:"guild"` Threads []*Channel `json:"threads"` //https://discord.com/developers/docs/topics/threads#gateway-events ShardID uint `json:"-"` }
GuildCreate This event can be sent in three different scenarios:
- When a user is initially connecting, to lazily load and backfill information for all unavailable Guilds sent in the Ready event.
- When a Guild becomes available again to the Client.
- When the current user joins a new Guild.
func (*GuildCreate) UnmarshalJSON ¶ added in v0.8.0
func (obj *GuildCreate) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type 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 GuildEmojiQueryBuilder ¶ added in v0.19.0
type GuildEmojiQueryBuilder interface { WithContext(ctx context.Context) GuildEmojiQueryBuilder WithFlags(flags ...Flag) GuildEmojiQueryBuilder Get() (*Emoji, error) Update(params *UpdateEmoji) (*Emoji, error) Delete() error }
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 WithFlags(flags ...Flag) GuildMemberQueryBuilder Get() (*Member, error) Update(params *UpdateMember) (*Member, error) AddRole(roleID Snowflake) error RemoveRole(roleID Snowflake) error Kick(reason string) error Ban(params *BanMember) error GetPermissions() (PermissionBit, error) }
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 WithFlags(flags ...Flag) GuildQueryBuilder // Get // TODO: Add more guild attribute things. Waiting for caching changes before then. Get() (guild *Guild, err error) Update(params *UpdateGuild) (*Guild, error) Delete() error // Leave leaves the given guild Leave() error // GetChannels // 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() ([]*Channel, error) // GetMembers // 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 *GetMembers) ([]*Member, error) CreateChannel(name string, params *CreateGuildChannel) (*Channel, error) UpdateChannelPositions(params []UpdateGuildChannelPositions) error CreateMember(userID Snowflake, accessToken string, params *AddGuildMember) (*Member, error) Member(userID Snowflake) GuildMemberQueryBuilder DisconnectVoiceParticipant(userID Snowflake) error SetCurrentUserNick(nick string) (newNick string, err error) GetBans() ([]*Ban, error) GetBan(userID Snowflake) (*Ban, error) UnbanUser(userID Snowflake, reason string) error // GetRoles // 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. GetRoles() ([]*Role, error) UpdateRolePositions(params []UpdateGuildRolePositions) ([]*Role, error) CreateRole(params *CreateGuildRole) (*Role, error) Role(roleID Snowflake) GuildRoleQueryBuilder GetPruneMembersCount(params *GetPruneMembersCount) (estimate int, err error) PruneMembers(params *PruneMembers) (pruned int, err error) GetVoiceRegions() ([]*VoiceRegion, error) GetInvites() ([]*Invite, error) GetIntegrations() ([]*Integration, error) CreateIntegration(params *CreateGuildIntegration) error UpdateIntegration(integrationID Snowflake, params *UpdateGuildIntegration) error DeleteIntegration(integrationID Snowflake) error SyncIntegration(integrationID Snowflake) error GetWidget() (*GuildWidget, error) UpdateWidget(params *UpdateGuildWidget) (*GuildWidget, error) GetVanityURL() (*PartialInvite, error) GetAuditLogs(logs *GetAuditLogs) (*AuditLog, error) VoiceChannel(channelID Snowflake) VoiceChannelQueryBuilder // GetEmojis // 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() ([]*Emoji, error) CreateEmoji(params *CreateGuildEmoji) (*Emoji, error) Emoji(emojiID Snowflake) GuildEmojiQueryBuilder GetWebhooks() (ret []*Webhook, err error) // GetActiveThreads Returns all active threads in the guild, including public and private threads. Threads are ordered // by their id, in descending order. GetActiveThreads() (*ActiveGuildThreads, error) // Guild Scheduled Event ScheduledEvent(eventID Snowflake) GuildScheduledEventQueryBuilder GetScheduledEvents(params *GetScheduledEvents) ([]*GuildScheduledEvent, error) CreateScheduledEvent(params *CreateScheduledEvent) (*GuildScheduledEvent, 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 WithFlags(flags ...Flag) GuildRoleQueryBuilder Update(params *UpdateRole) (*Role, error) Delete() error Get() (*Role, error) }
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 GuildScheduledEvent ¶ added in v0.30.0
type GuildScheduledEvent struct { ID Snowflake `json:"id"` GuildID Snowflake `json:"guild_id"` ChannelID Snowflake `json:"channel_id"` CreatorID Snowflake `json:"creator_id"` Name string `json:"name"` Description string `json:"description"` ScheduledStartTime Time `json:"scheduled_start_time"` ScheduledEndTime Time `json:"scheduled_end_time"` PrivacyLevel int `json:"privacy_level"` EventStatus int `json:"event_status"` EntityType int `json:"entity_type"` EntityMetadata interface{} `json:"entity_metadata"` Creator *User `json:"creator"` UserCount int `json:"user_count"` }
type GuildScheduledEventCreate ¶ added in v0.30.0
type GuildScheduledEventCreate struct { GuildScheduledEvent ShardID uint `json:"-"` }
type GuildScheduledEventDelete ¶ added in v0.30.0
type GuildScheduledEventDelete struct { GuildScheduledEvent ShardID uint `json:"-"` }
type GuildScheduledEventEntityTypes ¶ added in v0.35.0
type GuildScheduledEventEntityTypes uint
GuildScheduledEventEntityTypes ... https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types
const ( GuildScheduledEventEntityTypesStageInstance GuildScheduledEventEntityTypes = iota + 1 GuildScheduledEventEntityTypesVoice GuildScheduledEventEntityTypesExternal )
the different scheduled event entity types
type GuildScheduledEventPrivacyLevel ¶ added in v0.35.0
type GuildScheduledEventPrivacyLevel uint
GuildScheduledEventPrivacyLevel ... https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level
const (
GuildScheduledEventPrivacyLevelGuildOnly GuildScheduledEventPrivacyLevel = iota + 2
)
the different scheduled event privacy level
type GuildScheduledEventQueryBuilder ¶ added in v0.35.0
type GuildScheduledEventQueryBuilder interface { WithContext(ctx context.Context) GuildScheduledEventQueryBuilder WithFlags(flags ...Flag) GuildScheduledEventQueryBuilder Get(params *GetScheduledEvent) (*GuildScheduledEvent, error) Update(params *UpdateScheduledEvent) (*GuildScheduledEvent, error) Delete() error GetMembers(params *GetScheduledEventMembers) ([]*GuildScheduledEventUsers, error) }
type GuildScheduledEventStatus ¶ added in v0.35.0
type GuildScheduledEventStatus uint
const ( GuildScheduledEventStatusScheduled GuildScheduledEventStatus = iota + 1 GuildScheduledEventStatusActive GuildScheduledEventStatusCompleted GuildScheduledEventStatusCancelled )
type GuildScheduledEventUpdate ¶ added in v0.30.0
type GuildScheduledEventUpdate struct { GuildScheduledEvent ShardID uint `json:"-"` }
type GuildScheduledEventUserAdd ¶ added in v0.30.0
type GuildScheduledEventUserRemove ¶ added in v0.30.0
type GuildScheduledEventUsers ¶ added in v0.35.0
type GuildStickersUpdate ¶ added in v0.30.0
type GuildStickersUpdate struct { GuildID Snowflake `json:"guild_id"` Stickers []*MessageSticker `json:"stickers"` ShardID uint `json:"-"` }
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 GuildWidget ¶ added in v0.30.0
GuildEmbed https://discord.com/developers/docs/resources/guild#guild-embed-object
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 HandlerGuildScheduledEventCreate ¶ added in v0.30.0
type HandlerGuildScheduledEventCreate = func(s Session, h *GuildScheduledEventCreate)
HandlerGuildScheduledEventCreate is triggered by GuildScheduledEventCreate events
type HandlerGuildScheduledEventDelete ¶ added in v0.30.0
type HandlerGuildScheduledEventDelete = func(s Session, h *GuildScheduledEventDelete)
HandlerGuildScheduledEventDelete is triggered by GuildScheduledEventDelete events
type HandlerGuildScheduledEventUpdate ¶ added in v0.30.0
type HandlerGuildScheduledEventUpdate = func(s Session, h *GuildScheduledEventUpdate)
HandlerGuildScheduledEventUpdate is triggered by GuildScheduledEventUpdate events
type HandlerGuildScheduledEventUserAdd ¶ added in v0.30.0
type HandlerGuildScheduledEventUserAdd = func(s Session, h *GuildScheduledEventUserAdd)
HandlerGuildScheduledEventUserAdd is triggered by GuildScheduledEventUserAdd events
type HandlerGuildScheduledEventUserRemove ¶ added in v0.30.0
type HandlerGuildScheduledEventUserRemove = func(s Session, h *GuildScheduledEventUserRemove)
HandlerGuildScheduledEventUserRemove is triggered by GuildScheduledEventUserRemove events
type HandlerGuildStickersUpdate ¶ added in v0.30.0
type HandlerGuildStickersUpdate = func(s Session, h *GuildStickersUpdate)
HandlerGuildStickersUpdate is triggered by GuildStickersUpdate 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 HandlerThreadCreate ¶ added in v0.30.0
type HandlerThreadCreate = func(s Session, h *ThreadCreate)
HandlerThreadCreate is triggered by ThreadCreate events
type HandlerThreadDelete ¶ added in v0.30.0
type HandlerThreadDelete = func(s Session, h *ThreadDelete)
HandlerThreadDelete is triggered by ThreadDelete events
type HandlerThreadListSync ¶ added in v0.30.0
type HandlerThreadListSync = func(s Session, h *ThreadListSync)
HandlerThreadListSync is triggered by ThreadListSync events
type HandlerThreadMemberUpdate ¶ added in v0.30.0
type HandlerThreadMemberUpdate = func(s Session, h *ThreadMemberUpdate)
HandlerThreadMemberUpdate is triggered by ThreadMemberUpdate events
type HandlerThreadMembersUpdate ¶ added in v0.30.0
type HandlerThreadMembersUpdate = func(s Session, h *ThreadMembersUpdate)
HandlerThreadMembersUpdate is triggered by ThreadMembersUpdate events
type HandlerThreadUpdate ¶ added in v0.30.0
type HandlerThreadUpdate = func(s Session, h *ThreadUpdate)
HandlerThreadUpdate is triggered by ThreadUpdate events
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 InteractionCallbackType ¶ added in v0.27.0
type InteractionCallbackType = int
const ( InteractionCallbackPong InteractionCallbackType InteractionCallbackChannelMessageWithSource InteractionCallbackDeferredChannelMessageWithSource InteractionCallbackDeferredUpdateMessage InteractionCallbackUpdateMessage InteractionCallbackApplicationCommandAutocompleteResult InteractionCallbackModal )
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"` Locale string `json:"locale"` GuildLocale string `json:"guild_locale"` ShardID uint `json:"-"` }
func (*InteractionCreate) Edit ¶ added in v0.34.0
func (itc *InteractionCreate) Edit(ctx context.Context, session Session, response *UpdateMessage) error
func (*InteractionCreate) Reply ¶ added in v0.34.0
func (itc *InteractionCreate) Reply(ctx context.Context, session Session, response *CreateInteractionResponse) error
type InteractionType ¶ added in v0.27.0
type InteractionType = int
const ( InteractionPing InteractionType InteractionApplicationCommand InteractionMessageComponent InteractionApplicationCommandAutocomplete InteractionModalSubmit )
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 WithFlags(flags ...Flag) InviteQueryBuilder // Get Returns an invite object for the given code. Get(withMemberCount bool) (*Invite, error) // Delete an invite. Requires the MANAGE_CHANNELS permission. Returns an invite object on success. Delete() (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"` CommunicationDisabledUntil Time `json:"communication_disabled_until"` 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) (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"` 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 int `json:"style"` Label string `json:"label"` Emoji *Emoji `json:"emoji"` CustomID string `json:"custom_id"` Url string `json:"url,omitempty"` Disabled bool `json:"disabled"` Components []*MessageComponent `json:"components,omitempty"` Options []*SelectMenuOption `json:"options,omitempty"` Placeholder string `json:"placeholder"` MinValues int `json:"min_values"` MaxValues int `json:"max_values"` Required bool `json:"required"` Value string `json:"value,omitempty"` }
type MessageComponentType ¶ added in v0.27.0
type MessageComponentType = int
const ( MessageComponentActionRow MessageComponentType MessageComponentButton MessageComponentSelectMenu MessageComponentTextInput )
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 MessageFlagHasThread MessageFlagEphemeral MessageFlagLoading )
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 WithFlags(flags ...Flag) MessageQueryBuilder // Pin Pin a message by its ID and channel ID. Requires the 'MANAGE_MESSAGES' permission. Pin() error // Unpin Delete a pinned message in a channel. Requires the 'MANAGE_MESSAGES' permission. Unpin() error // Get 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() (*Message, error) // Update 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. Update(params *UpdateMessage) (*Message, error) // Delete deletes 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() error CreateThread(params *CreateThread) (*Channel, error) CrossPost() (*Message, error) // DeleteAllReactions Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' // permission to be present on the current user. DeleteAllReactions() 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.
MessageType 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 MessageTypeThreadCreated MessageTypeReply MessageTypeApplicationCommand MessageTypeThreadStarterMessage )
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 ( OptionTypeSubCommand OptionType OptionTypeSubCommandGroup OptionTypeString OptionTypeInteger OptionTypeBoolean OptionTypeUser OptionTypeChannel OptionTypeRole OptionTypeMentionable OptionTypeNumber )
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) PermissionVoiceStream )
Constants for the different bit offsets of voice permissions
const ( PermissionChangeNickname PermissionBit = 1 << (iota + 26) PermissionManageNicknames PermissionManageRoles PermissionManageWebhooks PermissionManageEmojis PermissionManageEvents PermissionManageThreads PermissionCreatePublicThreads PermissionCreatePrivateThreads PermissionUseExternalStickers PermissionSendMessagesInThreads PermissionUseEmbeddedActivites // This is technically called MODERATE_MEMBERS in the docs, but I think that would make it confusing, as managing roles // and banning and stuff could also be moderating PermissionTimeoutMembers )
Constants for general management.
const ( PermissionUseSlashCommands PermissionBit = 2147483648 // Down here cause according to discord docs: "(This permission is under active development and may be changed or removed.)" PermissionRequestToSpeak PermissionBit = 1 << 32 )
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 PruneMembers ¶ added in v0.30.0
type PruneMembers struct { Days *int `json:"days,omitempty"` ComputePruneCount *bool `json:"compute_prune_count,omitempty"` IncludeRoles []Snowflake `json:"include_roles,omitempty"` AuditLogReason string `json:"-"` }
PruneMembers https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params
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 WithFlags(flags ...Flag) ReactionQueryBuilder // Create 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() (err error) // Get Get a list of Users that reacted with this emoji. Returns an array of user objects on success. Get(params URLQueryStringer) (reactors []*User, err error) // DeleteOwn Delete a reaction the current user has made for the message. // Returns a 204 empty response on success. DeleteOwn() (err error) // DeleteUser 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) (err error) }
type Ready ¶ added in v0.6.0
type Ready struct { APIVersion int `json:"v"` User *User `json:"user"` Guilds []*GuildUnavailable `json:"guilds"` Application Application `json:"application"` // 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 ScheduledEventEntityMetadata ¶ added in v0.35.0
type ScheduledEventEntityMetadata struct {
Location string `json:"location,omitempty"` // required if EntityType is EXTERNAL
}
ScheduledEventEntityMetadata ... https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-metadata
type SelectMenuOption ¶ added in v0.31.0
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 // AvgHeartbeatLatency 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) // HeartbeatLatencies returns the latency for each given shard id. shardID => latency HeartbeatLatencies() (latencies map[uint]time.Duration, err error) RESTRatelimitBuckets() (group map[string][]string) Pool() *pools ClientQueryBuilder EditInteractionResponse(ctx context.Context, interaction *InteractionCreate, message *UpdateMessage) error SendInteractionResponse(context context.Context, interaction *InteractionCreate, data *CreateInteractionResponse) error 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) GuildScheduledEventCreate(handler HandlerGuildScheduledEventCreate, moreHandlers ...HandlerGuildScheduledEventCreate) GuildScheduledEventCreateChan(handler chan *GuildScheduledEventCreate, moreHandlers ...chan *GuildScheduledEventCreate) GuildScheduledEventDelete(handler HandlerGuildScheduledEventDelete, moreHandlers ...HandlerGuildScheduledEventDelete) GuildScheduledEventDeleteChan(handler chan *GuildScheduledEventDelete, moreHandlers ...chan *GuildScheduledEventDelete) GuildScheduledEventUpdate(handler HandlerGuildScheduledEventUpdate, moreHandlers ...HandlerGuildScheduledEventUpdate) GuildScheduledEventUpdateChan(handler chan *GuildScheduledEventUpdate, moreHandlers ...chan *GuildScheduledEventUpdate) GuildScheduledEventUserAdd(handler HandlerGuildScheduledEventUserAdd, moreHandlers ...HandlerGuildScheduledEventUserAdd) GuildScheduledEventUserAddChan(handler chan *GuildScheduledEventUserAdd, moreHandlers ...chan *GuildScheduledEventUserAdd) GuildScheduledEventUserRemove(handler HandlerGuildScheduledEventUserRemove, moreHandlers ...HandlerGuildScheduledEventUserRemove) GuildScheduledEventUserRemoveChan(handler chan *GuildScheduledEventUserRemove, moreHandlers ...chan *GuildScheduledEventUserRemove) GuildStickersUpdate(handler HandlerGuildStickersUpdate, moreHandlers ...HandlerGuildStickersUpdate) GuildStickersUpdateChan(handler chan *GuildStickersUpdate, moreHandlers ...chan *GuildStickersUpdate) 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) ThreadCreate(handler HandlerThreadCreate, moreHandlers ...HandlerThreadCreate) ThreadCreateChan(handler chan *ThreadCreate, moreHandlers ...chan *ThreadCreate) ThreadDelete(handler HandlerThreadDelete, moreHandlers ...HandlerThreadDelete) ThreadDeleteChan(handler chan *ThreadDelete, moreHandlers ...chan *ThreadDelete) ThreadListSync(handler HandlerThreadListSync, moreHandlers ...HandlerThreadListSync) ThreadListSyncChan(handler chan *ThreadListSync, moreHandlers ...chan *ThreadListSync) ThreadMemberUpdate(handler HandlerThreadMemberUpdate, moreHandlers ...HandlerThreadMemberUpdate) ThreadMemberUpdateChan(handler chan *ThreadMemberUpdate, moreHandlers ...chan *ThreadMemberUpdate) ThreadMembersUpdate(handler HandlerThreadMembersUpdate, moreHandlers ...HandlerThreadMembersUpdate) ThreadMembersUpdateChan(handler chan *ThreadMembersUpdate, moreHandlers ...chan *ThreadMembersUpdate) ThreadUpdate(handler HandlerThreadUpdate, moreHandlers ...HandlerThreadUpdate) ThreadUpdateChan(handler chan *ThreadUpdate, moreHandlers ...chan *ThreadUpdate) 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 TextInputStyle ¶ added in v0.36.0
type TextInputStyle = int
const ( TextInputStyleShort TextInputStyle TextInputStyleParagraph )
type ThreadCreate ¶ added in v0.30.0
ThreadCreate thread was created https://discord.com/developers/docs/topics/gateway#thread-create
type ThreadDelete ¶ added in v0.30.0
ThreadDelete thread was deleted https://discord.com/developers/docs/topics/gateway#thread-delete
type ThreadListSync ¶ added in v0.30.0
type ThreadListSync struct { GuildID Snowflake `json:"guild_id"` ChannelIDs []Snowflake `json:"channel_ids,omitempty"` Threads []*Channel `json:"threads"` Members []*ThreadMember `json:"members"` ShardID uint `json:"-"` }
ThreadListSync current user gains access to a thread https://discord.com/developers/docs/topics/gateway#thread-list-sync
type ThreadMember ¶ added in v0.30.0
type ThreadMember struct { ThreadID Snowflake `json:"id,omitempty"` UserID Snowflake `json:"user_id,omitempty"` JoinTimestamp Time `json:"join_timestamp"` Flags Flag `json:"flags"` }
ThreadMember https://discord.com/developers/docs/resources/channel#thread-member-object
type ThreadMemberUpdate ¶ added in v0.30.0
type ThreadMemberUpdate struct { Member *ThreadMember `json:"member"` ShardID uint `json:"-"` }
ThreadMemberUpdate current user gains access to a thread https://discord.com/developers/docs/topics/gateway#thread-member-update
type ThreadMembersUpdate ¶ added in v0.30.0
type ThreadMembersUpdate struct { ID Snowflake `json:"id"` GuildID Snowflake `json:"guild_id"` MemberCount int `json:"member_count"` AddedMembers []*ThreadMember `json:"added_members,omitempty"` RemovedMemberIDs []Snowflake `json:"removed_member_ids,omitempty"` ShardID uint `json:"-"` }
ThreadMembersUpdate current user gains access to a thread https://discord.com/developers/docs/topics/gateway#thread-members-update
type ThreadMetadata ¶ added in v0.30.0
type ThreadMetadata struct { Archived bool `json:"archived"` AutoArchiveDuration int `json:"auto_archive_duration"` ArchiveTimestamp Time `json:"archive_timestamp"` Locked bool `json:"locked"` Invitable bool `json:"inviteable,omitempty"` }
ThreadMetadata https://discord.com/developers/docs/resources/channel#thread-metadata-object
type ThreadUpdate ¶ added in v0.30.0
ThreadUpdate thread was updated https://discord.com/developers/docs/topics/gateway#thread-update
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