disgord

package module
v0.36.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2023 License: BSD-3-Clause Imports: 33 Imported by: 90

README

About

Go module with context support that handles some of the difficulties from interacting with Discord's bot interface for you; websocket sharding, auto-scaling of websocket connections, advanced caching (cache replacement strategies to restrict memory usage), helper functions, middlewares and lifetime controllers for event handlers, etc.

This package is intented to be used with the gateway to keep the cache up to date. You should treat data as read only, since they simply represent the discord state. To change the discord state you can use the REST methods and the gateway commands, which will eventually update your local state as well.

If you want a more lightweight experience you can disable/reject events that you do not need or want to keep track of. Be careful as this might break certain things.

Tips

  • Use disgord.Snowflake, not snowflake.Snowflake.
  • Use disgord.Time, not time.Time when dealing with Discord timestamps.

You must explicitly set intents if you want certain gateway events.

client := disgord.New(disgord.Config{
    Intents: disgord.IntentDirectMessages | disgord.IntentDirectMessageReactions,
})
client := disgord.New(disgord.Config{
    Intents: disgord.AllIntents(),
})

Starter guide

This project uses Go Modules for dealing with dependencies, remember to activate module support in your IDE

Examples can be found in examples and some open source projects Disgord projects in the wiki

I highly suggest reading the Discord API documentation and the Disgord go doc.

Simply use this github template to create your first new bot!

API / Interface

In short Disgord uses the builder pattern by respecting resources

The Client or Session holds are the relevant methods for interacting with Discord. The API is split by resource, such that Guild related information is found in Client.Guild(guild_id), while user related info is found in Client.User(user_id), gateway interaction is found in Client.Gateway(), the same for Channel, CurrentUser, Emoji, AuditLog, etc.

Cancellation is supported by calling .WithContext(context.Context before the final REST call (.Get(), .Update(), etc.).

Events

every event goes through the cache layer!

For Events, Disgord uses the reactor pattern. This supports both channels and functions. You chose your preference.

REST

If the request is a standard GET request, the cache is always checked first to reduce delay, network traffic and load on the Discord servers. And on responses, regardless of the http method, the data is copied into the cache.

// bypasses local cache
client.CurrentUser().Get(disgord.IgnoreCache)
client.Guild(guildID).GetMembers(disgord.IgnoreCache)

// always checks the local cache first
client.CurrentUser().Get()
client.Guild(guildID).GetMembers()

// with cancellation
deadline, _ := context.WithDeadline(context.Background(), time.Now().Add(2*time.Second))
client.CurrentUser().WithContext(deadline).Get()

Voice

Whenever you want the bot to join a voice channel, a websocket and UDP connection is established. So if your bot is currently in 5 voice channels, then you have 5 websocket connections and 5 udp connections open to handle the voice traffic.

Cache

The cache tries to represent the Discord state as accurate as it can. Because of this, the cache is immutable by default. Meaning the does not allow you to reference any cached objects directly, and every incoming and outgoing data of the cache is deep copied.

Contributing

Please see the CONTRIBUTING.md file (Note that it can be useful to read this regardless if you have the time)

You can contribute with pull requests, issues, wiki updates and helping out in the discord servers mentioned above.

To notify about bugs or suggesting enhancements, simply create a issue. The more the better. But be detailed enough that it can be reproduced and please provide logs.

To contribute with code, always create an issue before you open a pull request. This allows automating change logs and releases.

Remember to have stringer installed to run go generate: go get -u golang.org/x/tools/cmd/stringer

Sponsors

JetBrains

A Special thanks to the following companies for sponsoring this project!

Software used

Q&A

NOTE: To see more examples go to the examples folder. See the GoDoc for a in-depth introduction on the various topics.

1. How do I find my bot token and/or add my bot to a server?

Tutorial here: https://github.com/andersfylling/disgord/wiki/Get-bot-token-and-add-it-to-a-server
2. Is there an alternative Go package?

Yes, it's called DiscordGo (https://github.com/bwmarrin/discordgo). Its purpose is to provide a 
minimalistic API wrapper for Discord, it does not handle multiple websocket sharding, scaling, etc. 
behind the scenes such as Disgord does. Currently I do not have a comparison chart of Disgord and 
DiscordGo. But I do want to create one in the future, for now the biggest difference is that 
Disgord does not support self bots.
3. Why make another Discord lib in Go?

I'm trying to take over the world and then become a intergalactic war lord. Have to start somewhere.
4. Will Disgord support self bots?

No. Self bots are againts ToS and could result in account termination (see
https://support.discord.com/hc/en-us/articles/115002192352-Automated-user-accounts-self-bots-). 
In addition, self bots aren't a part of the official Discord API, meaning support could change at
any time and Disgord could break unexpectedly if this feature were to be added.

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

View Source
const (
	StatusOnline  = gateway.StatusOnline
	StatusOffline = gateway.StatusOffline
	StatusDnd     = gateway.StatusDND
	StatusIdle    = gateway.StatusIdle
)
View Source
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

View Source
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
)
View Source
const (
	MessageActivityTypeJoin
	MessageActivityTypeSpectate
	MessageActivityTypeListen
	MessageActivityTypeJoinRequest
)

different message activity types

View Source
const (
	AttachmentSpoilerPrefix = "SPOILER_"
)
View Source
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.

View Source
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.

View Source
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.

View Source
const EvtChannelUpdate = event.ChannelUpdate

EvtChannelUpdate Sent when a channel is updated. The inner payload is a guild channel object.

View Source
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.

View Source
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.

View Source
const EvtGuildCreate = event.GuildCreate

EvtGuildCreate This event can be sent in three different scenarios:

  1. When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the Ready event.
  2. When a Guild becomes available again to the client.
  3. When the current user joins a new Guild.
View Source
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.

View Source
const EvtGuildEmojisUpdate = event.GuildEmojisUpdate

EvtGuildEmojisUpdate Sent when a guild's emojis have been updated.

View Source
const EvtGuildIntegrationsUpdate = event.GuildIntegrationsUpdate

EvtGuildIntegrationsUpdate Sent when a guild integration is updated.

View Source
const EvtGuildMemberAdd = event.GuildMemberAdd

EvtGuildMemberAdd Sent when a new user joins a guild.

View Source
const EvtGuildMemberRemove = event.GuildMemberRemove

EvtGuildMemberRemove Sent when a user is removed from a guild (leave/kick/ban).

View Source
const EvtGuildMemberUpdate = event.GuildMemberUpdate

EvtGuildMemberUpdate Sent when a guild member is updated.

View Source
const EvtGuildMembersChunk = event.GuildMembersChunk

EvtGuildMembersChunk Sent in response to Gateway Request Guild Members.

View Source
const EvtGuildRoleCreate = event.GuildRoleCreate

EvtGuildRoleCreate Sent when a guild role is created.

View Source
const EvtGuildRoleDelete = event.GuildRoleDelete

EvtGuildRoleDelete Sent when a guild role is created.

View Source
const EvtGuildRoleUpdate = event.GuildRoleUpdate

EvtGuildRoleUpdate Sent when a guild role is created.

View Source
const EvtGuildScheduledEventCreate = event.GuildScheduledEventCreate

EvtGuildScheduledEventCreate ...

View Source
const EvtGuildScheduledEventDelete = event.GuildScheduledEventDelete

EvtGuildScheduledEventDelete ...

View Source
const EvtGuildScheduledEventUpdate = event.GuildScheduledEventUpdate

EvtGuildScheduledEventUpdate ...

View Source
const EvtGuildScheduledEventUserAdd = event.GuildScheduledEventUserAdd

EvtGuildScheduledEventUserAdd ...

View Source
const EvtGuildScheduledEventUserRemove = event.GuildScheduledEventUserRemove

EvtGuildScheduledEventUserRemove ...

View Source
const EvtGuildStickersUpdate = event.GuildStickersUpdate

EvtGuildStickersUpdate ...

View Source
const EvtGuildUpdate = event.GuildUpdate

EvtGuildUpdate Sent when a guild is updated. The inner payload is a guild object.

View Source
const EvtInteractionCreate = event.InteractionCreate

EvtInteractionCreate Sent when a user in a guild uses a Slash Command.

View Source
const EvtInviteCreate = event.InviteCreate

EvtInviteCreate Sent when a guild's invite is created.

View Source
const EvtInviteDelete = event.InviteDelete

EvtInviteDelete Sent when an invite is deleted.

View Source
const EvtMessageCreate = event.MessageCreate

EvtMessageCreate Sent when a message is created. The inner payload is a message object.

View Source
const EvtMessageDelete = event.MessageDelete

EvtMessageDelete Sent when a message is deleted.

View Source
const EvtMessageDeleteBulk = event.MessageDeleteBulk

EvtMessageDeleteBulk Sent when multiple messages are deleted at once.

View Source
const EvtMessageReactionAdd = event.MessageReactionAdd

EvtMessageReactionAdd Sent when a user adds a reaction to a message.

View Source
const EvtMessageReactionRemove = event.MessageReactionRemove

EvtMessageReactionRemove Sent when a user removes a reaction from a message.

View Source
const EvtMessageReactionRemoveAll = event.MessageReactionRemoveAll

EvtMessageReactionRemoveAll Sent when a user explicitly removes all reactions from a message.

View Source
const EvtMessageReactionRemoveEmoji = event.MessageReactionRemoveEmoji

EvtMessageReactionRemoveEmoji Sent when a bot removes all instances of a given emoji from the reactions of a message.

View Source
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.

View Source
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.

View Source
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.

View Source
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).

View Source
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.

View Source
const EvtThreadDelete = event.ThreadDelete

EvtThreadDelete Sent when a thread relevant to the current user is deleted.

View Source
const EvtThreadListSync = event.ThreadListSync

EvtThreadListSync Sent when the current user gains access to a channel.

View Source
const EvtThreadMemberUpdate = event.ThreadMemberUpdate

EvtThreadMemberUpdate Sent when the thread member object for the current user is updated.

View Source
const EvtThreadMembersUpdate = event.ThreadMembersUpdate

EvtThreadMembersUpdate Sent when anyone is added to or removed from a thread.

View Source
const EvtThreadUpdate = event.ThreadUpdate

EvtThreadUpdate Sent when a thread is updated.

View Source
const EvtTypingStart = event.TypingStart

EvtTypingStart Sent when a user starts typing in a channel.

View Source
const EvtUserUpdate = event.UserUpdate

EvtUserUpdate Sent when properties about the user change. Inner payload is a user object.

View Source
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.

View Source
const EvtVoiceStateUpdate = event.VoiceStateUpdate

EvtVoiceStateUpdate Sent when someone joins/leaves/moves voice channels. Inner payload is a voice state object.

View Source
const EvtWebhooksUpdate = event.WebhooksUpdate

EvtWebhooksUpdate Sent when a guild channel's WebHook is created, updated, or deleted.

View Source
const Name = constant.Name
View Source
const Version = constant.Version

Variables

View Source
var DefaultHttpClient = &http.Client{}
View Source
var ErrCacheEntryAlreadyExists = errors.New("cache entry already exists")
View Source
var ErrCacheMiss = errors.New("no matching entry found in cache")
View Source
var ErrIllegalScheduledEventPrivacyLevelValue = fmt.Errorf("scheduled event privacy level: %w", ErrIllegalValue)
View Source
var ErrIllegalValue = errors.New("illegal value")
View Source
var ErrMissingChannelID = fmt.Errorf("channel: %w", ErrMissingID)
View Source
var ErrMissingChannelName = fmt.Errorf("channel: %w", ErrMissingName)
View Source
var ErrMissingClientInstance = errors.New("client instance was not specified")
View Source
var ErrMissingEmojiID = fmt.Errorf("emoji: %w", ErrMissingID)
View Source
var ErrMissingGuildID = fmt.Errorf("guild: %w", ErrMissingID)
View Source
var ErrMissingGuildName = fmt.Errorf("guild: %w", ErrMissingName)
View Source
var ErrMissingID = fmt.Errorf("id: %w", ErrMissingRequiredField)
View Source
var ErrMissingMessageID = fmt.Errorf("message: %w", ErrMissingID)
View Source
var ErrMissingName = fmt.Errorf("name: %w", ErrMissingRequiredField)
View Source
var ErrMissingPermissionOverwriteID = fmt.Errorf("channel permission overwrite: %w", ErrMissingID)
View Source
var ErrMissingRESTParams = errors.New("this method requires REST parameters, but none were given")
View Source
var ErrMissingRequiredField = errors.New("missing required field")
View Source
var ErrMissingRoleID = fmt.Errorf("role: %w", ErrMissingID)
View Source
var ErrMissingScheduledEventEndTime = fmt.Errorf("scheduled event end: %w", ErrMissingTime)
View Source
var ErrMissingScheduledEventEntityType = fmt.Errorf("scheduled event entity: %w", ErrMissingType)
View Source
var ErrMissingScheduledEventLocation = fmt.Errorf("scheduled event: %w", ErrMissingRequiredField)
View Source
var ErrMissingScheduledEventName = fmt.Errorf("scheduled event name: %w", ErrMissingName)
View Source
var ErrMissingScheduledEventStartTime = fmt.Errorf("scheduled event start: %w", ErrMissingTime)
View Source
var ErrMissingThreadName = fmt.Errorf("thread: %w", ErrMissingName)
View Source
var ErrMissingTime = fmt.Errorf("time: %w", ErrMissingRequiredField)
View Source
var ErrMissingType = fmt.Errorf("type: %w", ErrMissingRequiredField)
View Source
var ErrMissingUserID = fmt.Errorf("user: %w", ErrMissingID)
View Source
var ErrMissingWebhookID = fmt.Errorf("webhook: %w", ErrMissingID)
View Source
var ErrMissingWebhookName = fmt.Errorf("webhook: %w", ErrMissingName)
View Source
var ErrMissingWebhookToken = errors.New("webhook token was not set")

Functions

func AllEvents added in v0.14.2

func AllEvents() []string

func AllEventsExcept added in v0.21.0

func AllEventsExcept(except ...string) []string

func CreateTermSigListener added in v0.16.3

func CreateTermSigListener() <-chan os.Signal

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 DeepCopyOver(dst Copier, src Copier) error

func LibraryInfo added in v0.4.0

func LibraryInfo() string

LibraryInfo returns name + version

func Reset added in v0.22.0

func Reset(r Reseter)

func ShardID added in v0.12.0

func ShardID(guildID Snowflake, nrOfShards uint) uint

ShardID calculate the shard id for a given guild. https://discord.com/developers/docs/topics/gateway#sharding-sharding-formula

func Sort added in v0.10.0

func Sort(v interface{}, fs ...Flag)

func ValidateUsername added in v0.8.0

func ValidateUsername(name string) (err error)

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 Application struct {
	ID   Snowflake `json:"id"`
	Name string    `json:"name"`
}

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

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

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 (b *BanMember) FindErrors() error

func (*BanMember) URLQueryString added in v0.30.0

func (b *BanMember) URLQueryString() string

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) Ready added in v0.27.0

func (c *BasicCache) Ready(data []byte) (*Ready, 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 (c *CacheNop) GetChannel(id Snowflake) (*Channel, error)

func (*CacheNop) GetCurrentUser added in v0.19.0

func (c *CacheNop) GetCurrentUser() (*User, error)

func (*CacheNop) GetCurrentUserGuilds added in v0.19.0

func (c *CacheNop) GetCurrentUserGuilds(p *GetCurrentUserGuilds) ([]*Guild, error)

func (*CacheNop) GetGuild added in v0.19.0

func (c *CacheNop) GetGuild(id Snowflake) (*Guild, error)

func (*CacheNop) GetGuildChannels added in v0.19.0

func (c *CacheNop) GetGuildChannels(id Snowflake) ([]*Channel, error)

func (*CacheNop) GetGuildEmoji added in v0.19.0

func (c *CacheNop) GetGuildEmoji(guildID, emojiID Snowflake) (*Emoji, error)

func (*CacheNop) GetGuildEmojis added in v0.19.0

func (c *CacheNop) GetGuildEmojis(id Snowflake) ([]*Emoji, error)

func (*CacheNop) GetGuildRoles added in v0.19.0

func (c *CacheNop) GetGuildRoles(guildID Snowflake) ([]*Role, error)

func (*CacheNop) GetMember added in v0.19.0

func (c *CacheNop) GetMember(guildID, userID Snowflake) (*Member, error)

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

func (c *CacheNop) GetMessage(channelID, messageID Snowflake) (*Message, error)

REST lookup

func (*CacheNop) GetMessages added in v0.19.0

func (c *CacheNop) GetMessages(channel Snowflake, p *GetMessages) ([]*Message, error)

func (*CacheNop) GetUser added in v0.19.0

func (c *CacheNop) GetUser(id Snowflake) (*User, 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) Patch added in v0.19.0

func (c *CacheNop) Patch(v interface{})

func (*CacheNop) PresenceUpdate added in v0.19.0

func (c *CacheNop) PresenceUpdate(data []byte) (evt *PresenceUpdate, err error)

func (*CacheNop) Ready added in v0.19.0

func (c *CacheNop) Ready(data []byte) (evt *Ready, err error)

func (*CacheNop) Resumed added in v0.19.0

func (c *CacheNop) Resumed(data []byte) (evt *Resumed, 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) Compare added in v0.6.0

func (c *Channel) Compare(other *Channel) bool

Compare checks if channel A is the same as channel B

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

func (c *Channel) Mention() string

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

func (*Channel) SendMsgString added in v0.6.0

func (c *Channel) SendMsgString(ctx context.Context, s Session, content string) (msg *Message, err error)

SendMsgString same as SendMsg, however this only takes the message content (string) as a argument for the message

func (*Channel) String added in v0.10.0

func (c *Channel) String() string

type ChannelCreate added in v0.6.0

type ChannelCreate struct {
	Channel *Channel `json:"channel"`
	ShardID uint     `json:"-"`
}

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

type ChannelDelete struct {
	Channel *Channel `json:"channel"`
	ShardID uint     `json:"-"`
}

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

type ChannelUpdate struct {
	Channel *Channel `json:"channel"`
	ShardID uint     `json:"-"`
}

ChannelUpdate channel was updated

func (*ChannelUpdate) UnmarshalJSON added in v0.8.0

func (obj *ChannelUpdate) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type Client

type Client struct {
	WebsocketHttpClient *http.Client
	// contains filtered or unexported fields
}

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 New added in v0.9.0

func New(conf Config) *Client

New create a Client. But panics on configuration/setup errors.

func NewClient

func NewClient(ctx context.Context, conf Config) (*Client, error)

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

func (c *Client) AvgHeartbeatLatency() (duration time.Duration, err error)

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) Cache added in v0.8.0

func (c *Client) Cache() Cache

Cache returns the cacheLink manager for the session

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

func (c *Client) GetConnectedGuilds() []Snowflake

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

func (c *Client) HeartbeatLatencies() (latencies map[uint]time.Duration, err error)

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

func (c *Client) Logger() logger.Logger

Logger returns the log instance of Disgord. Note that this instance is never nil. When the conf.Logger is not assigned an empty struct is used instead. Such that all calls are simply discarded at compile time removing the need for nil checks.

func (*Client) Pool added in v0.10.0

func (c *Client) Pool() *pools

func (*Client) RESTRatelimitBuckets added in v0.16.5

func (c *Client) RESTRatelimitBuckets() (group map[string][]string)

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

func (c Client) SendMsg(channelID Snowflake, data ...interface{}) (msg *Message, err error)

SendMsg should convert all inputs into a single message. If you supply a object with an ID such as a channel, message, role, etc. It will become a reference. If say the Message provided does not have an ID, the Message will populate a CreateMessage with it's fields.

If you want to affect the actual message data besides .Content; provide a MessageCreate. The reply message will be updated by the last one provided.

func (*Client) String

func (c *Client) String() string

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

func (c *Client) UpdateStatusString(s string) error

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 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 ClientStatus struct {
	Desktop string `json:"desktop"`
	Mobile  string `json:"mobile"`
	Web     string `json:"web"`
}

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

type CreateGuildIntegration struct {
	Type string    `json:"type"`
	ID   Snowflake `json:"id"`
}

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

type Ctrl struct {
	Runs     int
	Until    time.Time
	Duration time.Duration
	Channel  interface{}
}

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

func (*Ctrl) IsDead added in v0.10.0

func (c *Ctrl) IsDead() bool

func (*Ctrl) OnInsert added in v0.10.0

func (c *Ctrl) OnInsert(Session) error

func (*Ctrl) OnRemove added in v0.10.0

func (c *Ctrl) OnRemove(Session) error

func (*Ctrl) Update added in v0.10.0

func (c *Ctrl) Update()

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
	Footer      *EmbedFooter    `json:"footer,omitempty"`      // embed footer object	footer information
	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 {
	Text         string `json:"text"`                     //  | , url of author
	IconURL      string `json:"icon_url,omitempty"`       // ?| , url of footer icon (only supports http(s) and attachments)
	ProxyIconURL string `json:"proxy_icon_url,omitempty"` // ?| , a proxied url of footer icon
}

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 EmbedType added in v0.25.0

type EmbedType string
const (
	EmbedTypeRich    EmbedType = "rich"
	EmbedTypeImage   EmbedType = "image"
	EmbedTypeVideo   EmbedType = "video"
	EmbedTypeGIFV    EmbedType = "gifv"
	EmbedTypeArticle EmbedType = "article"
	EmbedTypeLink    EmbedType = "link"
)

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

func (*Emoji) Mention added in v0.6.0

func (e *Emoji) Mention() string

Mention mentions an emoji. Adds the animation prefix, if animated

func (*Emoji) String added in v0.10.0

func (e *Emoji) String() string

type Err added in v0.12.2

type Err = disgorderr.Err

type ErrRest added in v0.8.0

type ErrRest = httd.ErrREST

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
const (
	IgnoreCache Flag = 1 << iota
	IgnoreEmptyParams

	// sort options
	SortByID
	SortByName
	SortByHoist
	SortByGuildID
	SortByChannelID

	// ordering
	OrderAscending // default when sorting
	OrderDescending
)

func (Flag) IgnoreEmptyParams added in v0.10.0

func (f Flag) IgnoreEmptyParams() bool

func (Flag) Ignorecache added in v0.10.0

func (f Flag) Ignorecache() bool

func (Flag) Sort added in v0.10.0

func (f Flag) Sort() bool

func (Flag) String deprecated added in v0.10.0

func (i Flag) String() string

String

Deprecated: schedule for removal

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 GetPruneMembersCount struct {
	Days         *int        `json:"days,omitempty"`
	IncludeRoles []Snowflake `json:"include_roles,omitempty"`
}

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"`        // ?*|
	Unavailable bool            `json:"unavailable"`            // ?*| 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

func (g *Guild) AddChannel(c *Channel) error

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

func (g *Guild) AddMember(member *Member) error

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

func (g *Guild) AddMembers(members []*Member)

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

func (g *Guild) AddRole(role *Role) error

AddRole adds a role to the Guild object. Note that this does not interact with Discord.

func (*Guild) Channel added in v0.6.0

func (g *Guild) Channel(id Snowflake) (*Channel, error)

Channel get a guild channel given it's ID

func (*Guild) DeleteChannel added in v0.6.0

func (g *Guild) DeleteChannel(c *Channel) error

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

func (g *Guild) DeleteChannelByID(ID Snowflake) error

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

func (g *Guild) DeleteRoleByID(ID Snowflake)

DeleteRoleByID remove a role from the guild struct

func (*Guild) Emoji added in v0.8.0

func (g *Guild) Emoji(id Snowflake) (emoji *Emoji, err error)

Emoji get a guild emoji by it's ID

func (*Guild) GetMemberWithHighestSnowflake added in v0.7.0

func (g *Guild) GetMemberWithHighestSnowflake() *Member

GetMemberWithHighestSnowflake finds the member with the highest snowflake value.

func (*Guild) GetMembersCountEstimate added in v0.12.0

func (g *Guild) GetMembersCountEstimate(ctx context.Context, s Session) (estimate int, err error)

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) Member added in v0.6.0

func (g *Guild) Member(id Snowflake) (*Member, error)

Member return a member by his/her userid

func (*Guild) MembersByName added in v0.7.0

func (g *Guild) MembersByName(name string) (members []*Member)

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) Role added in v0.6.0

func (g *Guild) Role(id Snowflake) (*Role, error)

Role retrieve a role based on role id

func (*Guild) RoleByName added in v0.6.0

func (g *Guild) RoleByName(name string) ([]*Role, error)

RoleByName retrieves a slice of roles with same name

func (*Guild) String added in v0.10.0

func (g *Guild) String() string

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:

  1. When a user is initially connecting, to lazily load and backfill information for all unavailable Guilds sent in the Ready event.
  2. When a Guild becomes available again to the Client.
  3. 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 {
	UnavailableGuild *GuildUnavailable `json:"guild_unavailable"`
	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

type GuildIntegrationsUpdate struct {
	GuildID Snowflake `json:"guild_id"`
	ShardID uint      `json:"-"`
}

GuildIntegrationsUpdate guild integration was updated

type GuildMemberAdd added in v0.6.0

type GuildMemberAdd struct {
	Member  *Member `json:"member"`
	ShardID uint    `json:"-"`
}

GuildMemberAdd new user joined a guild

func (*GuildMemberAdd) UnmarshalJSON added in v0.9.0

func (obj *GuildMemberAdd) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type 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

type GuildMemberUpdate struct {
	*Member
	ShardID uint `json:"-"`
}

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 GuildScheduledEventUserAdd struct {
	GuildScheduledEventID Snowflake `json:"guild_scheduled_event_id"`
	UserID                Snowflake `json:"user_id"`
	GuildID               Snowflake `json:"guild_id"`

	ShardID uint `json:"-"`
}

type GuildScheduledEventUserRemove added in v0.30.0

type GuildScheduledEventUserRemove struct {
	GuildScheduledEventID Snowflake `json:"guild_scheduled_event_id"`
	UserID                Snowflake `json:"user_id"`
	GuildID               Snowflake `json:"guild_id"`

	ShardID uint `json:"-"`
}

type GuildScheduledEventUsers added in v0.35.0

type GuildScheduledEventUsers struct {
	GuildScheduledEventID Snowflake `json:"guild_scheduled_event_id"`
	User                  `json:"user"`
	Member                `json:"member"`
}

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 {
	ID          Snowflake `json:"id"`
	Unavailable bool      `json:"unavailable"` // ?*|
}

GuildUnavailable is a partial Guild object.

type GuildUpdate added in v0.6.0

type GuildUpdate struct {
	Guild   *Guild `json:"guild"`
	ShardID uint   `json:"-"`
}

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

type GuildWidget struct {
	Enabled   bool      `json:"enabled"`
	ChannelID Snowflake `json:"channel_id"`
}

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

type HandlerReady = func(s Session, h *Ready)

HandlerReady is triggered by Ready events

type HandlerResumed added in v0.17.0

type HandlerResumed = func(s Session, h *Resumed)

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 HttpClientDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

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

type Intent = gateway.Intent

func AllIntents added in v0.17.0

func AllIntents() Intent

func AllIntentsExcept added in v0.22.0

func AllIntentsExcept(exceptions ...Intent) Intent

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 Logger added in v0.9.0

type Logger = logger.Logger

Logger super basic logging interface

type MFALvl added in v0.6.0

type MFALvl uint

MFALvl ... https://discord.com/developers/docs/resources/guild#guild-object-mfa-level

const (
	MFALvlNone MFALvl = iota
	MFALvlElevated
)

Different MFA levels

func (*MFALvl) Elevated added in v0.6.0

func (mfal *MFALvl) Elevated() bool

Elevated ...

func (*MFALvl) None added in v0.6.0

func (mfal *MFALvl) None() bool

None ...

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

func (m *Member) GetUser(ctx context.Context, session Session) (usr *User, err error)

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

func (m *Member) Mention() string

Mention creates a string which is parsed into a member mention on Discord GUI's

func (*Member) String added in v0.7.0

func (m *Member) String() string

func (*Member) UpdateNick added in v0.12.0

func (m *Member) UpdateNick(ctx context.Context, client GuildQueryBuilderCaller, nickname string) error

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

func (m *Message) DiscordURL() (string, error)

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

func (m *Message) IsDirectMessage() bool

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) React added in v0.12.0

func (m *Message) React(ctx context.Context, s Session, emoji interface{}) error

func (*Message) Reply added in v0.10.0

func (m *Message) Reply(ctx context.Context, s Session, data ...interface{}) (*Message, error)

Reply input any type as an reply. int, string, an object, etc.

func (*Message) Send added in v0.6.0

func (m *Message) Send(ctx context.Context, s Session) (msg *Message, err error)

Send sends this message to discord.

func (*Message) String added in v0.10.0

func (m *Message) String() string

func (*Message) Unreact added in v0.12.0

func (m *Message) Unreact(ctx context.Context, s Session, emoji interface{}) error

type MessageActivity added in v0.6.0

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

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

type MessageCreate struct {
	Message *Message
	ShardID uint `json:"-"`
}

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 MessageReference struct {
	MessageID Snowflake `json:"message_id"`
	ChannelID Snowflake `json:"channel_id"`
	GuildID   Snowflake `json:"guild_id"`
}

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

type MessageUpdate struct {
	Message *Message
	ShardID uint `json:"-"`
}

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

type PartialBan struct {
	Reason                 string
	BannedUserID           Snowflake
	ModeratorResponsibleID Snowflake
}

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 PartialEmoji added in v0.6.0

type PartialEmoji = Emoji

PartialEmoji see Emoji

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 Pool added in v0.10.0

type Pool interface {
	Put(x Reseter)
	Get() (x Reseter)
}

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

func (r *Role) Mention() string

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

func (r *Role) SetGuildID(id Snowflake)

SetGuildID link role to a guild before running session.SaveToDiscord(*Role)

func (*Role) String added in v0.10.0

func (r *Role) String() string

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 SelectMenuOption struct {
	Label       string `json:"label"`
	Value       string `json:"value"`
	Description string `json:"description"`
	Emoji       *Emoji `json:"emoji"`
	Default     bool   `json:"default"`
}

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

type Snowflake = util.Snowflake

Snowflake twitter snowflake identification for Discord

func GetSnowflake added in v0.6.0

func GetSnowflake(v interface{}) (Snowflake, error)

GetSnowflake see snowflake.GetSnowflake

func ParseSnowflakeString added in v0.6.0

func ParseSnowflakeString(v string) Snowflake

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

type ThreadCreate struct {
	Thread  *Channel `json:"thread"`
	ShardID uint     `json:"-"`
}

ThreadCreate thread was created https://discord.com/developers/docs/topics/gateway#thread-create

type ThreadDelete added in v0.30.0

type ThreadDelete struct {
	Thread  *Channel `json:"thread"`
	ShardID uint     `json:"-"`
}

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

type ThreadUpdate struct {
	Thread  *Channel `json:"thread"`
	ShardID uint     `json:"-"`
}

ThreadUpdate thread was updated https://discord.com/developers/docs/topics/gateway#thread-update

type Time added in v0.10.0

type Time struct {
	time.Time
}

Time handles Discord timestamps

func (Time) MarshalJSON added in v0.10.0

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. error: https://stackoverflow.com/questions/28464711/go-strange-json-hyphen-unmarshall-error

func (Time) String added in v0.10.0

func (t Time) String() string

String returns the timestamp as a Discord formatted timestamp. Formatting with time.RFC3331 does not suffice.

func (*Time) UnmarshalJSON added in v0.10.0

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type TypingStart added in v0.6.0

type TypingStart struct {
	ChannelID     Snowflake `json:"channel_id"`
	GuildID       Snowflake `json:"guild_id"`
	UserID        Snowflake `json:"user_id"`
	Member        *Member   `json:"member"`
	TimestampUnix int       `json:"timestamp"`
	ShardID       uint      `json:"-"`
}

TypingStart user started typing in a channel

type