disgord

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: BSD-3-Clause Imports: 23 Imported by: 90

README

Disgord

forthebadgeforthebadgeforthebadge

Health

Branch Build status Code climate Go Report Card Codacy
develop CircleCI Maintainability Go Report Card Codacy Badge

About

GoLang module for interacting with the Discord API. Supports socketing and REST functionality. Discord object will also have implemented helper functions such as Message.RespondString(session, "hello"), or Channel.SendMsg(session, &Message{...}) for simplicity/readability.

Disgord has complete implementation for Discord's documented REST API. It lacks comprehensive testing, although unit-tests have been created for several of the disgord REST implementations. The socketing is not complete, but does support all event types (using both channels and callbacks).

Note that caching is yet to be implemented. Versions from v0.5.1 and below, had caching to some degree, but was scrapped once a complete rework of the project structure was done.

Disgord does not utilize reflection, except in unit tests and unmarshalling/marshalling of JSON.

To get started see the examples in docs

Alternative GoLang package for Discord: DiscordGo

Package structure

None of the sub-packages should be used outside the library. If there exists a requirement for that, please create an issue or pull request.

github.com/andersfylling/disgord
└──.circleci    :CircleCI configuration
└──constant     :Constants such as version, GitHub URL, etc.
└──docs         :Examples, templates, (documentation)
└──endpoint     :All the REST endpoints of Discord
└──httd         :Deals with rate limits and http calls
└──testdata     :Holds all test data for unit tests (typically JSON files)
└──websocket    :Discord Websocket logic (reconnect, resume, etc.)
Dependencies
github.com/andersfylling/disgord
└──github.com/andersfylling/snowflake  :The snowflake ID designed for Discord
└──github.com/json-iterator/go         :For faster JSON decoding/encoding
└──github.com/sergi/go-diff            :Unit testing for checking JSON encoding/decoding of structs
└──github.com/sirupsen/logrus          :Logging (will be replaced with a simplified interface for DI)

Contributing

Please see the CONTRIBUTING.md file

Git branching model

The branch:develop holds the most recent changes, as it name implies. There is no master branch as there will never be a "stable latest branch" except the git tags (or releases).

Mental model

Caching

The cache, of discord objects, aims to reflect the same state as of the discord servers. Therefore incoming data is deep copied, as well as return values from the cache. This lib handles caching for you, so whenever you send a request to the REST API or receive a discord event. The contents are cached auto-magically to a separate memory space.

As a structure is sent into the cache module, everything is deep copied as mentioned, however if the object hold discord objects consistent of a snowflake, it does not do a deep copy. It converts given field to a nil, and stores only the snowflake in a separate struct/map. This makes sure that there will only exist one version of an object. Making updating fairly easy. When the object goes out of cache, a copy is created and every sub object containing a snowflake is deep copied from the cache as well, to return a wholesome object.

Requests

For every REST API request the request is rate limited auto-magically by disgord. The functions in resource pkg are blocking, and should be used with care. In the future there might be implementations of channel methods if requested.

Events

The reactor pattern with goroutines, or a pro-actor pattern is used. This will always be the default behavior, synchronous triggering of listeners might be implemented in the future as an option. Incoming events from the discord servers are parsed into respective structs and dispatched to either a) callbacks, or b) through channels. Both are dispatched from the same place, and the arguments share the same memory space. So it doesn't matter which one you pick, chose your preference.

Quick example

NOTE: To see more examples go visit the docs/examples folder.

The following example is used as a prerequisite for the coming examples later on in this README file.

var err error
termSignal := make(chan os.Signal, 1)
signal.Notify(termSignal, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)

sess, err := disgord.NewSession(&disgord.Config{
  Token: os.Getenv("DISGORD_TOKEN"),
})
if err != nil {
    panic(err)
}

Listening for events can be done in two ways. Firstly, the reactor pattern and secondly, a GoLang channel:

// add a event listener
sess.AddListener(event.KeyGuildCreate, func(session Session, data *event.GuildCreate) {
  guild := data.Guild
  // do something with guild
})

// or use a channel to listen for events
go func() {
    for {
        select {
        case data, alive := <- sess.Evt().GuildCreateChan():
            if !alive {
                fmt.Println("channel is dead")
                break
            }

            guild := data.Guild
            // do something with guild
        }
    }
}()

// connect to the discord gateway to receive events
err = sess.Connect()
if err != nil {
    panic(err)
}

Remember that when you call Session.Connect() it is recommended to call Session.Disconnect for a graceful shutdown and closing channels and Goroutines.

// keep the app alive until terminated
<-termSignal
sess.Disconnect()

To retrieve information from the Discord REST API you utilize the Session interface as it will in the future implement features such as caching, control checks, etc

// retrieve a specific user from the Discord API
var user *resource.User
userID := NewSnowflake(228846961774559232)
user, err = session.GetUser(userID) // will do a cache lookup in the future
if err != nil {
   panic(err)
}

However, if you think the Session interface is incorrect (outdated cache, or another issue) you can bypass the interface and call the REST method directly while you wait for a patch:

// bypassing the cache
user, err = rest.GetUser(session.Req(), userID)
if err != nil {
   panic(err)
}

There's also another way to retrieve content: channels. These methods will return a GoLang channel to help with concurrency. However, their implementation is down prioritized and I recommend using the normal REST methods for now. (Currently only the Session.User method is working, and might be temporary deprecated).

// eg. retrieve a specific user from the Discord API using GoLang channels
userResponse := <- sess.UserChan(userID) // sends a request to discord
userResponse2 := <- sess.UserChan(userID) // does a cache look up, to prevent rate limiting/banning

// check if there was an issue (eg. rate limited or not found)
if userResponse.Err != nil {
    panic(userResponse.Err)
}

// check if this is retrieved from the cache
if userResponse.Cache {
    // ...
}

// get the user info
user := userResponse.User

Q&A

1. Reason for making another Discord lib in GoLang?

I'm trying to take over the world and then become a intergalactic war lord. Have to start somewhere.

Thanks to

Documentation

Overview

Package disgord GoLang module for interacting with the Discord API

Index

Constants

View Source
const (
	// JSONEncoding const for JSON encoding type
	JSONEncoding = "json"

	// APIVersion desired API version to use
	APIVersion = 6 // February 5, 2018
	// DefaultAPIVersion the default Discord API version
	DefaultAPIVersion = 6

	// GitHubURL complete url for this project
	GitHubURL = "https://github.com/andersfylling/disgord"
)
View Source
const (
	AuditLogEvtGuildUpdate      = 1
	AuditLogEvtChannelCreate    = 10
	AuditLogEvtChannelUpdate    = 11
	AuditLogEvtChannelDelete    = 12
	AuditLogEvtOverwriteCreate  = 13
	AuditLogEvtOverwriteUpdate  = 14
	AuditLogEvtOverwriteDelete  = 15
	AuditLogEvtMemberKick       = 20
	AuditLogEvtMemberPrune      = 21
	AuditLogEvtMemberBanAdd     = 22
	AuditLogEvtMemberBanRemove  = 23
	AuditLogEvtMemberUpdate     = 24
	AuditLogEvtMemberRoleUpdate = 25
	AuditLogEvtRoleCreate       = 30
	AuditLogEvtRoleUpdate       = 31
	AuditLogEvtRoleDelete       = 32
	AuditLogEvtInviteCreate     = 40
	AuditLogEvtInviteUpdate     = 41
	AuditLogEvtInviteDelete     = 42
	AuditLogEvtWebhookCreate    = 50
	AuditLogEvtWebhookUpdate    = 51
	AuditLogEvtWebhookDelete    = 52
	AuditLogEvtEmojiCreate      = 60
	AuditLogEvtEmojiUpdate      = 61
	AuditLogEvtEmojiDelete      = 62
	AuditLogEvtMessageDelete    = 72
)
View Source
const (
	// key name,								          identifier                       changed, type,   description
	AuditLogChangeKeyName                        = "name"                          // guild	string	name changed
	AuditLogChangeKeyIconHash                    = "icon_hash"                     // guild	string	icon changed
	AuditLogChangeKeySplashHash                  = "splash_hash"                   // guild	string	invite splash page artwork changed
	AuditLogChangeKeyOwnerID                     = "owner_id"                      // guild	snowflake	owner changed
	AuditLogChangeKeyRegion                      = "region"                        // guild	string	region changed
	AuditLogChangeKeyAFKChannelID                = "afk_channel_id"                // guild	snowflake	afk channel changed
	AuditLogChangeKeyAFKTimeout                  = "afk_timeout"                   // guild	integer	afk timeout duration changed
	AuditLogChangeKeyMFALevel                    = "mfa_level"                     // guild	integer	two-factor auth requirement changed
	AuditLogChangeKeyVerificationLevel           = "verification_level"            // guild	integer	required verification level changed
	AuditLogChangeKeyExplicitContentFilter       = "explicit_content_filter"       // guild	integer	change in whose messages are scanned and deleted for explicit content in the server
	AuditLogChangeKeyDefaultMessageNotifications = "default_message_notifications" // guild	integer	default message notification level changed
	AuditLogChangeKeyVanityURLCode               = "vanity_url_code"               // guild	string	guild invite vanity url changed
	AuditLogChangeKeyAdd                         = "$add"                          // add	guild	array of role objects	new role added
	AuditLogChangeKeyRemove                      = "$remove"                       // remove	guild	array of role objects	role removed
	AuditLogChangeKeyPruneDeleteDays             = "prune_delete_days"             // guild	integer	change in number of days after which inactive and role-unassigned members are kicked
	AuditLogChangeKeyWidgetEnabled               = "widget_enabled"                // guild	bool	server widget enabled/disable
	AuditLogChangeKeyWidgetChannelID             = "widget_channel_id"             // guild	snowflake	channel id of the server widget changed
	AuditLogChangeKeyPosition                    = "position"                      // channel	integer	text or voice channel position changed
	AuditLogChangeKeyTopic                       = "topic"                         // channel	string	text channel topic changed
	AuditLogChangeKeyBitrate                     = "bitrate"                       // channel	integer	voice channel bitrate changed
	AuditLogChangeKeyPermissionOverwrites        = "permission_overwrites"         // channel	array of channel overwrite objects	permissions on a channel changed
	AuditLogChangeKeyNSFW                        = "nsfw"                          // channel	bool	channel nsfw restriction changed
	AuditLogChangeKeyApplicationID               = "application_id"                // channel	snowflake	application id of the added or removed webhook or bot
	AuditLogChangeKeyPermissions                 = "permissions"                   // role	integer	permissions for a role changed
	AuditLogChangeKeyColor                       = "color"                         // role	integer	role color changed
	AuditLogChangeKeyHoist                       = "hoist"                         // role	bool	role is now displayed/no longer displayed separate from online users
	AuditLogChangeKeyMentionable                 = "mentionable"                   // role	bool	role is now mentionable/unmentionable
	AuditLogChangeKeyAllow                       = "allow"                         // role	integer	a permission on a text or voice channel was allowed for a role
	AuditLogChangeKeyDeny                        = "deny"                          // role	integer	a permission on a text or voice channel was denied for a role
	AuditLogChangeKeyCode                        = "code"                          // invite	string	invite code changed
	AuditLogChangeKeyChannelID                   = "channel_id"                    // invite	snowflake	channel for invite code changed
	AuditLogChangeKeyInviterID                   = "inviter_id"                    // invite	snowflake	person who created invite code changed
	AuditLogChangeKeyMaxUses                     = "max_uses"                      // invite	integer	change to max number of times invite code can be used
	AuditLogChangeKeyUses                        = "uses"                          // invite	integer	number of times invite code used changed
	AuditLogChangeKeyMaxAge                      = "max_age"                       // invite	integer	how long invite code lasts changed
	AuditLogChangeKeyTemporary                   = "temporary"                     // invite	bool	invite code is temporary/never expires
	AuditLogChangeKeyDeaf                        = "deaf"                          // user	bool	user server deafened/undeafened
	AuditLogChangeKeyMute                        = "mute"                          // user	bool	user server muted/unmuteds
	AuditLogChangeKeyNick                        = "nick"                          // user	string	user nickname changed
	AuditLogChangeKeyAvatarHash                  = "avatar_hash"                   // user	string	user avatar changed
	AuditLogChangeKeyID                          = "id"                            // any	snowflake	the id of the changed entity - sometimes used in conjunction with other keys
	AuditLogChangeKeyType                        = "type"                          // any	integer (channel type) or string	type of entity created
)
View Source
const (
	// Channel types
	// https://discordapp.com/developers/docs/resources/channel#channel-object-channel-types
	ChannelTypeGuildText uint = iota
	ChannelTypeDM
	ChannelTypeGuildVoice
	ChannelTypeGroupDM
	ChannelTypeGuildCategory
)
View Source
const (
	MessageActivityTypeJoin
	MessageActivityTypeSpectate
	MessageActivityTypeListen
	MessageActivityTypeJoinRequest
)
View Source
const (
	MessageTypeDefault = iota
	MessageTypeRecipientAdd
	MessageTypeRecipientRemove
	MessageTypeCall
	MessageTypeChannelNameChange
	MessageTypeChannelIconChange
	MessageTypeChannelPinnedMessage
	MessageTypeGuildMemberJoin
)
View Source
const (
	ReadMessagesPermission = 1 << (iota + 10)
	SendMessagesPermission
	SendTTSMessagesPermission
	ManageMessagesPermission
	EmbedLinksPermission
	AttachFilesPermission
	ReadMessageHistoryPermission
	MentionEveryonePermission
	UseExternalEmojisPermission
)

Constants for the different bit offsets of text channel permissions

View Source
const (
	VoiceConnectPermission = 1 << (iota + 20)
	VoiceSpeakPermission
	VoiceMuteMembersPermission
	VoiceDeafenMembersPermission
	VoiceMoveMembersPermission
	VoiceUseVADPermission
)

Constants for the different bit offsets of voice permissions

View Source
const (
	ChangeNicknamePermission = 1 << (iota + 26)
	ManageNicknamesPermission
	ManageRolesPermission
	ManageWebhooksPermission
	ManageEmojisPermission
)

Constants for general management.

Constants for the different bit offsets of general permissions

View Source
const (
	// StatusIdle presence status for idle
	StatusIdle = "idle"
	// StatusDnd presence status for dnd
	StatusDnd = "dnd"
	// StatusOnline presence status for online
	StatusOnline = "online"
	// StatusOffline presence status for offline
	StatusOffline = "offline"
)
View Source
const (
	EndpointGuild = "/guilds/"
)
View Source
const EventAllEvents = "GOD_DAMN_EVERYTHING"

EventAllEvents keys that does not fit within one of the existing files goes here

View Source
const EventChannelCreate = "CHANNEL_CREATE"

EventChannelCreate 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 EventChannelDelete = "CHANNEL_DELETE"

EventChannelDelete Sent when a channel relevant to the current user is deleted.

The inner payload is a DM or Guild channel object.
View Source
const EventChannelPinsUpdate = "CHANNEL_PINS_UPDATE"

EventChannelPinsUpdate Sent when a message is pinned or unpinned in a text

channel. This is not sent when a pinned message is
deleted.
Fields:
* ChannelID int64 or discord.Snowflake
* LastPinTimestamp time.Now().UTC().Format(time.RFC3339)

TODO fix.

View Source
const EventChannelUpdate = "CHANNEL_UPDATE"

EventChannelUpdate Sent when a channel is updated. The inner payload is a guild

channel object.
View Source
const EventGuildBanAdd = "GUILD_BAN_ADD"

EventGuildBanAdd 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 EventGuildBanRemove = "GUILD_BAN_REMOVE"

EventGuildBanRemove 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 EventGuildCreate = "GUILD_CREATE"

EventGuildCreate 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. The inner payload is a guild object, with all the extra fields specified.
View Source
const EventGuildDelete = "GUILD_DELETE"

EventGuildDelete Sent when a guild becomes unavailable during a guild outage,

or when the user leaves or is removed from a guild. The inner
payload is an unavailable guild object. If the unavailable
field is not set, the user was removed from the guild.
View Source
const EventGuildEmojisUpdate = "GUILD_EMOJI_UPDATE"

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

Fields:
* GuildID int64 or discord.Snowflake
View Source
const EventGuildIntegrationsUpdate = "GUILD_INTEGRATIONS_UPDATE"

EventGuildIntegrationsUpdate Sent when a guild integration is updated.

Fields:
* GuildID int64 or discord.Snowflake
* Emojis []*discord.emoji.Emoji
View Source
const EventGuildMemberAdd = "GUILD_MEMBER_ADD"

EventGuildMemberAdd Sent when a new user joins a guild. The inner payload is a

guild member object with these extra fields:
* GuildID int64 or discord.Snowflake
View Source
const EventGuildMemberRemove = "GUILD_MEMBER_REMOVE"

EventGuildMemberRemove Sent when a user is removed from a guild

(leave/kick/ban).
Fields:
* GuildID int64 or discord.Snowflake
* User *discord.user.User
View Source
const EventGuildMemberUpdate = "GUILD_MEMBER_UPDATE"

EventGuildMemberUpdate Sent when a guild member is updated.

Fields:
* GuildID int64 or discord.Snowflake
* Roles []int64 or []discord.Snowflake
* User *discord.user.User
* Nick string
View Source
const EventGuildMembersChunk = "GUILD_MEMBER_CHUNK"

EventGuildMemberChunk Sent in response to Gateway Request Guild Members.

Fields:
* GuildID int64 or discord.Snowflake
* Members []*discord.member.Member
View Source
const EventGuildRoleCreate = "GUILD_ROLE_CREATE"

EventGuildRoleCreate Sent when a guild role is created.

Fields:
* GuildID int64 or discord.Snowflake
* Role *discord.role.Role
View Source
const EventGuildRoleDelete = "GUILD_ROLE_DELETE"

EventGuildRoleDelete Sent when a guild role is created.

Fields:
* GuildID int64 or discord.Snowflake
* RoleID  int64 or discord.Snowflake
View Source
const EventGuildRoleUpdate = "GUILD_ROLE_UPDATE"

EventGuildRoleUpdate Sent when a guild role is created.

Fields:
* GuildID int64 or discord.Snowflake
* Role    *discord.role.Role
View Source
const EventGuildUpdate = "GUILD_UPDATE"

EventGuildUpdate Sent when a guild is updated. The inner payload is a guild

object.
View Source
const EventMessageCreate = "MESSAGE_CREATE"

EventMessageCreate Sent when a message is created. The inner payload is a

message object.
View Source
const EventMessageDelete = "MESSAGE_DELETE"

EventMessageDelete Sent when a message is deleted.

Fields:
* ID        int64 or discord.Snowflake
* ChannelID int64 or discord.Snowflake
View Source
const EventMessageDeleteBulk = "MESSAGE_DELETE_BULK"

EventMessageDeleteBulk Sent when multiple messages are deleted at once.

Fields:
* IDs       []int64 or []discord.Snowflake
* ChannelID int64 or discord.Snowflake
View Source
const EventMessageReactionAdd = "MESSAGE_REACTION_ADD"

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

Fields:
* UserID     int64 or discord.Snowflake
* ChannelID  int64 or discord.Snowflake
* MessageID  int64 or discord.Snowflake
* Emoji      *discord.emoji.Emoji
View Source
const EventMessageReactionRemove = "MESSAGE_REACTION_REMOVE"

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

Fields:
* UserID     int64 or discord.Snowflake
* ChannelID  int64 or discord.Snowflake
* MessageID  int64 or discord.Snowflake
* Emoji      *discord.emoji.Emoji
View Source
const EventMessageReactionRemoveAll = "MESSAGE_REACTION_REMOVE_ALL"

EventMessageReactionRemoveAll Sent when a user explicitly removes all reactions

from a message.
Fields:
* ChannelID  int64 or discord.Snowflake
* MessageID  int64 or discord.Snowflake
View Source
const EventMessageUpdate = "MESSAGE_UPDATE"

EventMessageUpdate 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 EventPresenceUpdate = "PRESENCE_UPDATE"

EventPresenceUpdate A user's presence is their current state on a guild.

This event is sent when a user's presence is updated
for a guild.
Fields:
User    *discord.user.User
Roles   []*discord.role.Role
Game    *discord.game.Game
GuildID int64 or discord.Snowflake
Status  *string or *discord.presence.Status
View Source
const EventReady = "READY"

EventReady The ready event is dispatched when a client has completed the

initial handshake with the gateway (for new sessions). The ready
event can be the largest and most complex event the gateway will
send, as it contains all the state required for a client to begin
interacting with the rest of the platform.
Fields:
* V uint8
* User *discord.user.User
* PrivateChannels []*discord.channel.Private
* Guilds []*discord.guild.Unavailable
* SessionID string
* Trace []string
View Source
const EventResumed = "RESUMED"

EventResumed The resumed event is dispatched when a client has sent a resume

payload to the gateway (for resuming existing sessions).
Fields:
* Trace []string
View Source
const EventTypingStart = "TYPING_START"

EventTypingStart Sent when a user starts typing in a channel.

Fields: TODO
View Source
const EventUserUpdate = "USER_UPDATE"

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

user object.
View Source
const EventVoiceServerUpdate = "VOICE_SERVER_UPDATE"

EventVoiceServerUpdate Sent when a guild's voice server is updated. This is

sent when initially connecting to voice, and when the
current voice instance fails over to a new server.
Fields:
* Token     string or discord.Token
* ChannelID int64 or discord.Snowflake
* Endpoint  string or discord.Endpoint
View Source
const EventVoiceStateUpdate = "VOICE_STATE_UPDATE"

EventVoiceStateUpdate Sent when someone joins/leaves/moves voice channels.

Inner payload is a voice state object.
View Source
const EventWebhooksUpdate = "WEBHOOK_UPDATE"

EventWebhooksUpdate Sent when a guild channel's webhook is created, updated, or

deleted.
Fields:
* GuildID   int64 or discord.Snowflake
* ChannelID int64 or discord.Snowflake

Variables

This section is empty.

Functions

func AddGuildMemberRole added in v0.6.0

func AddGuildMemberRole(client httd.Puter, guildID, userID, roleID Snowflake) (err error)

AddGuildMemberRole [PUT] Adds a role to a guild member. Requires the 'MANAGE_ROLES' permission. Returns a 204

empty response on success. Fires a Guild Member Update Gateway event.

Endpoint /guilds/{guild.id}/members/{user.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/members TODO: I don't know if this is correct Discord documentation https://discordapp.com/developers/docs/resources/guild#add-guild-member-role Reviewed 2018-08-18 Comment -

func AddPinnedChannelMessage added in v0.6.0

func AddPinnedChannelMessage(client httd.Puter, channelID, msgID Snowflake) (err error)

AddPinnedChannelMessage [GET] Pin a message in a channel. Requires the 'MANAGE_MESSAGES' permission.

Returns a 204 empty response on success.

Endpoint /channels/{channel.id}/pins/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#add-pinned-channel-message Reviewed 2018-06-10 Comment -

func BulkDeleteMessages added in v0.6.0

func BulkDeleteMessages(client httd.Poster, chanID Snowflake, params *BulkDeleteMessagesParams) (err error)

BulkDeleteMessages [POST] 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.

Endpoint /channels/{channel.id}/messages/bulk-delete Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] TODO: is this limiter key incorrect? Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-message Reviewed 2018-06-10 Comment This endpoint will not delete messages older than 2 weeks, and will fail if

any message provided is older than that.

func CreateGuildBan added in v0.6.0

func CreateGuildBan(client httd.Puter, guildID, userID Snowflake, params *CreateGuildBanParams) (err error)

CreateGuildBan [PUT] Create a guild ban, and optionally delete previous messages sent by the banned user.

Requires the 'BAN_MEMBERS' permission. Returns a 204 empty response on success.
Fires a Guild Ban Add Gateway event.

Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-ban Reviewed 2018-08-18 Comment -

func CreateGuildIntegration added in v0.6.0

func CreateGuildIntegration(client httd.Poster, guildID Snowflake, params *CreateGuildIntegrationParams) (err error)

CreateGuildIntegration [POST] Attach an integration object from the current user to the guild. Requires

the 'MANAGE_GUILD' permission. Returns a 204 empty response on success.
Fires a Guild Integrations Update Gateway event.

Endpoint /guilds/{guild.id}/integrations Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-integration Reviewed 2018-08-18 Comment -

func DeleteAllReactions added in v0.6.0

func DeleteAllReactions(client httd.Deleter, channelID, messageID Snowflake) (err error)

DeleteAllReactions [DELETE] Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES'

permission to be present on the current user.

Endpoint /channels/{channel.id}/messages/{message.id}/reactions Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] TODO: I have no idea if this is the correct key Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-all-reactions Reviewed 2018-06-07 Comment - emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom

func DeleteChannel added in v0.6.0

func DeleteChannel(client httd.Deleter, id Snowflake) (err error)

DeleteChannel [DELETE] 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.

Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#deleteclose-channel Reviewed 2018-06-07 Comment Deleting a guild channel cannot be undone. Use this with caution, as it

is impossible to undo this action when performed on a guild channel. In
contrast, when used with a private message, it is possible to undo the
action by opening a private message with the recipient again.

func DeleteChannelPermission added in v0.6.0

func DeleteChannelPermission(client httd.Deleter, channelID, overwriteID Snowflake) (err error)

DeleteChannelPermission [DELETE] Delete a channel permission overwrite for a user or role in a channel.

Only usable for guild channels. Requires the 'MANAGE_ROLES' permission.
Returns a 204 empty response on success. For more information about
permissions, see permissions:
https://discordapp.com/developers/docs/topics/permissions#permissions

Endpoint /channels/{channel.id}/permissions/{overwrite.id} Rate limiter [MAJOR] /channels/{channel.id}/permissions Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-channel-permission Reviewed 2018-06-07 Comment -

func DeleteGuild added in v0.6.0

func DeleteGuild(client httd.Deleter, id Snowflake) (err error)

DeleteGuild [DELETE] Delete a guild permanently. User must be owner. Returns 204 No Content on success.

Fires a Guild Delete Gateway event.

Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild Reviewed 2018-08-17 Comment -

func DeleteGuildEmoji added in v0.6.0

func DeleteGuildEmoji(client httd.Deleter, guildID, emojiID Snowflake) (err error)

DeleteGuildEmoji [DELETE] Delete the given emoji. Requires the

'MANAGE_EMOJIS' permission. Returns 204
No Content on success. Fires a Guild Emojis
Update Gateway event.

Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#delete-guild-emoji Reviewed 2018-06-10 Comment -

func DeleteGuildIntegration added in v0.6.0

func DeleteGuildIntegration(client httd.Deleter, guildID, integrationID Snowflake) (err error)

DeleteGuildIntegration [DELETE] Delete the attached integration object for the guild.

Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success.
Fires a Guild Integrations Update Gateway event.

Endpoint /guilds/{guild.id}/integrations/{integration.id} Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild-integration Reviewed 2018-08-18 Comment -

func DeleteGuildRole added in v0.6.0

func DeleteGuildRole(client httd.Deleter, guildID, roleID Snowflake) (err error)

DeleteGuildRole [DELETE] Delete a guild role. Requires the 'MANAGE_ROLES' permission. Returns a 204 empty

response on success. Fires a Guild Role Delete Gateway event.

Endpoint /guilds/{guild.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#delete-guild-role Reviewed 2018-08-18 Comment -

func DeleteMessage added in v0.6.0

func DeleteMessage(client httd.Deleter, channelID, msgID Snowflake) (err error)

DeleteMessage [DELETE] Delete a message. If operating on a guild channel and trying to delete a

message that was not sent by the current user, this endpoint requires the
'MANAGE_MESSAGES' permission. Returns a 204 empty response on success.
Fires a Message Delete Gateway event.

Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-message Reviewed 2018-06-10 Comment -

func DeleteOwnReaction added in v0.6.0

func DeleteOwnReaction(client httd.Deleter, channelID, messageID Snowflake, emoji interface{}) (err error)

DeleteOwnReaction [DELETE] Delete a reaction the current user has made for the message. Returns a 204

empty response on success.

Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] TODO: I have no idea what the key is Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-own-reaction Reviewed 2018-06-07 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom

func DeletePinnedChannelMessage added in v0.6.0

func DeletePinnedChannelMessage(client httd.Deleter, channelID, msgID Snowflake) (err error)

DeletePinnedChannelMessage [DELETE] Delete a pinned message in a channel. Requires the 'MANAGE_MESSAGES'

permission. Returns a 204 empty response on success.
Returns a 204 empty response on success.

Endpoint /channels/{channel.id}/pins/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-pinned-channel-message Reviewed 2018-06-10 Comment -

func DeleteUserReaction added in v0.6.0

func DeleteUserReaction(client httd.Deleter, channelID, messageID, userID Snowflake, emoji interface{}) (err error)

DeleteUserReaction [DELETE] 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.

Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages [DELETE] TODO: I have no idea if this is the correct key Discord documentation https://discordapp.com/developers/docs/resources/channel#delete-user-reaction Reviewed 2018-06-07 Comment emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom

func DeleteWebhook added in v0.6.0

func DeleteWebhook(client httd.Deleter, webhookID Snowflake) (err error)

DeleteWebhook [DELETE] Delete a webhook permanently. User must be owner. Returns a 204 NO CONTENT response

on success.

Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#delete-webhook Reviewed 2018-08-14 Comment -

func DeleteWebhookWithToken added in v0.6.0

func DeleteWebhookWithToken(client httd.Deleter, id Snowflake, token string) (err error)

DeleteWebhookWithToken [DELETE] Same as DeleteWebhook, except this call does not require authentication. Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#delete-webhook-with-token Reviewed 2018-08-14 Comment -

func EditChannelPermissions added in v0.6.0

func EditChannelPermissions(client httd.Puter, chanID, overwriteID Snowflake, params *EditChannelPermissionsParams) (err error)

EditChannelPermissions [PUT] 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.

Endpoint /channels/{channel.id}/permissions/{overwrite.id} Rate limiter [MAJOR] /channels/{channel.id}/permissions Discord documentation https://discordapp.com/developers/docs/resources/channel#edit-channel-permissions Reviewed 2018-06-07 Comment -

func ExecuteGitHubWebhook added in v0.6.0

func ExecuteGitHubWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)

ExecuteGitHubWebhook [POST] Trigger a webhook in Discord from the GitHub app. Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-githubcompatible-webhook Reviewed 2018-08-14 Comment Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint.

as the "Payload URL." You can choose what events your Discord channel receives by
choosing the "Let me select individual events" option and selecting individual
events for the new webhook you're configuring.

func ExecuteSlackWebhook added in v0.6.0

func ExecuteSlackWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool) (err error)

ExecuteSlackWebhook [POST] Trigger a webhook in Discord from the Slack app. Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-slackcompatible-webhook Reviewed 2018-08-14 Comment Refer to Slack's documentation for more information. We do not support Slack's channel,

icon_emoji, mrkdwn, or mrkdwn_in properties.

func ExecuteWebhook added in v0.6.0

func ExecuteWebhook(client httd.Poster, params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error)

ExecuteWebhook [POST] Trigger a webhook in Discord. Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#execute-webhook Reviewed 2018-08-14 Comment This endpoint. supports both JSON and form data bodies. It does require

multipart/form-data requests instead of the normal JSON request type when
uploading files. Make sure you set your Content-Type to multipart/form-data if
you're doing that. Note that in that case, the embeds field cannot be used, but
you can pass an url-encoded JSON body as a form value for payload_json.

Comment#2 For the webhook embed objects, you can set every field except type (it will be

rich regardless of if you try to set it), provider, video, and any height, width,
or proxy_url values for images.

TODO

func GroupDMAddRecipient added in v0.6.0

func GroupDMAddRecipient(client httd.Puter, channelID, userID Snowflake, params *GroupDMAddRecipientParams) (err error)

GroupDMAddRecipient [PUT] Adds a recipient to a Group DM using their access token.

Returns a 204 empty response on success.

Endpoint /channels/{channel.id}/recipients/{user.id} Rate limiter [MAJOR] /channels/{channel.id}/recipients Discord documentation https://discordapp.com/developers/docs/resources/channel#group-dm-add-recipient Reviewed 2018-06-10 Comment -

func GroupDMRemoveRecipient added in v0.6.0

func GroupDMRemoveRecipient(client httd.Deleter, channelID, userID Snowflake) (err error)

GroupDMRemoveRecipient [DELETE] Removes a recipient from a Group DM. Returns a 204 empty response on success. Endpoint /channels/{channel.id}/recipients/{user.id} Rate limiter [MAJOR] /channels/{channel.id}/recipients Discord documentation https://discordapp.com/developers/docs/resources/channel#group-dm-remove-recipient Reviewed 2018-06-10 Comment -

func LeaveGuild added in v0.6.0

func LeaveGuild(client httd.Deleter, id Snowflake) (err error)

LeaveGuild [DELETE] Leave a guild. Returns a 204 empty response on success. Endpoint /users/@me/guilds/{guild.id} Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#leave-guild Reviewed 2018-06-10 Comment -

func LibraryInfo added in v0.4.0

func LibraryInfo() string

LibraryInfo returns name + version

func ModifyCurrentUserNick added in v0.6.0

func ModifyCurrentUserNick(client httd.Patcher, id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error)

ModifyCurrentUserNick [PATCH] Modifies the nickname of the current user in a guild. Returns a 200 with the

nickname on success. Fires a Guild Member Update Gateway event.

Endpoint /guilds/{guild.id}/members/@me/nick Rate limiter /guilds/{guild.id}/members TODO: I don't know if this is correct Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-current-user-nick Reviewed 2018-08-18 Comment -

func ModifyGuildIntegration added in v0.6.0

func ModifyGuildIntegration(client httd.Patcher, guildID, integrationID Snowflake, params *ModifyGuildIntegrationParams) (err error)

ModifyGuildIntegration [POST] Modify the behavior and settings of a integration object for the guild.

Requires the 'MANAGE_GUILD' permission. Returns a 204 empty response on success.
Fires a Guild Integrations Update Gateway event.

Endpoint /guilds/{guild.id}/integrations/{integration.id} Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-integration Reviewed 2018-08-18 Comment -

func ModifyGuildMember added in v0.6.0

func ModifyGuildMember(client httd.Patcher, guildID, userID Snowflake, params *ModifyGuildMemberParams) (err error)

ModifyGuildMember [PATCH] Modify attributes of a guild member. Returns a 204 empty response on success.

Fires a Guild Member Update Gateway event.

Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-member Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional. When moving members to channels,

the API user must have permissions to both connect to the channel and have the
MOVE_MEMBERS permission.

func RemoveGuildBan added in v0.6.0

func RemoveGuildBan(client httd.Deleter, guildID, userID Snowflake) (err error)

RemoveGuildBan [DELETE] Remove the ban for a user. Requires the 'BAN_MEMBERS' permissions.

Returns a 204 empty response on success. Fires a Guild Ban Remove Gateway event.

Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-ban Reviewed 2018-08-18 Comment -

func RemoveGuildMember added in v0.6.0

func RemoveGuildMember(client httd.Deleter, guildID, userID Snowflake) (err error)

RemoveGuildMember [DELETE] Remove a member from a guild. Requires 'KICK_MEMBERS' permission. Returns a 204

empty response on success. Fires a Guild Member Remove Gateway event.

Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-member Reviewed 2018-08-18 Comment -

func RemoveGuildMemberRole added in v0.6.0

func RemoveGuildMemberRole(client httd.Deleter, guildID, userID, roleID Snowflake) (err error)

RemoveGuildMemberRole [DELETE] Removes a role from a guild member. Requires the 'MANAGE_ROLES' permission. Returns

a 204 empty response on success. Fires a Guild Member Update Gateway event.

Endpoint /guilds/{guild.id}/members/{user.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#remove-guild-member-role Reviewed 2018-08-18 Comment -

func SyncGuildIntegration added in v0.6.0

func SyncGuildIntegration(client httd.Poster, guildID, integrationID Snowflake) (err error)

SyncGuildIntegration [POST] Sync an integration. Requires the 'MANAGE_GUILD' permission.

Returns a 204 empty response on success.

Endpoint /guilds/{guild.id}/integrations/{integration.id}/sync Rate limiter /guilds/{guild.id}/integrations TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/guild#sync-guild-integration Reviewed 2018-08-18 Comment -

func TriggerTypingIndicator added in v0.6.0

func TriggerTypingIndicator(client httd.Poster, channelID Snowflake) (err error)

TriggerTypingIndicator [POST] 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.

Endpoint /channels/{channel.id}/typing Rate limiter [MAJOR] /channels/{channel.id}/typing Discord documentation https://discordapp.com/developers/docs/resources/channel#trigger-typing-indicator Reviewed 2018-06-10 Comment -

Types

type AddGuildMemberParams added in v0.6.0

type AddGuildMemberParams struct {
	AccessToken string      `json:"access_token"`
	Nick        string      `json:"nick,omitempty"`
	Roles       []Snowflake `json:"roles"`
	Mute        bool        `json:"mute"`
	Deaf        bool        `json:"deaf"`
}

AddGuildMemberParams https://discordapp.com/developers/docs/resources/guild#add-guild-member-json-params

type Attachment added in v0.6.0

type Attachment struct {
	ID       Snowflake `json:"id"`
	Filename string    `json:"filename"`
	Size     uint      `json:"size"`
	URL      string    `json:"url"`
	ProxyURL string    `json:"proxy_url"`
	Height   uint      `json:"height"`
	Width    uint      `json:"width"`
}

Attachment https://discordapp.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"`
}

func GuildAuditLogs added in v0.6.0

func GuildAuditLogs(client httd.Getter, guildID Snowflake, params *GuildAuditLogsParams) (log *AuditLog, err error)

GuildAuditLogs [GET] Returns an audit log object for the guild.

Requires the 'VIEW_AUDIT_LOG' permission.

Endpoint /guilds/{guild.id}/audit-logs Rate limiter [MAJOR] /guilds/{guild.id}/audit-logs Discord documentation https://discordapp.com/developers/docs/resources/audit-log#get-guild-audit-log Reviewed 2018-06-05 Comment -

type AuditLogChange added in v0.6.0

type AuditLogChange struct {
	NewValue interface{} `json:"new_value,omitempty"`
	OldValue interface{} `json:"old_value,omitempty"`
	Key      string      `json:"key"`
}

type AuditLogEntry added in v0.6.0

type AuditLogEntry struct {
	TargetID   Snowflake         `json:"target_id"`
	Changes    []*AuditLogChange `json:"changes,omitempty"`
	UserID     Snowflake         `json:"user_id"`
	ID         Snowflake         `json:"id"`
	ActionType uint              `json:"action_type"`
	Options    []*AuditLogOption `json:"options,omitempty"`
	Reason     string            `json:"reason,omitempty"`
}

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"`
}

type Ban added in v0.6.0

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

-------------- Ban https://discordapp.com/developers/docs/resources/guild#ban-object

func GetGuildBan added in v0.6.0

func GetGuildBan(client httd.Getter, guildID, userID Snowflake) (ret *Ban, err error)

GetGuildBan [GET] Returns a ban object for the given user or a 404 not found if the ban cannot be found.

Requires the 'BAN_MEMBERS' permission.

Endpoint /guilds/{guild.id}/bans/{user.id} Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-ban Reviewed 2018-08-18 Comment -

func GetGuildBans added in v0.6.0

func GetGuildBans(client httd.Getter, id Snowflake) (ret []*Ban, err error)

GetGuildBans [GET] Returns a list of ban objects for the users banned from this guild.

Requires the 'BAN_MEMBERS' permission.

Endpoint /guilds/{guild.id}/bans Rate limiter /guilds/{guild.id}/bans Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-bans Reviewed 2018-08-18 Comment -

type BodyUserCreateDM added in v0.6.0

type BodyUserCreateDM struct {
	RecipientID Snowflake `json:"recipient_id"`
}

BodyUserCreateDM JSON param for func CreateDM

type BulkDeleteMessagesParams added in v0.6.0

type BulkDeleteMessagesParams struct {
	Messages []Snowflake `json:"messages"`
	// contains filtered or unexported fields
}

BulkDeleteMessagesParams https://discordapp.com/developers/docs/resources/channel#bulk-delete-messages-json-params

func (*BulkDeleteMessagesParams) AddMessage added in v0.6.0

func (p *BulkDeleteMessagesParams) AddMessage(msg *Message) (err error)

AddMessage Adds a message to be deleted

func (*BulkDeleteMessagesParams) Valid added in v0.6.0

func (p *BulkDeleteMessagesParams) Valid() (err error)

Valid validates the BulkDeleteMessagesParams data

type Cache added in v0.6.0

type Cache struct{}

func NewCache added in v0.6.0

func NewCache() *Cache

type Cacher added in v0.6.0

type Cacher interface{}

type Channel added in v0.6.0

type Channel struct {
	ID                   Snowflake             `json:"id"`
	Type                 uint                  `json:"type"`
	GuildID              Snowflake             `json:"guild_id,omitempty"`              // ?|
	Position             uint                  `json:"position,omitempty"`              // ?|
	PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"` // ?|
	Name                 string                `json:"name,omitempty"`                  // ?|
	Topic                string                `json:"topic,omitempty"`                 // ?|
	NSFW                 bool                  `json:"nsfw,omitempty"`                  // ?|
	LastMessageID        Snowflake             `json:"last_message_id,omitempty"`       // ?|?, pointer
	Bitrate              uint                  `json:"bitrate,omitempty"`               // ?|
	UserLimit            uint                  `json:"user_limit,omitempty"`            // ?|
	Recipients           []*User               `json:"recipient,omitempty"`             // ?| , empty if not DM
	Icon                 string                `json:"icon,omitempty"`                  // ?|?, pointer
	OwnerID              Snowflake             `json:"owner_id,omitempty"`              // ?|
	ApplicationID        Snowflake             `json:"application_id,omitempty"`        // ?|
	ParentID             Snowflake             `json:"parent_id,omitempty"`             // ?|?, pointer
	LastPingTimestamp    Timestamp             `json:"last_ping_timestamp,omitempty"`   // ?|

	sync.RWMutex
}

Channel

func CreateDM added in v0.6.0

func CreateDM(client httd.Poster, recipientID Snowflake) (ret *Channel, err error)

CreateDM [POST] Create a new DM channel with a user. Returns a DM channel object. Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#create-dm Reviewed 2018-06-10 Comment - TODO: review

func CreateGroupDM added in v0.6.0

func CreateGroupDM(client httd.Poster, params *CreateGroupDMParams) (ret *Channel, err error)

CreateGroupDM [POST] Create a new group DM channel with multiple users. Returns a DM channel object. Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#create-group-dm Reviewed 2018-06-10 Comment -

func CreateGuildChannel added in v0.6.0

func CreateGuildChannel(client httd.Poster, id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error)

CreateGuildChannel [POST] Create a new channel object for the guild. Requires the 'MANAGE_CHANNELS' permission.

Returns the new channel object on success. Fires a Channel Create Gateway event.

Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-channel Reviewed 2018-08-17 Comment All parameters for this endpoint. are optional excluding 'name'

func GetChannel added in v0.6.0

func GetChannel(client httd.Getter, id Snowflake) (ret *Channel, err error)

GetChannel [GET] Get a channel by Snowflake. Returns a channel object. Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel Reviewed 2018-06-07 Comment -

func GetGuildChannels added in v0.6.0

func GetGuildChannels(client httd.Getter, id Snowflake) (ret []*Channel, err error)

GetGuildChannels [GET] Returns a list of guild channel objects. Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-channels Reviewed 2018-08-17 Comment -

func GetUserDMs added in v0.6.0

func GetUserDMs(client httd.Getter) (ret []*Channel, err error)

GetUserDMs [GET] Returns a list of DM channel objects. Endpoint /users/@me/channels Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-user-dms Reviewed 2018-06-10 Comment -

func ModifyChannel added in v0.6.0

func ModifyChannel(client httd.Patcher, changes *ModifyChannelParams) (ret *Channel, err error)

ModifyChannel PUT/PATCH 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.

Endpoint /channels/{channel.id} Rate limiter [MAJOR] /channels/{channel.id} Discord documentation https://discordapp.com/developers/docs/resources/channel#modify-channel Reviewed 2018-06-07 Comment andersfylling: only implemented the patch method, as its parameters are optional.

func NewChannel added in v0.6.0

func NewChannel() *Channel

func (*Channel) Clear added in v0.6.0

func (c *Channel) Clear()

func (*Channel) Compare added in v0.6.0

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

func (*Channel) Create added in v0.6.0

func (c *Channel) Create()

func (*Channel) DeepCopy added in v0.6.0

func (c *Channel) DeepCopy() *Channel

func (*Channel) Delete added in v0.6.0

func (c *Channel) Delete(client ChannelDeleter) (err error)

Delete sends a Discord REST request to delete the related channel

func (*Channel) Mention added in v0.6.0

func (c *Channel) Mention() string

func (*Channel) Replicate added in v0.6.0

func (c *Channel) Replicate(channel *Channel, recipients []*User)

func (*Channel) SendMsg added in v0.6.0

func (c *Channel) SendMsg(client MessageSender, message *Message) (msg *Message, err error)

func (*Channel) SendMsgString added in v0.6.0

func (c *Channel) SendMsgString(client MessageSender, content string) (msg *Message, err error)

func (*Channel) Update added in v0.6.0

func (c *Channel) Update(client ChannelUpdater)

Update send channel changes to the Discord API

type ChannelCreate added in v0.6.0

type ChannelCreate struct {
	Channel *Channel        `json:"channel"`
	Ctx     context.Context `json:"-"`
}

ChannelCreateBox new channel created

type ChannelCreateCallback

type ChannelCreateCallback = func(session Session, cc *ChannelCreate)

ChannelCreateCallback triggered on CHANNEL_CREATE events

type ChannelDelete added in v0.6.0

type ChannelDelete struct {
	Channel *Channel        `json:"channel"`
	Ctx     context.Context `json:"-"`
}

ChannelDelete channel was deleted

type ChannelDeleteCallback

type ChannelDeleteCallback = func(session Session, cd *ChannelDelete)

ChannelDeleteCallback triggered on CHANNEL_DELETE events

type ChannelDeleter added in v0.6.0

type ChannelDeleter interface {
	DeleteChannel(id Snowflake) (err error)
}

type ChannelEmbed added in v0.6.0

type ChannelEmbed struct {
	Title       string                 `json:"title"`       // title of embed
	Type        string                 `json:"type"`        // type of embed (always "rich" for webhook embeds)
	Description string                 `json:"description"` // description of embed
	URL         string                 `json:"url"`         // url of embed
	Timestamp   time.Time              `json:"timestamp"`   // timestamp	timestamp of embed content
	Color       int                    `json:"color"`       // color code of the embed
	Footer      *ChannelEmbedFooter    `json:"footer"`      // embed footer object	footer information
	Image       *ChannelEmbedImage     `json:"image"`       // embed image object	image information
	Thumbnail   *ChannelEmbedThumbnail `json:"thumbnail"`   // embed thumbnail object	thumbnail information
	Video       *ChannelEmbedVideo     `json:"video"`       // embed video object	video information
	Provider    *ChannelEmbedProvider  `json:"provider"`    // embed provider object	provider information
	Author      *ChannelEmbedAuthor    `json:"author"`      // embed author object	author information
	Fields      []*ChannelEmbedField   `json:"fields"`      //	array of embed field objects	fields information
}

ChannelEmbed https://discordapp.com/developers/docs/resources/channel#embed-object

type ChannelEmbedAuthor added in v0.6.0

type ChannelEmbedAuthor 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
}

ChannelEmbedAuthor https://discordapp.com/developers/docs/resources/channel#embed-object-embed-author-structure

type ChannelEmbedField added in v0.6.0

type ChannelEmbedField struct {
	Name   string `json:"name"`           //  | , name of the field
	Value  string `json:"value"`          //  | , value of the field
	Inline bool   `json:"bool,omitempty"` // ?| , whether or not this field should display inline
}

ChannelEmbedField https://discordapp.com/developers/docs/resources/channel#embed-object-embed-field-structure

type ChannelEmbedFooter added in v0.6.0

type ChannelEmbedFooter 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
}

ChannelEmbedFooter https://discordapp.com/developers/docs/resources/channel#embed-object-embed-footer-structure

type ChannelEmbedImage added in v0.6.0

type ChannelEmbedImage 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
}

ChannelEmbedImage https://discordapp.com/developers/docs/resources/channel#embed-object-embed-image-structure

type ChannelEmbedProvider added in v0.6.0

type ChannelEmbedProvider struct {
	Name string `json:"name,omitempty"` // ?| , name of provider
	Url  string `json:"url,omitempty"`  // ?| , url of provider
}

ChannelEmbedProvider https://discordapp.com/developers/docs/resources/channel#embed-object-embed-provider-structure

type ChannelEmbedThumbnail added in v0.6.0

type ChannelEmbedThumbnail 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
}

ChannelEmbedThumbnail https://discordapp.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure

type ChannelEmbedVideo added in v0.6.0

type ChannelEmbedVideo 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
}

ChannelEmbedVideo https://discordapp.com/developers/docs/resources/channel#embed-object-embed-video-structure

type ChannelFetcher added in v0.6.0

type ChannelFetcher interface {
	GetChannel(id Snowflake) (ret *Channel, err error)
}

type ChannelMessager added in v0.6.0

type ChannelMessager interface {
	CreateMessage(*Message) error
}

ChannelMessager Methods required to create a new DM (or use an existing one) and send a DM.

type ChannelPinsUpdate added in v0.6.0

type ChannelPinsUpdate struct {
	// ChannelID snowflake	the id of the channel
	ChannelID Snowflake `json:"channel_id"`

	// LastPinTimestamp	ISO8601 timestamp	the time at which the most recent pinned message was pinned
	LastPinTimestamp Timestamp       `json:"last_pin_timestamp,omitempty"` // ?|
	Ctx              context.Context `json:"-"`
}

ChannelPinsUpdate message was pinned or unpinned

type ChannelPinsUpdateCallback

type ChannelPinsUpdateCallback = func(session Session, cpu *ChannelPinsUpdate)

ChannelPinsUpdateCallback triggered on CHANNEL_PINS_UPDATE events

type ChannelUpdate added in v0.6.0

type ChannelUpdate struct {
	Channel *Channel        `json:"channel"`
	Ctx     context.Context `json:"-"`
}

ChannelUpdateBox channel was updated

type ChannelUpdateCallback

type ChannelUpdateCallback = func(session Session, cu *ChannelUpdate)

ChannelUpdateCallback triggered on CHANNEL_UPDATE events

type ChannelUpdater added in v0.6.0

type ChannelUpdater interface {
}

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Client is the main disgord client to hold your state and data

func NewClient

func NewClient(conf *Config) (*Client, error)

NewClient creates a new default disgord instance

func NewClientMustCompile

func NewClientMustCompile(conf *Config) *Client

NewClientMustCompile constructs a client and crash on failures

func (*Client) AddGuildMember

func (c *Client) AddGuildMember(guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error)

AddGuildMember .

func (*Client) AddGuildMemberRole

func (c *Client) AddGuildMemberRole(guildID, userID, roleID Snowflake) (err error)

AddGuildMemberRole .

func (*Client) AddListener

func (c *Client) AddListener(evtName string, listener interface{})

AddListener register a listener for a specific event key/type (see Key...)

func (*Client) AddListenerOnce

func (c *Client) AddListenerOnce(evtName string, listener interface{})

AddListenerOnce not implemented. Do not use.

func (*Client) AddPinnedChannelMessage

func (c *Client) AddPinnedChannelMessage(channelID, msgID Snowflake) (err error)

AddPinnedChannelMessage .

func (*Client) BeginGuildPrune

func (c *Client) BeginGuildPrune(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)

BeginGuildPrune .

func (*Client) BulkDeleteMessages

func (c *Client) BulkDeleteMessages(chanID Snowflake, params *BulkDeleteMessagesParams) (err error)

BulkDeleteMessages .

func (*Client) Connect

func (c *Client) Connect() (err error)

Connect establishes a websocket connection to the discord API

func (*Client) CreateChannelInvites

func (c *Client) CreateChannelInvites(id Snowflake, params *CreateChannelInvitesParams) (ret *Invite, err error)

CreateChannelInvites ...

func (*Client) CreateChannelMessage

func (c *Client) CreateChannelMessage(channelID Snowflake, params *CreateChannelMessageParams) (ret *Message, err error)

CreateChannelMessage .

func (*Client) CreateDM

func (c *Client) CreateDM(recipientID Snowflake) (ret *Channel, err error)

CreateDM .

func (*Client) CreateGroupDM

func (c *Client) CreateGroupDM(params *CreateGroupDMParams) (ret *Channel, err error)

CreateGroupDM .

func (*Client) CreateGuild

func (c *Client) CreateGuild(params *CreateGuildParams) (ret *Guild, err error)

CreateGuild .

func (*Client) CreateGuildBan

func (c *Client) CreateGuildBan(guildID, userID Snowflake, params *CreateGuildBanParams) (err error)

CreateGuildBan .

func (*Client) CreateGuildChannel

func (c *Client) CreateGuildChannel(id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error)

CreateGuildChannel .

func (*Client) CreateGuildEmoji

func (c *Client) CreateGuildEmoji(guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error)

CreateGuildEmoji .

func (*Client) CreateGuildIntegration

func (c *Client) CreateGuildIntegration(guildID Snowflake, params *CreateGuildIntegrationParams) (err error)

CreateGuildIntegration .

func (*Client) CreateGuildRole

func (c *Client) CreateGuildRole(id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error)

CreateGuildRole .

func (*Client) CreateReaction

func (c *Client) CreateReaction(channelID, messageID Snowflake, emoji interface{}) (ret *Reaction, err error)

CreateReaction .

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error)

CreateWebhook .

func (*Client) DeleteAllReactions

func (c *Client) DeleteAllReactions(channelID, messageID Snowflake) (err error)

DeleteAllReactions .

func (*Client) DeleteChannel

func (c *Client) DeleteChannel(id Snowflake) (err error)

DeleteChannel ...

func (*Client) DeleteChannelPermission

func (c *Client) DeleteChannelPermission(channelID, overwriteID Snowflake) (err error)

DeleteChannelPermission .

func (*Client) DeleteGuild

func (c *Client) DeleteGuild(id Snowflake) (err error)

DeleteGuild .

func (*Client) DeleteGuildEmoji

func (c *Client) DeleteGuildEmoji(guildID, emojiID Snowflake) (err error)

DeleteGuildEmoji .

func (*Client) DeleteGuildIntegration

func (c *Client) DeleteGuildIntegration(guildID, integrationID Snowflake) (err error)

DeleteGuildIntegration .

func (*Client) DeleteGuildRole

func (c *Client) DeleteGuildRole(guildID, roleID Snowflake) (err error)

DeleteGuildRole .

func (*Client) DeleteInvite

func (c *Client) DeleteInvite(inviteCode string) (invite *Invite, err error)

DeleteInvite .

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(channelID, msgID Snowflake) (err error)

DeleteMessage .

func (*Client) DeleteOwnReaction

func (c *Client) DeleteOwnReaction(channelID, messageID Snowflake, emoji interface{}) (err error)

DeleteOwnReaction .

func (*Client) DeletePinnedChannelMessage

func (c *Client) DeletePinnedChannelMessage(channelID, msgID Snowflake) (err error)

DeletePinnedChannelMessage .

func (*Client) DeleteUserReaction

func (c *Client) DeleteUserReaction(channelID, messageID, userID Snowflake, emoji interface{}) (err error)

DeleteUserReaction .

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(webhookID Snowflake) (err error)

DeleteWebhook .

func (*Client) DeleteWebhookWithToken

func (c *Client) DeleteWebhookWithToken(id Snowflake, token string) (err error)

DeleteWebhookWithToken .

func (*Client) Disconnect

func (c *Client) Disconnect() (err error)

Disconnect closes the discord websocket connection

func (*Client) DisconnectOnInterrupt added in v0.6.2

func (c *Client) DisconnectOnInterrupt() (err error)

DisconnectOnInterrupt wait until a termination signal is detected

func (*Client) EditChannelPermissions

func (c *Client) EditChannelPermissions(chanID, overwriteID Snowflake, params *EditChannelPermissionsParams) (err error)

EditChannelPermissions ...

func (*Client) EditMessage

func (c *Client) EditMessage(chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error)

EditMessage .

func (*Client) Evt

func (c *Client) Evt() EvtDispatcher

Evt gives access to the event dispatcher for registering handlers and utilising event channels

func (*Client) ExecuteGitHubWebhook

func (c *Client) ExecuteGitHubWebhook(params *ExecuteWebhookParams, wait bool) (err error)

ExecuteGitHubWebhook .

func (*Client) ExecuteSlackWebhook

func (c *Client) ExecuteSlackWebhook(params *ExecuteWebhookParams, wait bool) (err error)

ExecuteSlackWebhook .

func (*Client) ExecuteWebhook

func (c *Client) ExecuteWebhook(params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error)

ExecuteWebhook .

func (*Client) GetChannel

func (c *Client) GetChannel(id Snowflake) (ret *Channel, err error)

GetChannel ...

func (*Client) GetChannelInvites

func (c *Client) GetChannelInvites(id Snowflake) (ret []*Invite, err error)

GetChannelInvites ...

func (*Client) GetChannelMessage

func (c *Client) GetChannelMessage(channelID, messageID Snowflake) (ret *Message, err error)

GetChannelMessage .

func (*Client) GetChannelMessages

func (c *Client) GetChannelMessages(channelID Snowflake, params URLParameters) (ret []*Message, err error)

GetChannelMessages .

func (*Client) GetChannelWebhooks

func (c *Client) GetChannelWebhooks(channelID Snowflake) (ret []*Webhook, err error)

GetChannelWebhooks .

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser() (ret *User, err error)

GetCurrentUser .

func (*Client) GetCurrentUserGuilds

func (c *Client) GetCurrentUserGuilds(params *GetCurrentUserGuildsParams) (ret []*Guild, err error)

GetCurrentUserGuilds .

func (*Client) GetGuild

func (c *Client) GetGuild(id Snowflake) (ret *Guild, err error)

GetGuild .

func (*Client) GetGuildAuditLogs

func (c *Client) GetGuildAuditLogs(guildID Snowflake, params *GuildAuditLogsParams) (log *AuditLog, err error)

GetGuildAuditLogs ...

func (*Client) GetGuildBan

func (c *Client) GetGuildBan(guildID, userID Snowflake) (ret *Ban, err error)

GetGuildBan .

func (*Client) GetGuildBans

func (c *Client) GetGuildBans(id Snowflake) (ret []*Ban, err error)

GetGuildBans .

func (*Client) GetGuildChannels

func (c *Client) GetGuildChannels(id Snowflake) (ret []*Channel, err error)

GetGuildChannels .

func (*Client) GetGuildEmbed

func (c *Client) GetGuildEmbed(guildID Snowflake) (ret *GuildEmbed, err error)

GetGuildEmbed .

func (*Client) GetGuildEmoji

func (c *Client) GetGuildEmoji(guildID, emojiID Snowflake) (ret *Emoji, err error)

GetGuildEmoji .

func (*Client) GetGuildEmojis

func (c *Client) GetGuildEmojis(id Snowflake) (ret []*Emoji, err error)

GetGuildEmojis .

func (*Client) GetGuildIntegrations

func (c *Client) GetGuildIntegrations(id Snowflake) (ret []*Integration, err error)

GetGuildIntegrations .

func (*Client) GetGuildInvites

func (c *Client) GetGuildInvites(id Snowflake) (ret []*Invite, err error)

GetGuildInvites .

func (*Client) GetGuildMember

func (c *Client) GetGuildMember(guildID, userID Snowflake) (ret *Member, err error)

GetGuildMember .

func (*Client) GetGuildMembers

func (c *Client) GetGuildMembers(guildID, after Snowflake, limit int) (ret []*Member, err error)

GetGuildMembers .

func (*Client) GetGuildPruneCount

func (c *Client) GetGuildPruneCount(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)

GetGuildPruneCount .

func (*Client) GetGuildRoles

func (c *Client) GetGuildRoles(guildID Snowflake) (ret []*Role, err error)

GetGuildRoles .

func (*Client) GetGuildVanityURL

func (c *Client) GetGuildVanityURL(guildID Snowflake) (ret *PartialInvite, err error)

GetGuildVanityURL .

func (*Client) GetGuildVoiceRegions

func (c *Client) GetGuildVoiceRegions(id Snowflake) (ret []*VoiceRegion, err error)

GetGuildVoiceRegions .

func (*Client) GetGuildWebhooks

func (c *Client) GetGuildWebhooks(guildID Snowflake) (ret []*Webhook, err error)

GetGuildWebhooks .

func (*Client) GetInvite

func (c *Client) GetInvite(inviteCode string, withCounts bool) (invite *Invite, err error)

GetInvite .

func (*Client) GetPinnedMessages

func (c *Client) GetPinnedMessages(channelID Snowflake) (ret []*Message, err error)

GetPinnedMessages .

func (*Client) GetReaction

func (c *Client) GetReaction(channelID, messageID Snowflake, emoji interface{}, params URLParameters) (ret []*User, err error)

GetReaction .

func (*Client) GetUser

func (c *Client) GetUser(id Snowflake) (ret *User, err error)

GetUser .

func (*Client) GetUserConnections

func (c *Client) GetUserConnections() (ret []*UserConnection, err error)

GetUserConnections .

func (*Client) GetUserDMs

func (c *Client) GetUserDMs() (ret []*Channel, err error)

GetUserDMs .

func (*Client) GetVoiceRegions

func (c *Client) GetVoiceRegions() (ret []*VoiceRegion, err error)

GetVoiceRegions .

func (*Client) GetWebhook

func (c *Client) GetWebhook(id Snowflake) (ret *Webhook, err error)

GetWebhook .

func (*Client) GetWebhookWithToken

func (c *Client) GetWebhookWithToken(id Snowflake, token string) (ret *Webhook, err error)

GetWebhookWithToken .

func (*Client) GroupDMAddRecipient

func (c *Client) GroupDMAddRecipient(channelID, userID Snowflake, params *GroupDMAddRecipientParams) (err error)

GroupDMAddRecipient .

func (*Client) GroupDMRemoveRecipient

func (c *Client) GroupDMRemoveRecipient(channelID, userID Snowflake) (err error)

GroupDMRemoveRecipient .

func (*Client) LeaveGuild

func (c *Client) LeaveGuild(id Snowflake) (err error)

LeaveGuild .

func (*Client) ModifyChannel

func (c *Client) ModifyChannel(changes *ModifyChannelParams) (ret *Channel, err error)

ModifyChannel ...

func (*Client) ModifyCurrentUser

func (c *Client) ModifyCurrentUser(params *ModifyCurrentUserParams) (ret *User, err error)

ModifyCurrentUser .

func (*Client) ModifyCurrentUserNick

func (c *Client) ModifyCurrentUserNick(id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error)

ModifyCurrentUserNick .

func (*Client) ModifyGuild

func (c *Client) ModifyGuild(id Snowflake, params *ModifyGuildParams) (ret *Guild, err error)

ModifyGuild .

func (*Client) ModifyGuildEmbed

func (c *Client) ModifyGuildEmbed(guildID Snowflake, params *GuildEmbed) (ret *GuildEmbed, err error)

ModifyGuildEmbed .

func (*Client) ModifyGuildEmoji

func (c *Client) ModifyGuildEmoji(guildID, emojiID Snowflake, params *ModifyGuildEmojiParams) (ret *Emoji, err error)

ModifyGuildEmoji .

func (*Client) ModifyGuildIntegration

func (c *Client) ModifyGuildIntegration(guildID, integrationID Snowflake, params *ModifyGuildIntegrationParams) (err error)

ModifyGuildIntegration .

func (*Client) ModifyGuildMember

func (c *Client) ModifyGuildMember(guildID, userID Snowflake, params *ModifyGuildMemberParams) (err error)

ModifyGuildMember .

func (*Client) ModifyGuildRole

func (c *Client) ModifyGuildRole(guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret []*Role, err error)

ModifyGuildRole .

func (*Client) ModifyGuildRolePositions

func (c *Client) ModifyGuildRolePositions(guildID Snowflake, params *ModifyGuildRolePositionsParams) (ret []*Role, err error)

ModifyGuildRolePositions .

func (*Client) ModifyWebhook

func (c *Client) ModifyWebhook(newWebhook *Webhook) (ret *Webhook, err error)

ModifyWebhook .

func (*Client) ModifyWebhookWithToken

func (c *Client) ModifyWebhookWithToken(newWebhook *Webhook) (ret *Webhook, err error)

ModifyWebhookWithToken .

func (*Client) RateLimiter

func (c *Client) RateLimiter() httd.RateLimiter

RateLimiter return the rate limiter object

func (*Client) RemoveGuildBan

func (c *Client) RemoveGuildBan(guildID, userID Snowflake) (err error)

RemoveGuildBan .

func (*Client) RemoveGuildMember

func (c *Client) RemoveGuildMember(guildID, userID Snowflake) (err error)

RemoveGuildMember .

func (*Client) RemoveGuildMemberRole

func (c *Client) RemoveGuildMemberRole(guildID, userID, roleID Snowflake) (err error)

RemoveGuildMemberRole .

func (*Client) Req

func (c *Client) Req() httd.Requester

Req return the request object. Used in REST requests to handle rate limits, wrong http responses, etc.

func (*Client) SendMsg added in v0.4.0

func (c *Client) SendMsg(channelID Snowflake, message *Message) (msg *Message, err error)

SendMsg .

func (*Client) SendMsgString added in v0.4.0

func (c *Client) SendMsgString(channelID Snowflake, content string) (msg *Message, err error)

SendMsgString .

func (*Client) State

func (c *Client) State() Cacher

State is the cache....

func (*Client) String

func (c *Client) String() string

func (*Client) SyncGuildIntegration

func (c *Client) SyncGuildIntegration(guildID, integrationID Snowflake) (err error)

SyncGuildIntegration .

func (*Client) TriggerTypingIndicator

func (c *Client) TriggerTypingIndicator(channelID Snowflake) (err error)

TriggerTypingIndicator .

func (*Client) UpdateChannel added in v0.4.0

func (c *Client) UpdateChannel(channel *Channel) (err error)

UpdateChannel Not implemented yet

func (*Client) UpdateMessage added in v0.4.0

func (c *Client) UpdateMessage(message *Message) (msg *Message, err error)

UpdateMessage .

type Config

type Config struct {
	Token      string
	HTTPClient *http.Client

	APIVersion  int    // eg. version 6. 0 defaults to lowest supported api version
	APIEncoding string // eg. json, use const. defaults to json

	CancelRequestWhenRateLimited bool

	LoadAllMembers   bool
	LoadAllChannels  bool
	LoadAllRoles     bool
	LoadAllPresences bool

	Debug bool
}

Config Configuration for the Disgord client

type CreateChannelInvitesParams added in v0.6.0

type CreateChannelInvitesParams struct {
	MaxAge    int  `json:"max_age,omitempty"`   // duration of invite in seconds before expiry, or 0 for never. default 86400 (24 hours)
	MaxUses   int  `json:"max_uses,omitempty"`  // max number of uses or 0 for unlimited. default 0
	Temporary bool `json:"temporary,omitempty"` // whether this invite only grants temporary membership. default false
	Unique    bool `json:"unique,omitempty"`    // if true, don't try to reuse a similar invite (useful for creating many unique one time use invites). default false
}

CreateChannelInvitesParams https://discordapp.com/developers/docs/resources/channel#create-channel-invite-json-params

type CreateChannelMessageParams added in v0.6.0

type CreateChannelMessageParams struct {
	Content     string        `json:"content"`
	Nonce       Snowflake     `json:"nonce,omitempty"`
	Tts         bool          `json:"tts,omitempty"`
	File        interface{}   `json:"file,omitempty"`  // TODO: what is this supposed to be?
	Embed       *ChannelEmbed `json:"embed,omitempty"` // embedded rich content
	PayloadJSON string        `json:"payload_json,omitempty"`
}

CreateChannelMessageParams JSON params for CreateChannelMessage

func NewMessageByString added in v0.6.0

func NewMessageByString(content string) *CreateChannelMessageParams

NewMessageByString creates a message object from a string/content

type CreateGroupDMParams added in v0.6.0

type CreateGroupDMParams struct {
	AccessTokens []string             `json:"access_tokens"` // access tokens of users that have granted your app the gdm.join scope
	Nicks        map[Snowflake]string `json:"nicks"`         // userID => nickname
}

CreateGroupDMParams JSON params for func CreateGroupDM https://discordapp.com/developers/docs/resources/user#create-group-dm

type CreateGuildBanParams added in v0.6.0

type CreateGuildBanParams struct {
	DeleteMessageDays int    `urlparam:"delete_message_days"` // number of days to delete messages for (0-7)
	Reason            string `urlparam:"reason"`              // reason for being banned
}

CreateGuildBanParams https://discordapp.com/developers/docs/resources/guild#create-guild-ban-query-string-params

func (*CreateGuildBanParams) GetQueryString added in v0.6.0

func (params *CreateGuildBanParams) GetQueryString() string

GetQueryString .

type CreateGuildChannelParams added in v0.6.0

type CreateGuildChannelParams struct {
	Name                 string                `json:"name"`                            //  |
	Type                 uint                  `json:"type,omitempty"`                  // ?|
	Topic                string                `json:"topic,omitempty"`                 // ?|
	Bitrate              uint                  `json:"bitrate,omitempty"`               // ?|
	UserLimit            uint                  `json:"user_limit,omitempty"`            // ?|
	PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"` // ?|
	ParentID             Snowflake             `json:"parent_id,omitempty"`             // ?|
	NSFW                 bool                  `json:"nsfw,omitempty"`                  // ?|
}

CreateGuildChannelParams https://discordapp.com/developers/docs/resources/guild#create-guild-channel-json-params

type CreateGuildEmojiParams added in v0.6.0

type CreateGuildEmojiParams struct {
	Name  string      `json:"name"`
	Image string      `json:"image"`
	Roles []Snowflake `json:"roles"`
}

CreateGuildEmojiParams JSON params for func CreateGuildEmoji

type CreateGuildIntegrationParams added in v0.6.0

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

CreateGuildIntegrationParams https://discordapp.com/developers/docs/resources/guild#create-guild-integration-json-params

type CreateGuildParams added in v0.6.0

type CreateGuildParams struct {
	Name                    string                        `json:"name"`
	Region                  string                        `json:"region"`
	Icon                    string                        `json:"icon"`
	VerificationLvl         int                           `json:"verification_level"`
	DefaultMsgNotifications DefaultMessageNotificationLvl `json:"default_message_notifications"`
	ExplicitContentFilter   ExplicitContentFilterLvl      `json:"explicit_content_filter"`
	Roles                   []*Role                       `json:"roles"`
	Channels                []*PartialChannel             `json:"channels"`
}

CreateGuildParams https://discordapp.com/developers/docs/resources/guild#create-guild-json-params example partial channel object:

{
   "name": "naming-things-is-hard",
   "type": 0
}

type CreateGuildRoleParams added in v0.6.0

type CreateGuildRoleParams struct {
	Name        string `json:"name,omitempty"`
	Permissions int    `json:"permissions,omitempty"`
	Color       int    `json:"color,omitempty"`
	Hoist       bool   `json:"hoist,omitempty"`
	Mentionable bool   `json:"mentionable,omitempty"`
}

CreateGuildRoleParams https://discordapp.com/developers/docs/resources/guild#create-guild-role-json-params

type CreateWebhookParams added in v0.6.0

type CreateWebhookParams struct {
	Name   string `json:"name"`   // name of the webhook (2-32 characters)
	Avatar string `json:"avatar"` // avatar data uri scheme, image for the default webhook avatar
}

CreateWebhookParams json params for the create webhook rest request avatar string: https://discordapp.com/developers/docs/resources/user#avatar-data

type DefaultMessageNotificationLvl added in v0.6.0

type DefaultMessageNotificationLvl uint

DefaultMessageNotification ... https://discordapp.com/developers/docs/resources/guild#guild-object-default-message-notification-level

func (*DefaultMessageNotificationLvl) AllMessages added in v0.6.0

func (dmnl *DefaultMessageNotificationLvl) AllMessages() bool

func (*DefaultMessageNotificationLvl) Equals added in v0.6.0

func (dmnl *DefaultMessageNotificationLvl) Equals(v uint) bool

func (*DefaultMessageNotificationLvl) OnlyMentions added in v0.6.0

func (dmnl *DefaultMessageNotificationLvl) OnlyMentions() bool

type DeletedMessage added in v0.6.0

type DeletedMessage struct {
	ID        Snowflake `json:"id"`
	ChannelID Snowflake `json:"channel_id"`
}

func NewDeletedMessage added in v0.6.0

func NewDeletedMessage() *DeletedMessage

type Dispatch

type Dispatch struct {
	// contains filtered or unexported fields
}

Dispatch holds all the channels and internal state for all registered observers

func NewDispatch

func NewDispatch() *Dispatch

NewDispatch construct a Dispatch object for reacting to web socket events from discord

func (*Dispatch) AddHandler

func (d *Dispatch) AddHandler(evtName string, listener interface{})

AddHandler bind a callback to a event type. See event.Key...

func (*Dispatch) AddHandlerOnce

func (d *Dispatch) AddHandlerOnce(evtName string, listener interface{})

AddHandlerOnce same as AddHandler except that the callback is only triggered once

func (*Dispatch) AllChan

func (d *Dispatch) AllChan() <-chan interface{}

AllChan sends all event types

func (*Dispatch) ChannelCreateChan

func (d *Dispatch) ChannelCreateChan() <-chan *ChannelCreate

ChannelCreateChan for CHANNEL_CREATE, when a channel is created

func (*Dispatch) ChannelDeleteChan

func (d *Dispatch) ChannelDeleteChan() <-chan *ChannelDelete

ChannelDeleteChan for CHANNEL_DELETE, when a channel is deleted

func (*Dispatch) ChannelPinsUpdateChan

func (d *Dispatch) ChannelPinsUpdateChan() <-chan *ChannelPinsUpdate

ChannelPinsUpdateChan for CHANNEL_PIN_UPDATE. Message was pinned or unpinned

func (*Dispatch) ChannelUpdateChan

func (d *Dispatch) ChannelUpdateChan() <-chan *ChannelUpdate

ChannelUpdateChan for CHANNEL_UPDATE, when a channel is updated

func (*Dispatch) GuildBanAddChan

func (d *Dispatch) GuildBanAddChan() <-chan *GuildBanAdd

GuildBanAddChan for GUILD_BAN_ADD. A user was banned from a guild

func (*Dispatch) GuildBanRemoveChan

func (d *Dispatch) GuildBanRemoveChan() <-chan *GuildBanRemove

GuildBanRemoveChan for GUILD_BAN_REMOVE. A user was unbanned from a guild

func (*Dispatch) GuildCreateChan

func (d *Dispatch) GuildCreateChan() <-chan *GuildCreate

GuildCreateChan for GUILD_CREATE. Lazy-load for unavailable guild, guild became available, or user joined a new guild

func (*Dispatch) GuildDeleteChan

func (d *Dispatch) GuildDeleteChan() <-chan *GuildDelete

GuildDeleteChan for GUILD_DELETE, guild became unavailable, or user left/was removed from a guild

func (*Dispatch) GuildEmojisUpdateChan

func (d *Dispatch) GuildEmojisUpdateChan() <-chan *GuildEmojisUpdate

GuildEmojisUpdateChan for GUILD_EMOJI_UPDATE. Guild emojis were updated

func (*Dispatch) GuildIntegrationsUpdateChan

func (d *Dispatch) GuildIntegrationsUpdateChan() <-chan *GuildIntegrationsUpdate

GuildIntegrationsUpdateChan for GUILD_INTEGRATIONS_UPDATE. Guild integration was updated

func (*Dispatch) GuildMemberAddChan

func (d *Dispatch) GuildMemberAddChan() <-chan *GuildMemberAdd

GuildMemberAddChan for GUILD_MEMBER_ADD. New user joined a guild.

func (*Dispatch) GuildMemberRemoveChan

func (d *Dispatch) GuildMemberRemoveChan() <-chan *GuildMemberRemove

GuildMemberRemoveChan for GUILD_MEMBER_REMOVE. User was removed from guild.

func (*Dispatch) GuildMemberUpdateChan

func (d *Dispatch) GuildMemberUpdateChan() <-chan *GuildMemberUpdate

GuildMemberUpdateChan for GUILD_MEMBER_UPDATE. Guild member was updated.

func (*Dispatch) GuildMembersChunkChan

func (d *Dispatch) GuildMembersChunkChan() <-chan *GuildMembersChunk

GuildMembersChunkChan for GUILD_MEMBERS_CHUNK. Response to socket command 'Request Guild Members'

func (*Dispatch) GuildRoleCreateChan

func (d *Dispatch) GuildRoleCreateChan() <-chan *GuildRoleCreate

GuildRoleCreateChan for GUILD_ROLE_CREATE. Guild role was created.

func (*Dispatch) GuildRoleDeleteChan

func (d *Dispatch) GuildRoleDeleteChan() <-chan *GuildRoleDelete

GuildRoleDeleteChan for GUILD_ROLE_DELETE. Guild role was deleted.

func (*Dispatch) GuildRoleUpdateChan

func (d *Dispatch) GuildRoleUpdateChan() <-chan *GuildRoleUpdate

GuildRoleUpdateChan for GUILD_ROLE_UPDATE. Guild role was updated.

func (*Dispatch) GuildUpdateChan

func (d *Dispatch) GuildUpdateChan() <-chan *GuildUpdate

GuildUpdateChan for GUILD_UPDATE. Guild was updated

func (*Dispatch) MessageCreateChan

func (d *Dispatch) MessageCreateChan() <-chan *MessageCreate

MessageCreateChan for MESSAGE_CREATE. New message was created.

func (*Dispatch) MessageDeleteBulkChan

func (d *Dispatch) MessageDeleteBulkChan() <-chan *MessageDeleteBulk

MessageDeleteBulkChan for MESSAGE_DELETE_BULK. Multiple messages were deleted at once.

func (*Dispatch) MessageDeleteChan

func (d *Dispatch) MessageDeleteChan() <-chan *MessageDelete

MessageDeleteChan for MESSAGE_DELETE. Message was deleted.

func (*Dispatch) MessageReactionAddChan

func (d *Dispatch) MessageReactionAddChan() <-chan *MessageReactionAdd

MessageReactionAddChan for MESSAGE_REACTION_ADD. A user reacted to a message.

func (*Dispatch) MessageReactionRemoveAllChan

func (d *Dispatch) MessageReactionRemoveAllChan() <-chan *MessageReactionRemoveAll

MessageReactionRemoveAllChan for MESSAGE_REACTION_REMOVE_ALL. All reactions were explicitly removed from a message

func (*Dispatch) MessageReactionRemoveChan

func (d *Dispatch) MessageReactionRemoveChan() <-chan *MessageReactionRemove

MessageReactionRemoveChan for MESSAGE_REACTION_REMOVE. A user removed a a reaction to a message.

func (*Dispatch) MessageUpdateChan

func (d *Dispatch) MessageUpdateChan() <-chan *MessageUpdate

MessageUpdateChan for MESSAGE_UPDATE. Message was updated.

func (*Dispatch) PresenceUpdateChan

func (d *Dispatch) PresenceUpdateChan() <-chan *PresenceUpdate

PresenceUpdateChan for PRESENCE_UPDATE. A user's presence was updated in a guild.

func (*Dispatch) ReadyChan

func (d *Dispatch) ReadyChan() <-chan *Ready

ReadyChan for READY events

func (*Dispatch) ResumedChan

func (d *Dispatch) ResumedChan() <-chan *Resumed

ResumedChan for RESUME events

func (*Dispatch) TypingStartChan

func (d *Dispatch) TypingStartChan() <-chan *TypingStart

TypingStartChan for TYPING_START. A user started typing in a channel.

func (*Dispatch) UserUpdateChan

func (d *Dispatch) UserUpdateChan() <-chan *UserUpdate

UserUpdateChan for USER_UPDATE. Properties about a user changed

func (*Dispatch) VoiceServerUpdateChan

func (d *Dispatch) VoiceServerUpdateChan() <-chan *VoiceServerUpdate

VoiceServerUpdateChan for VOICE_SERVER_UPDATE. Guild's voice server was updated

func (*Dispatch) VoiceStateUpdateChan

func (d *Dispatch) VoiceStateUpdateChan() <-chan *VoiceStateUpdate

VoiceStateUpdateChan for VOICE_STATE_UPDATE. Someone joined, left, or moved a voice channel

func (*Dispatch) WebhooksUpdateChan

func (d *Dispatch) WebhooksUpdateChan() <-chan *WebhooksUpdate

WebhooksUpdateChan for WEBHOOK_UPDATE. A guild channel webhook was created, update, or deleted

type EditChannelPermissionsParams added in v0.6.0

type EditChannelPermissionsParams struct {
	Allow int    `json:"allow"` // the bitwise value of all allowed permissions
	Deny  int    `json:"deny"`  // the bitwise value of all disallowed permissions
	Type  string `json:"type"`  // "member" for a user or "role" for a role
}

EditChannelPermissionsParams https://discordapp.com/developers/docs/resources/channel#edit-channel-permissions-json-params

type EditMessageParams added in v0.6.0

type EditMessageParams struct {
	Content string        `json:"content,omitempty"`
	Embed   *ChannelEmbed `json:"embed,omitempty"` // embedded rich content
}

EditMessageParams https://discordapp.com/developers/docs/resources/channel#edit-message-json-params

type 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"`
}

Emoji

func CreateGuildEmoji added in v0.6.0

func CreateGuildEmoji(client httd.Poster, guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error)

CreateGuildEmoji [POST] Create a new emoji for the guild. Requires the

'MANAGE_EMOJIS' permission. Returns the new emoji
object on success. Fires a Guild Emojis Update Gateway event.

Endpoint /guilds/{guild.id}/emojis Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#create-guild-emoji Reviewed 2018-06-10 Comment Emojis and animated emojis have a maximum file size of 256kb.

Attempting to upload an emoji larger than this limit will fail
and return 400 Bad Request and an error message, but not a JSON
status code.

func GetGuildEmoji added in v0.6.0

func GetGuildEmoji(client httd.Getter, guildID, emojiID Snowflake) (ret *Emoji, err error)

GetGuildEmoji [GET] Returns an emoji object for the given guild and emoji IDs. Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#get-guild-emoji Reviewed 2018-06-10 Comment -

func ListGuildEmojis added in v0.6.0

func ListGuildEmojis(client httd.Getter, id Snowflake) (ret []*Emoji, err error)

ListGuildEmojis [GET] Returns a list of emoji objects for the given guild. Endpoint /guilds/{guild.id}/emojis Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#list-guild-emojis Reviewed 2018-06-10 Comment -

func ModifyGuildEmoji added in v0.6.0

func ModifyGuildEmoji(client httd.Patcher, guildID, emojiID Snowflake, params *ModifyGuildEmojiParams) (ret *Emoji, err error)

ModifyGuildEmoji [PATCH] Modify the given emoji. Requires the 'MANAGE_EMOJIS'

permission. Returns the updated emoji object on success.
Fires a Guild Emojis Update Gateway event.

Endpoint /guilds/{guild.id}/emojis/{emoji.id} Rate limiter [MAJOR] /guilds/{guild.id} // TODO: no idea if this is correct Discord documentation https://discordapp.com/developers/docs/resources/emoji#modify-guild-emoji Reviewed 2018-06-10 Comment -

func (*Emoji) Clear added in v0.6.0

func (e *Emoji) Clear()

func (*Emoji) Mention added in v0.6.0

func (e *Emoji) Mention() string

Mention TODO: review

func (*Emoji) MentionAnimated added in v0.6.0

func (e *Emoji) MentionAnimated() string

MentionAnimated add the animation prefix if a animated emoji TODO: review

type EventCallback

type EventCallback = func(session Session, box interface{})

EventCallback is triggered on every event type

type EvtDispatcher

type EvtDispatcher interface {
	AllChan() <-chan interface{} // any event
	ReadyChan() <-chan *Ready
	ResumedChan() <-chan *Resumed
	ChannelCreateChan() <-chan *ChannelCreate
	ChannelUpdateChan() <-chan *ChannelUpdate
	ChannelDeleteChan() <-chan *ChannelDelete
	ChannelPinsUpdateChan() <-chan *ChannelPinsUpdate
	GuildCreateChan() <-chan *GuildCreate
	GuildUpdateChan() <-chan *GuildUpdate
	GuildDeleteChan() <-chan *GuildDelete
	GuildBanAddChan() <-chan *GuildBanAdd
	GuildBanRemoveChan() <-chan *GuildBanRemove
	GuildEmojisUpdateChan() <-chan *GuildEmojisUpdate
	GuildIntegrationsUpdateChan() <-chan *GuildIntegrationsUpdate
	GuildMemberAddChan() <-chan *GuildMemberAdd
	GuildMemberRemoveChan() <-chan *GuildMemberRemove
	GuildMemberUpdateChan() <-chan *GuildMemberUpdate
	GuildMembersChunkChan() <-chan *GuildMembersChunk
	GuildRoleUpdateChan() <-chan *GuildRoleUpdate
	GuildRoleCreateChan() <-chan *GuildRoleCreate
	GuildRoleDeleteChan() <-chan *GuildRoleDelete
	MessageCreateChan() <-chan *MessageCreate
	MessageUpdateChan() <-chan *MessageUpdate
	MessageDeleteChan() <-chan *MessageDelete
	MessageDeleteBulkChan() <-chan *MessageDeleteBulk
	MessageReactionAddChan() <-chan *MessageReactionAdd
	MessageReactionRemoveChan() <-chan *MessageReactionRemove
	MessageReactionRemoveAllChan() <-chan *MessageReactionRemoveAll
	PresenceUpdateChan() <-chan *PresenceUpdate
	TypingStartChan() <-chan *TypingStart
	UserUpdateChan() <-chan *UserUpdate
	VoiceStateUpdateChan() <-chan *VoiceStateUpdate
	VoiceServerUpdateChan() <-chan *VoiceServerUpdate
	WebhooksUpdateChan() <-chan *WebhooksUpdate

	AddHandler(evtName string, listener interface{})
	AddHandlerOnce(evtName string, listener interface{})
}

EvtDispatcher interface for developers using the module. Gives access to channels and the option to add callbacks to specific event types.

type ExecuteWebhookParams added in v0.6.0

type ExecuteWebhookParams struct {
	WebhookID Snowflake `json:"-"`
	Token     string    `json:"-"`

	Content   string          `json:"content"`
	Username  string          `json:"username"`
	AvatarURL string          `json:"avatar_url"`
	TTS       bool            `json:"tts"`
	File      interface{}     `json:"file"`
	Embeds    []*ChannelEmbed `json:"embeds"`
}

ExecuteWebhookParams JSON params for func ExecuteWebhook

func NewExecuteWebhookParams added in v0.6.0

func NewExecuteWebhookParams(id Snowflake, token string) (ret *ExecuteWebhookParams, err error)

NewExecuteWebhookParams creates params for func ExecuteWebhook

type ExplicitContentFilterLvl added in v0.6.0

type ExplicitContentFilterLvl uint

ExplicitContentFilterLvl ... https://discordapp.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level

func (*ExplicitContentFilterLvl) AllMembers added in v0.6.0

func (ecfl *ExplicitContentFilterLvl) AllMembers() bool

func (*ExplicitContentFilterLvl) Disabled added in v0.6.0

func (ecfl *ExplicitContentFilterLvl) Disabled() bool

func (*ExplicitContentFilterLvl) MembersWithoutRoles added in v0.6.0

func (ecfl *ExplicitContentFilterLvl) MembersWithoutRoles() bool

type GetChannelMessagesParams added in v0.6.0

type GetChannelMessagesParams struct {
	Around Snowflake `urlparam:"around,omitempty"`
	Before Snowflake `urlparam:"before,omitempty"`
	After  Snowflake `urlparam:"after,omitempty"`
	Limit  int       `urlparam:"limit,omitempty"`
}

GetChannelMessagesParams https://discordapp.com/developers/docs/resources/channel#get-channel-messages-query-string-params TODO: ensure limits

func (*GetChannelMessagesParams) GetQueryString added in v0.6.0

func (params *GetChannelMessagesParams) GetQueryString() string

GetQueryString .

type GetCurrentUserGuildsParams added in v0.6.0

type GetCurrentUserGuildsParams struct {
	Before Snowflake `urlparam:"before,omitempty"`
	After  Snowflake `urlparam:"after,omitempty"`
	Limit  int       `urlparam:"limit,omitempty"`
}

GetCurrentUserGuildsParams JSON params for func GetCurrentUserGuilds

func (*GetCurrentUserGuildsParams) GetQueryString added in v0.6.0

func (params *GetCurrentUserGuildsParams) GetQueryString() string

GetQueryString .

type GetReactionURLParams added in v0.6.0

type GetReactionURLParams struct {
	Before Snowflake `urlparam:"before,omitempty"` // get users before this user Snowflake
	After  Snowflake `urlparam:"after,omitempty"`  // get users after this user Snowflake
	Limit  int       `urlparam:"limit,omitempty"`  // max number of users to return (1-100)
}

GetReactionURLParams https://discordapp.com/developers/docs/resources/channel#get-reactions-query-string-params

func (*GetReactionURLParams) GetQueryString added in v0.6.0

func (params *GetReactionURLParams) GetQueryString() string

GetQueryString .

type GroupDMAddRecipientParams added in v0.6.0

type GroupDMAddRecipientParams struct {
	AccessToken string `json:"access_token"` // access token of a user that has granted your app the gdm.join scope
	Nickname    string `json:"nick"`         // nickname of the user being added
}

GroupDMAddRecipientParams JSON params for GroupDMAddRecipient

type Guild added in v0.6.0

type Guild struct {
	ID                          Snowflake                     `json:"id"`
	ApplicationID               *Snowflake                    `json:"application_id"` //   |?
	Name                        string                        `json:"name"`
	Icon                        *string                       `json:"icon"`            //  |?, icon hash
	Splash                      *string                       `json:"splash"`          //  |?, image hash
	Owner                       bool                          `json:"owner,omitempty"` // ?|
	OwnerID                     Snowflake                     `json:"owner_id"`
	Permissions                 uint64                        `json:"permissions,omitempty"` // ?|, permission flags for connected user `/users/@me/guilds`
	Region                      string                        `json:"region"`
	AfkChannelID                *Snowflake                    `json:"afk_channel_id"` // |?
	AfkTimeout                  uint                          `json:"afk_timeout"`
	EmbedEnabled                bool                          `json:"embed_enabled,omit_empty"`
	EmbedChannelID              Snowflake                     `json:"embed_channel_id,omit_empty"`
	VerificationLevel           VerificationLvl               `json:"verification_level"`
	DefaultMessageNotifications DefaultMessageNotificationLvl `json:"default_message_notifications"`
	ExplicitContentFilter       ExplicitContentFilterLvl      `json:"explicit_content_filter"`
	Roles                       []*Role                       `json:"roles"`
	Emojis                      []*Emoji                      `json:"emojis"`
	Features                    []string                      `json:"features"`
	MFALevel                    MFALvl                        `json:"mfa_level"`
	WidgetEnabled               bool                          `json:"widget_enabled,omit_empty"`    //   |
	WidgetChannelID             Snowflake                     `json:"widget_channel_id,omit_empty"` //   |
	SystemChannelID             *Snowflake                    `json:"system_channel_id,omitempty"`  //   |?

	// JoinedAt must be a pointer, as we can't hide non-nil structs
	JoinedAt       *Timestamp      `json:"joined_at,omitempty"`    // ?*|
	Large          bool            `json:"large,omitempty"`        // ?*|
	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"`    // ?*|
	PresencesMutex sync.RWMutex    `json:"-"`
	// contains filtered or unexported fields
}

func CreateGuild added in v0.6.0

func CreateGuild(client httd.Poster, params *CreateGuildParams) (ret *Guild, err error)

CreateGuild [POST] Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. Endpoint /guilds Rate limiter /guilds Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild Reviewed 2018-08-16 Comment This endpoint. can be used only by bots in less than 10 guilds. Creating channel

categories from this endpoint. is not supported.

func GetCurrentUserGuilds added in v0.6.0

func GetCurrentUserGuilds(client httd.Getter, params *GetCurrentUserGuildsParams) (ret []*Guild, err error)

GetCurrentUserGuilds [GET] Returns a list of partial guild objects the current user is a member of.

Requires the guilds OAuth2 scope.

Endpoint /users/@me/guilds Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-current-user-guilds Reviewed 2018-06-10 Comment This endpoint. returns 100 guilds by default, which is the maximum number of

guilds a non-bot user can join. Therefore, pagination is not needed for
integrations that need to get a list of users' guilds.

func GetGuild added in v0.6.0

func GetGuild(client httd.Getter, id Snowflake) (ret *Guild, err error)

GetGuild [GET] Returns the guild object for the given id. Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild Reviewed 2018-08-17 Comment -

func ModifyGuild added in v0.6.0

func ModifyGuild(client httd.Patcher, id Snowflake, params *ModifyGuildParams) (ret *Guild, err error)

ModifyGuild [PATCH] Modify a guild's settings. Requires the 'MANAGE_GUILD' permission. Returns the updated

guild object on success. Fires a Guild Update Gateway event.

Endpoint /guilds/{guild.id} Rate limiter /guilds/{guild.id} Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional

func ModifyGuildChannelPositions added in v0.6.0

func ModifyGuildChannelPositions(client httd.Patcher, id Snowflake, params *ModifyGuildChannelPositionsParams) (ret *Guild, err error)

ModifyGuildChannelPositions [PATCH] Modify the positions of a set of channel objects for the guild. Requires

'MANAGE_CHANNELS' permission. Returns a 204 empty response on success.
Fires multiple Channel Update Gateway events.

Endpoint /guilds/{guild.id}/channels Rate limiter /guilds/{guild.id}/channels Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-channel-positions Reviewed 2018-08-17 Comment Only channels to be modified are required, with the minimum being a swap

between at least two channels.

func NewGuild added in v0.6.0

func NewGuild() *Guild

func NewGuildFromJSON added in v0.6.0

func NewGuildFromJSON(data []byte) *Guild

func NewGuildFromUnavailable added in v0.6.0

func NewGuildFromUnavailable(gu *GuildUnavailable) *Guild

func NewPartialGuild added in v0.6.0

func NewPartialGuild(ID Snowflake) *Guild

func (*Guild) AddChannel added in v0.6.0

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

func (*Guild) AddMember added in v0.6.0

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

func (*Guild) AddRole added in v0.6.0

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

func (*Guild) Channel added in v0.6.0

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

func (*Guild) Clear added in v0.6.0

func (g *Guild) Clear()

Clear all the pointers

func (*Guild) Compare added in v0.6.0

func (g *Guild) Compare(other *Guild) bool

Compare two guild objects

func (*Guild) DeepCopy added in v0.6.0

func (g *Guild) DeepCopy() *Guild

func (*Guild) DeleteChannel added in v0.6.0

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

func (*Guild) DeleteChannelByID added in v0.6.0

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

func (*Guild) DeleteRoleByID added in v0.6.0

func (g *Guild) DeleteRoleByID(ID Snowflake)

func (*Guild) MarshalJSON added in v0.6.0

func (g *Guild) MarshalJSON() ([]byte, error)

TODO: fix copying of mutex lock

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

func (g *Guild) MemberByName(name string) ([]*Member, error)

MemberByName retrieve a slice of members with same username or nickname

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)

RoleByTitle retrieves a slice of roles with same name

func (*Guild) Update added in v0.6.0

func (g *Guild) Update(new *Guild)

Update update the reference content

func (*Guild) UpdatePresence added in v0.6.0

func (g *Guild) UpdatePresence(p *UserPresence)

func (*Guild) UpdateRole added in v0.6.0

func (g *Guild) UpdateRole(r *Role)

type GuildAuditLogsParams added in v0.6.0

type GuildAuditLogsParams struct {
	UserID     Snowflake `urlparam:"user_id,omitempty"`     // filter the log for a user id
	ActionType uint      `urlparam:"action_type,omitempty"` // the type of audit log event
	Before     Snowflake `urlparam:"before,omitempty"`      // filter the log before a certain entry id
	Limit      int       `urlparam:"limit,omitempty"`       // how many entries are returned (default 50, minimum 1, maximum 100)
}

GuildAuditLogsParams set params used in endpoint request https://discordapp.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters

func (*GuildAuditLogsParams) GetQueryString added in v0.6.0

func (params *GuildAuditLogsParams) GetQueryString() string

GetQueryString .

type GuildBanAdd added in v0.6.0

type GuildBanAdd struct {
	User *User           `json:"user"`
	Ctx  context.Context `json:"-"`
}

GuildBanAdd user was banned from a guild

type GuildBanAddCallback

type GuildBanAddCallback = func(session Session, gba *GuildBanAdd)

GuildBanAddCallback triggered on GUILD_BAN_ADD events

type GuildBanRemove added in v0.6.0

type GuildBanRemove struct {
	User *User           `json:"user"`
	Ctx  context.Context `json:"-"`
}

GuildBanRemove user was unbanned from a guild

type GuildBanRemoveCallback

type GuildBanRemoveCallback = func(session Session, gbr *GuildBanRemove)

GuildBanRemoveCallback triggered on GUILD_BAN_REMOVE events

type GuildCreate added in v0.6.0

type GuildCreate struct {
	Guild *Guild          `json:"guild"`
	Ctx   context.Context `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.

type GuildCreateCallback

type GuildCreateCallback = func(session Session, gc *GuildCreate)

GuildCreateCallback triggered on GUILD_CREATE events

type GuildDelete added in v0.6.0

type GuildDelete struct {
	UnavailableGuild *GuildUnavailable `json:"guild_unavailable"`
	Ctx              context.Context   `json:"-"`
}

GuildDelete guild became unavailable, or user left/was removed from a guild

type GuildDeleteCallback

type GuildDeleteCallback = func(session Session, gd *GuildDelete)

GuildDeleteCallback triggered on GUILD_DELETE events

type GuildEmbed added in v0.6.0

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

------------ GuildEmbed https://discordapp.com/developers/docs/resources/guild#guild-embed-object

func GetGuildEmbed added in v0.6.0

func GetGuildEmbed(client httd.Getter, guildID Snowflake) (ret *GuildEmbed, err error)

GetGuildEmbed [GET] Returns the guild embed object. Requires the 'MANAGE_GUILD' permission. Endpoint /guilds/{guild.id}/embed Rate limiter /guilds/{guild.id}/embed Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-embed Reviewed 2018-08-18 Comment -

func ModifyGuildEmbed added in v0.6.0

func ModifyGuildEmbed(client httd.Patcher, guildID Snowflake, params *GuildEmbed) (ret *GuildEmbed, err error)

ModifyGuildEmbed [PATCH] Modify a guild embed object for the guild. All attributes may be passed in

with JSON and modified. Requires the 'MANAGE_GUILD' permission.
Returns the updated guild embed object.

Endpoint /guilds/{guild.id}/embed Rate limiter /guilds/{guild.id}/embed Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-embed Reviewed 2018-08-18 Comment -

type GuildEmojisUpdate added in v0.6.0

type GuildEmojisUpdate struct {
	GuildID Snowflake       `json:"guild_id"`
	Emojis  []*Emoji        `json:"emojis"`
	Ctx     context.Context `json:"-"`
}

GuildEmojisUpdate guild emojis were updated

type GuildEmojisUpdateCallback

type GuildEmojisUpdateCallback = func(session Session, geu *GuildEmojisUpdate)

GuildEmojisUpdateCallback triggered on GUILD_EMOJIS_UPDATE events

type GuildIntegrationsUpdate added in v0.6.0

type GuildIntegrationsUpdate struct {
	GuildID Snowflake       `json:"guild_id"`
	Ctx     context.Context `json:"-"`
}

GuildIntegrationsUpdate guild integration was updated

type GuildIntegrationsUpdateCallback

type GuildIntegrationsUpdateCallback = func(session Session, giu *GuildIntegrationsUpdate)

GuildIntegrationsUpdateCallback triggered on GUILD_INTEGRATIONS_UPDATE events

type GuildInterface added in v0.6.0

type GuildInterface interface {
	Channel(ID Snowflake)
}

type GuildMemberAdd added in v0.6.0

type GuildMemberAdd struct {
	Member *Member         `json:"member"`
	Ctx    context.Context `json:"-"`
}

GuildMemberAdd new user joined a guild

type GuildMemberAddCallback

type GuildMemberAddCallback = func(session Session, gma *GuildMemberAdd)

GuildMemberAddCallback triggered on GUILD_MEMBER_ADD events

type GuildMemberRemove added in v0.6.0

type GuildMemberRemove struct {
	GuildID Snowflake       `json:"guild_id"`
	User    *User           `json:"user"`
	Ctx     context.Context `json:"-"`
}

GuildMemberRemove user was removed from a guild

type GuildMemberRemoveCallback

type GuildMemberRemoveCallback = func(session Session, gmr *GuildMemberRemove)

GuildMemberRemoveCallback triggered on GUILD_MEMBER_REMOVE events

type GuildMemberUpdate added in v0.6.0

type GuildMemberUpdate struct {
	GuildID Snowflake       `json:"guild_id"`
	Roles   []*Role         `json:"roles"`
	User    *User           `json:"user"`
	Nick    string          `json:"nick"`
	Ctx     context.Context `json:"-"`
}

GuildMemberUpdate guild member was updated

type GuildMemberUpdateCallback

type GuildMemberUpdateCallback = func(session Session, gmu *GuildMemberUpdate)

GuildMemberUpdateCallback triggered on GUILD_MEMBER_UPDATE events

type GuildMembersChunk added in v0.6.0

type GuildMembersChunk struct {
	GuildID Snowflake       `json:"guild_id"`
	Members []*Member       `json:"members"`
	Ctx     context.Context `json:"-"`
}

GuildMembersChunk response to Request Guild Members

type GuildMembersChunkCallback

type GuildMembersChunkCallback = func(session Session, gmc *GuildMembersChunk)

GuildMembersChunkCallback triggered on GUILD_MEMBERS_CHUNK events

type GuildPruneCount added in v0.6.0

type GuildPruneCount struct {
	Pruned int `json:"pruned"`
}

func BeginGuildPrune added in v0.6.0

func BeginGuildPrune(client httd.Poster, id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)

BeginGuildPrune [POST] Begin a prune operation. Requires the 'KICK_MEMBERS' permission. Returns an object

with one 'pruned' key indicating the number of members that were removed in the
prune operation. Fires multiple Guild Member Remove Gateway events.

Endpoint /guilds/{guild.id}/prune Rate limiter /guilds/{guild.id}/prune Discord documentation https://discordapp.com/developers/docs/resources/guild#begin-guild-prune Reviewed 2018-08-18 Comment -

func GetGuildPruneCount added in v0.6.0

func GetGuildPruneCount(client httd.Getter, id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)

GetGuildPruneCount [GET] Returns an object with one 'pruned' key indicating the number of members that would

be removed in a prune operation. Requires the 'KICK_MEMBERS' permission.

Endpoint /guilds/{guild.id}/prune Rate limiter /guilds/{guild.id}/prune Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-prune-count Reviewed 2018-08-18 Comment -

type GuildPruneParams added in v0.6.0

type GuildPruneParams struct {
	Days int `urlparam:"days"` // number of days to count prune for (1 or more)
}

GuildPruneParams https://discordapp.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params

func (*GuildPruneParams) GetQueryString added in v0.6.0

func (params *GuildPruneParams) GetQueryString() string

GetQueryString .

type GuildRoleCreate added in v0.6.0

type GuildRoleCreate struct {
	GuildID Snowflake       `json:"guild_id"`
	Role    *Role           `json:"role"`
	Ctx     context.Context `json:"-"`
}

GuildRoleCreate guild role was created

type GuildRoleCreateCallback

type GuildRoleCreateCallback = func(session Session, grc *GuildRoleCreate)

GuildRoleCreateCallback triggered on GUILD_ROLE_CREATE events

type GuildRoleDelete added in v0.6.0

type GuildRoleDelete struct {
	GuildID Snowflake       `json:"guild_id"`
	RoleID  Snowflake       `json:"role_id"`
	Ctx     context.Context `json:"-"`
}

GuildRoleDelete guild role was deleted

type GuildRoleDeleteCallback

type GuildRoleDeleteCallback = func(session Session, grd *GuildRoleDelete)

GuildRoleDeleteCallback triggered on GUILD_ROLE_DELETE events

type GuildRoleUpdate added in v0.6.0

type GuildRoleUpdate struct {
	GuildID Snowflake       `json:"guild_id"`
	Role    *Role           `json:"role"`
	Ctx     context.Context `json:"-"`
}

GuildRoleUpdate guild role was updated

type GuildRoleUpdateCallback

type GuildRoleUpdateCallback = func(session Session, gru *GuildRoleUpdate)

GuildRoleUpdateCallback triggered on GUILD_ROLE_UPDATE events

type GuildUnavailable added in v0.6.0

type GuildUnavailable struct {
	ID           Snowflake `json:"id"`
	Unavailable  bool      `json:"unavailable"` // ?*|
	sync.RWMutex `json:"-"`
}

func NewGuildUnavailable added in v0.6.0

func NewGuildUnavailable(ID Snowflake) *GuildUnavailable

type GuildUpdate added in v0.6.0

type GuildUpdate struct {
	Guild *Guild          `json:"guild"`
	Ctx   context.Context `json:"-"`
}

GuildUpdate guild was updated

type GuildUpdateCallback

type GuildUpdateCallback = func(session Session, gu *GuildUpdate)

GuildUpdateCallback triggered on GUILD_UPDATE events

type Hello added in v0.6.0

type Hello struct {
	HeartbeatInterval uint            `json:"heartbeat_interval"`
	Trace             []string        `json:"_trace"`
	Ctx               context.Context `json:"-"`
}

Hello defines the heartbeat interval

type HelloCallback

type HelloCallback = func(session Session, h *Hello)

HelloCallback triggered in hello events

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://discordapp.com/developers/docs/resources/guild#integration-object

func GetGuildIntegrations added in v0.6.0

func GetGuildIntegrations(client httd.Getter, id Snowflake) (ret []*Integration, err error)

GetGuildIntegrations [GET] Returns a list of integration objects for the guild.

Requires the 'MANAGE_GUILD' permission.

Endpoint /guilds/{guild.id}/integrations Rate limiter /guilds/{guild.id}/integrations Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-integrations Reviewed 2018-08-18 Comment -

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://discordapp.com/developers/docs/resources/guild#integration-account-object

type InvalidSession added in v0.6.0

type InvalidSession struct {
	Ctx context.Context `json:"-"`
}

InvalidSession failure response to Identify or Resume or invalid active session

type InvalidSessionCallback

type InvalidSessionCallback = func(session Session, is *InvalidSession)

InvalidSessionCallback triggered on INVALID_SESSION events

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 *PartialGuild `json:"guild"`

	// Channel the channel this invite is for
	Channel *PartialChannel `json:"channel"`

	// ApproximatePresenceCount approximate count of online members
	ApproximatePresenceCount int `json:"approximate_presence_count,omitempty"`

	// ApproximatePresenceCount approximate count of total members
	ApproximateMemberCount int `json:"approximate_member_count,omitempty"`
}

Invite Represents a code that when used, adds a user to a guild. https://discordapp.com/developers/docs/resources/invite#invite-object Reviewed: 2018-06-10

func CreateChannelInvites added in v0.6.0

func CreateChannelInvites(client httd.Poster, id Snowflake, params *CreateChannelInvitesParams) (ret *Invite, err error)

CreateChannelInvites [POST] 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.

Endpoint /channels/{channel.id}/invites Rate limiter [MAJOR] /channels/{channel.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/channel#create-channel-invite Reviewed 2018-06-07 Comment -

func DeleteInvite added in v0.6.0

func DeleteInvite(client httd.Deleter, inviteCode string) (invite *Invite, err error)

DeleteInvite [DELETE] Delete an invite. Requires the MANAGE_CHANNELS permission. Returns an invite

object on success.

Endpoint /invites/{invite.code} Rate limiter /invites Discord documentation https://discordapp.com/developers/docs/resources/invite#delete-invite Reviewed 2018-06-10 Comment -

func GetChannelInvites added in v0.6.0

func GetChannelInvites(client httd.Getter, id Snowflake) (ret []*Invite, err error)

GetChannelInvites [GET] Returns a list of invite objects (with invite metadata) for the channel.

Only usable for guild channels. Requires the 'MANAGE_CHANNELS' permission.

Endpoint /channels/{channel.id}/invites Rate limiter [MAJOR] /channels/{channel.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-invites Reviewed 2018-06-07 Comment -

func GetGuildInvites added in v0.6.0

func GetGuildInvites(client httd.Getter, id Snowflake) (ret []*Invite, err error)

GetGuildInvites [GET] Returns a list of invite objects (with invite metadata) for the guild.

Requires the 'MANAGE_GUILD' permission.

Endpoint /guilds/{guild.id}/invites Rate limiter /guilds/{guild.id}/invites Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-invites Reviewed 2018-08-18 Comment -

func GetInvite added in v0.6.0

func GetInvite(client httd.Getter, inviteCode string, withCounts bool) (invite *Invite, err error)

GetInvite [GET] Returns an invite object for the given code. Endpoint /invites/{invite.code} Rate limiter /invites Discord documentation https://discordapp.com/developers/docs/resources/invite#get-invite Reviewed 2018-06-10 Comment -

withCounts whether the invite should contain approximate member counts

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 Timestamp `json:"created_at"`

	// Revoked whether this invite is revoked
	Revoked bool `json:"revoked"`
}

InviteMetadata Object https://discordapp.com/developers/docs/resources/invite#invite-metadata-object Reviewed: 2018-06-10

type MFALvl added in v0.6.0

type MFALvl uint

MFA ... https://discordapp.com/developers/docs/resources/guild#guild-object-mfa-level

func (*MFALvl) Elevated added in v0.6.0

func (mfal *MFALvl) Elevated() bool

func (*MFALvl) None added in v0.6.0

func (mfal *MFALvl) None() bool

type Marshaler added in v0.6.0

type Marshaler interface {
	MarshalJSON() ([]byte, error)
}

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 Timestamp   `json:"joined_at,omitempty"`
	Deaf     bool        `json:"deaf"`
	Mute     bool        `json:"mute"`

	sync.RWMutex `json:"-"`
}

Member https://discordapp.com/developers/docs/resources/guild#guild-member-object

func AddGuildMember added in v0.6.0

func AddGuildMember(client httd.Puter, guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error)

AddGuildMember [PUT] Adds a user to the guild, provided you have a valid oauth2 access token for the user

with the guilds.join scope. Returns a 201 Created with the guild member as the body,
or 204 No Content if the user is already a member of the guild. Fires a Guild Member Add
Gateway event. Requires the bot to have the CREATE_INSTANT_INVITE permission.

Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#add-guild-member Reviewed 2018-08-18 Comment All parameters to this endpoint. except for access_token are optional.

func GetGuildMember added in v0.6.0

func GetGuildMember(client httd.Getter, guildID, userID Snowflake) (ret *Member, err error)

GetGuildMember [GET] Returns a guild member object for the specified user. Endpoint /guilds/{guild.id}/members/{user.id} Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-member Reviewed 2018-08-17 Comment -

func GetGuildMembers added in v0.6.0

func GetGuildMembers(client httd.Getter, guildID, after Snowflake, limit int) (ret []*Member, err error)

GetGuildMembers [GET] Returns a list of guild member objects that are members of the guild. Endpoint /guilds/{guild.id}/members Rate limiter /guilds/{guild.id}/members Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-members Reviewed 2018-08-17 Comment All parameters to this endpoint. are optional Comment#2 "List Guild Members" Comment#3 https://discordapp.com/developers/docs/resources/guild#list-guild-members-query-string-params

func (*Member) Clear added in v0.6.0

func (m *Member) Clear() Snowflake

func (*Member) Update added in v0.6.0

func (m *Member) Update(new *Member) (err error)

type Message added in v0.6.0

type Message struct {
	ID              Snowflake          `json:"id"`
	ChannelID       Snowflake          `json:"channel_id"`
	Author          *User              `json:"author"`
	Content         string             `json:"content"`
	Timestamp       time.Time          `json:"timestamp"`
	EditedTimestamp time.Time          `json:"edited_timestamp"` // ?
	Tts             bool               `json:"tts"`
	MentionEveryone bool               `json:"mention_everyone"`
	Mentions        []*User            `json:"mentions"`
	MentionRoles    []Snowflake        `json:"mention_roles"`
	Attachments     []*Attachment      `json:"attachments"`
	Embeds          []*ChannelEmbed    `json:"embeds"`
	Reactions       []*Reaction        `json:"reactions"` // ?
	Nonce           Snowflake          `json:"nonce"`     // ?, used for validating a message was sent
	Pinned          bool               `json:"pinned"`
	WebhookID       Snowflake          `json:"webhook_id"` // ?
	Type            uint               `json:"type"`
	Activity        MessageActivity    `json:"activity"`
	Application     MessageApplication `json:"application"`

	sync.RWMutex `json:"-"`
}

Message https://discordapp.com/developers/docs/resources/channel#message-object-message-structure

func CreateChannelMessage added in v0.6.0

func CreateChannelMessage(client httd.Poster, channelID Snowflake, params *CreateChannelMessageParams) (ret *Message, err error)

CreateChannelMessage [POST] 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.

Endpoint /channels/{channel.id}/messages Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#create-message Reviewed 2018-06-10 Comment Before using this endpoint, you must connect to and identify with a gateway

at least once. This endpoint supports both JSON and form data bodies. It does
require multipart/form-data requests instead of the normal JSON request type
when uploading files. Make sure you set your Content-Type to multipart/form-data
if you're doing that. Note that in that case, the embed field cannot be used,
but you can pass an url-encoded JSON body as a form value for payload_json.

func EditMessage added in v0.6.0

func EditMessage(client httd.Patcher, chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error)

EditMessage [PATCH] 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.

Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#edit-message Reviewed 2018-06-10 Comment All parameters to this endpoint are optional.

func GetChannelMessage added in v0.6.0

func GetChannelMessage(client httd.Getter, channelID, messageID Snowflake) (ret *Message, err error)

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

Endpoint /channels/{channel.id}/messages/{message.id} Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-message Reviewed 2018-06-10 Comment -

func GetChannelMessages added in v0.6.0

func GetChannelMessages(client httd.Getter, channelID Snowflake, params URLParameters) (ret []*Message, err error)

GetChannelMessages [GET] 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.

Endpoint /channels/{channel.id}/messages Rate limiter [MAJOR] /channels/{channel.id}/messages Discord documentation https://discordapp.com/developers/docs/resources/channel#get-channel-messages Reviewed 2018-06-10 Comment The before, after, and around keys are mutually exclusive, only one may

be passed at a time. see ReqGetChannelMessagesParams.

func GetPinnedMessages added in v0.6.0

func GetPinnedMessages(client httd.Getter, channelID Snowflake) (ret []*Message, err error)

GetPinnedMessages [GET] Returns all pinned messages in the channel as an array of message objects. Endpoint /channels/{channel.id}/pins Rate limiter [MAJOR] /channels/{channel.id}/pins Discord documentation https://discordapp.com/developers/docs/resources/channel#get-pinned-messages Reviewed 2018-06-10 Comment -

func NewMessage added in v0.6.0

func NewMessage() *Message

func (*Message) AddReaction added in v0.6.0

func (m *Message) AddReaction(reaction *Reaction)

func (*Message) Delete added in v0.6.0

func (m *Message) Delete(client MessageDeleter) (err error)

Delete sends a delete request to Discord for the related message

func (*Message) MarshalJSON added in v0.6.0

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) RemoveReaction added in v0.6.0

func (m *Message) RemoveReaction(id Snowflake)

func (*Message) Respond added in v0.6.0

func (m *Message) Respond(client MessageSender, message *Message) (msg *Message, err error)

func (*Message) RespondString added in v0.6.0

func (m *Message) RespondString(client MessageSender, content string) (msg *Message, err error)

func (*Message) Send added in v0.6.0

func (m *Message) Send(client MessageSender) (msg *Message, err error)

func (*Message) Update added in v0.6.0

func (m *Message) Update(client MessageUpdater) (msg *Message, err error)

Update after changing the message object, call update to notify Discord

about any changes made

type MessageActivity added in v0.6.0

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

https://discordapp.com/developers/docs/resources/channel#message-object-message-activity-structure

type MessageApplication added in v0.6.0

type MessageApplication struct {
	ID          Snowflake `json:"id"`
	CoverImage  string    `json:"cover_image"`
	Description string    `json:"description"`
	Icon        string    `json:"icon"`
	Name        string    `json:"name"`
}

https://discordapp.com/developers/docs/resources/channel#message-object-message-application-structure

type MessageCreate added in v0.6.0

type MessageCreate struct {
	Message *Message
	Ctx     context.Context `json:"-"`
}

MessageCreate message was created

type MessageCreateCallback

type MessageCreateCallback = func(session Session, mc *MessageCreate)

MessageCreateCallback triggered on MESSAGE_CREATE events

type MessageDelete added in v0.6.0

type MessageDelete struct {
	MessageID Snowflake       `json:"id"`
	ChannelID Snowflake       `json:"channel_id"`
	Ctx       context.Context `json:"-"`
}

MessageDelete message was deleted

type MessageDeleteBulk added in v0.6.0

type MessageDeleteBulk struct {
	MessageIDs []Snowflake     `json:"ids"`
	ChannelID  Snowflake       `json:"channel_id"`
	Ctx        context.Context `json:"-"`
}

MessageDeleteBulk multiple messages were deleted at once

type MessageDeleteBulkCallback

type MessageDeleteBulkCallback = func(session Session, mdb *MessageDeleteBulk)

MessageDeleteBulkCallback triggered on MESSAGE_DELETE_BULK events

type MessageDeleteCallback

type MessageDeleteCallback = func(session Session, md *MessageDelete)

MessageDeleteCallback triggered on MESSAGE_DELETE events

type MessageDeleter added in v0.6.0

type MessageDeleter interface {
	DeleteMessage(channelID, msgID Snowflake) (err error)
}

type MessageReactionAdd added in v0.6.0

type MessageReactionAdd struct {
	UserID    Snowflake `json:"user_id"`
	ChannelID Snowflake `json:"channel_id"`
	MessageID Snowflake `json:"message_id"`
	// PartialEmoji id and name. id might be nil
	PartialEmoji *Emoji          `json:"emoji"`
	Ctx          context.Context `json:"-"`
}

MessageReactionAdd user reacted to a message

type MessageReactionAddCallback

type MessageReactionAddCallback = func(session Session, mra *MessageReactionAdd)

MessageReactionAddCallback triggered on MESSAGE_REACTION_ADD events

type MessageReactionRemove added in v0.6.0

type MessageReactionRemove struct {
	UserID    Snowflake `json:"user_id"`
	ChannelID Snowflake `json:"channel_id"`
	MessageID Snowflake `json:"message_id"`
	// PartialEmoji id and name. id might be nil
	PartialEmoji *Emoji          `json:"emoji"`
	Ctx          context.Context `json:"-"`
}

MessageReactionRemove user removed a reaction from a message

type MessageReactionRemoveAll added in v0.6.0

type MessageReactionRemoveAll struct {
	ChannelID Snowflake       `json:"channel_id"`
	MessageID Snowflake       `json:"id"`
	Ctx       context.Context `json:"-"`
}

MessageReactionRemoveAll all reactions were explicitly removed from a message

type MessageReactionRemoveAllCallback

type MessageReactionRemoveAllCallback = func(session Session, mrra *MessageReactionRemoveAll)

MessageReactionRemoveAllCallback triggered on MESSAGE_REACTION_REMOVE_ALL events

type MessageReactionRemoveCallback

type MessageReactionRemoveCallback = func(session Session, mrr *MessageReactionRemove)

MessageReactionRemoveCallback triggered on MESSAGE_REACTION_REMOVE events

type MessageSender added in v0.6.0

type MessageSender interface {
	SendMsg(channelID Snowflake, message *Message) (msg *Message, err error)
	SendMsgString(channelID Snowflake, content string) (msg *Message, err error)
}

type MessageUpdate added in v0.6.0

type MessageUpdate struct {
	Message *Message
	Ctx     context.Context `json:"-"`
}

MessageUpdate message was edited

type MessageUpdateCallback

type MessageUpdateCallback = func(session Session, mu *MessageUpdate)

MessageUpdateCallback triggered on MESSAGE_UPDATE events

type MessageUpdater added in v0.6.0

type MessageUpdater interface {
	UpdateMessage(message *Message) (msg *Message, err error)
}

type ModifyCurrentUserNickParams added in v0.6.0

type ModifyCurrentUserNickParams struct {
	Nick string `json:"nick"` // :CHANGE_NICKNAME
}

ModifyCurrentUserNickParams https://discordapp.com/developers/docs/resources/guild#modify-guild-member-json-params

type ModifyCurrentUserParams added in v0.6.0

type ModifyCurrentUserParams struct {
	Username string `json:"username,omitempty"`
	Avatar   string `json:"avatar,omitempty"`
}

ModifyCurrentUserParams JSON params for func ModifyCurrentUser

type ModifyGuildChannelPositionsParams added in v0.6.0

type ModifyGuildChannelPositionsParams struct {
	ID       Snowflake `json:"id"`
	Position int       `json:"position"`
}

ModifyGuildChannelPositionsParams https://discordapp.com/developers/docs/resources/guild#modify-guild-channel-positions-json-params

type ModifyGuildEmojiParams added in v0.6.0

type ModifyGuildEmojiParams struct {
	Name  string      `json:"name"`
	Roles []Snowflake `json:"roles"`
}

ModifyGuildEmojiParams JSON params for func ModifyGuildEmoji

type ModifyGuildIntegrationParams added in v0.6.0

type ModifyGuildIntegrationParams struct {
	ExpireBehavior    int  `json:"expire_behavior"`
	ExpireGracePeriod int  `json:"expire_grace_period"`
	EnableEmoticons   bool `json:"enable_emoticons"`
}

ModifyGuildIntegrationParams https://discordapp.com/developers/docs/resources/guild#modify-guild-integration-json-params

type ModifyGuildMemberParams added in v0.6.0

type ModifyGuildMemberParams struct {
	Nick      string      `json:"nick,omitempty"`       // :MANAGE_NICKNAMES
	Roles     []Snowflake `json:"roles,omitempty"`      // :MANAGE_ROLES
	Mute      bool        `json:"mute,omitempty"`       // :MUTE_MEMBERS
	Deaf      bool        `json:"deaf,omitempty"`       // :DEAFEN_MEMBERS
	ChannelID Snowflake   `json:"channel_id,omitempty"` // :MOVE_MEMBERS
}

ModifyGuildMemberParams https://discordapp.com/developers/docs/resources/guild#modify-guild-member-json-params

type ModifyGuildParams added in v0.6.0

type ModifyGuildParams struct {
	Name                    string                        `json:"name,omitempty"`
	Region                  string                        `json:"region,omitempty"`
	VerificationLvl         int                           `json:"verification_level,omitempty"`
	DefaultMsgNotifications DefaultMessageNotificationLvl `json:"default_message_notifications,omitempty"`
	ExplicitContentFilter   ExplicitContentFilterLvl      `json:"explicit_content_filter,omitempty"`
	AFKChannelID            Snowflake                     `json:"afk_channel_id,omitempty"`
	AFKTimeout              int                           `json:"afk_timeout,omitempty"`
	Icon                    string                        `json:"icon,omitempty"`
	OwnerID                 Snowflake                     `json:"owner_id,omitempty"`
	Splash                  string                        `json:"splash,omitempty"`
	SystemChannelID         Snowflake                     `json:"system_channel_id,omitempty"`
}

ModifyGuildParams https://discordapp.com/developers/docs/resources/guild#modify-guild-json-params

type ModifyGuildRoleParams added in v0.6.0

type ModifyGuildRoleParams struct {
	Name        string `json:"name,omitempty"`
	Permissions int    `json:"permissions,omitempty"`
	Color       int    `json:"color,omitempty"`
	Hoist       bool   `json:"hoist,omitempty"`
	Mentionable bool   `json:"mentionable,omitempty"`
}

ModifyGuildRoleParams JSON params for func ModifyGuildRole

type ModifyGuildRolePositionsParams added in v0.6.0

type ModifyGuildRolePositionsParams struct {
	ID       Snowflake `json:"id"`
	Position int       `json:"position"`
}

ModifyGuildRolePositionsParams https://discordapp.com/developers/docs/resources/guild#modify-guild-role-positions-json-params

type PartialChannel added in v0.6.0

type PartialChannel = Channel

type PartialEmoji added in v0.6.0

type PartialEmoji = Emoji

type PartialGuild added in v0.6.0

type PartialGuild = Guild

Guild Guilds in Discord represent an isolated collection of users and channels,

and are often referred to as "servers" in the UI.

https://discordapp.com/developers/docs/resources/guild#guild-object Fields with `*` are only sent within the GUILD_CREATE event TODO: lazyload everything reviewed: 2018-08-25

type PartialInvite added in v0.6.0

type PartialInvite = Invite

PartialInvite

{
   "code": "abc"
}

func GetGuildVanityURL added in v0.6.0

func GetGuildVanityURL(client httd.Getter, guildID Snowflake) (ret *PartialInvite, err error)

GetGuildVanityURL [GET] Returns a partial invite object for guilds with that feature enabled.

Requires the 'MANAGE_GUILD' permission.

Endpoint /guilds/{guild.id}/vanity-url Rate limiter /guilds/{guild.id}/vanity-url Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-vanity-url Reviewed 2018-08-18 Comment -

type PermissionOverwrite added in v0.6.0

type PermissionOverwrite struct {
	ID    Snowflake `json:"id"`    // role or user id
	Type  string    `json:"type"`  // either `role` or `member`
	Allow int       `json:"allow"` // permission bit set
	Deny  int       `json:"deny"`  // permission bit set
}

Overwrite: https://discordapp.com/developers/docs/resources/channel#overwrite-object

func (*PermissionOverwrite) Clear added in v0.6.0

func (pmo *PermissionOverwrite) Clear()

type PresenceUpdate added in v0.6.0

type PresenceUpdate struct {
	User    *User         `json:"user"`
	RoleIDs []Snowflake   `json:"roles"`
	Game    *UserActivity `json:"game"`
	GuildID Snowflake     `json:"guild_id"`

	// Status either "idle", "dnd", "online", or "offline"
	// TODO: constants somewhere..
	Status string          `json:"status"`
	Ctx    context.Context `json:"-"`
}

PresenceUpdate user's presence was updated in a guild

type PresenceUpdateCallback

type PresenceUpdateCallback = func(session Session, pu *PresenceUpdate)

PresenceUpdateCallback triggered on PRESENCE_UPDATE events

type Reaction added in v0.6.0

type Reaction struct {
	Count uint          `json:"count"`
	Me    bool          `json:"me"`
	Emoji *PartialEmoji `json:"Emoji"`
}

https://discordapp.com/developers/docs/resources/channel#reaction-object

func CreateReaction added in v0.6.0

func CreateReaction(client httd.Puter, channelID, messageID Snowflake, emoji interface{}) (ret *Reaction, err error)

CreateReaction [PUT] 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.

Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me Rate limiter [MAJOR] /channels/{channel.id}/messages TODO: I have no idea what the key is Discord documentation https://discordapp.com/developers/docs/resources/channel#create-reaction Reviewed 2018-06-07 Comment - emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom

type Ready added in v0.6.0

type Ready struct {
	APIVersion int                 `json:"v"`
	User       *User               `json:"user"`
	Guilds     []*GuildUnavailable `json:"guilds"`

	// not really needed, as it is handled on the socket layer.
	SessionID string   `json:"session_id"`
	Trace     []string `json:"_trace"`

	sync.RWMutex `json:"-"`
	Ctx          context.Context `json:"-"`
}

Ready contains the initial state information

type ReadyCallback

type ReadyCallback = func(session Session, r *Ready)

ReadyCallback triggered on READY events

type Resumed added in v0.6.0

type Resumed struct {
	Trace []string        `json:"_trace"`
	Ctx   context.Context `json:"-"`
}

Resumed response to Resume

type ResumedCallback

type ResumedCallback = func(session Session, r *Resumed)

ResumedCallback triggered on RESUME events

type Role added in v0.6.0

type Role struct {
	ID          Snowflake `json:"id"`
	Name        string    `json:"name"`
	Color       int       `json:"color"`
	Hoist       bool      `json:"hoist"`
	Position    int       `json:"position"`
	Permissions uint64    `json:"permissions"`
	Managed     bool      `json:"managed"`
	Mentionable bool      `json:"mentionable"`
}

Role https://discordapp.com/developers/docs/topics/permissions#role-object

func CreateGuildRole added in v0.6.0

func CreateGuildRole(client httd.Poster, id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error)

CreateGuildRole [POST] Create a new role for the guild. Requires the 'MANAGE_ROLES' permission.

Returns the new role object on success. Fires a Guild Role Create Gateway event.

Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#create-guild-role Reviewed 2018-08-18 Comment All JSON params are optional.

func GetGuildRoles added in v0.6.0

func GetGuildRoles(client httd.Getter, guildID Snowflake) (ret []*Role, err error)

GetGuildRoles [GET] Returns a list of role objects for the guild. Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-roles Reviewed 2018-08-18 Comment -

func ModifyGuildRole added in v0.6.0

func ModifyGuildRole(client httd.Patcher, guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret []*Role, err error)

ModifyGuildRole [PATCH] Modify a guild role. Requires the 'MANAGE_ROLES' permission. Returns the updated

role on success. Fires a Guild Role Update Gateway event.

Endpoint /guilds/{guild.id}/roles/{role.id} Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-role Reviewed 2018-08-18 Comment -

func ModifyGuildRolePositions added in v0.6.0

func ModifyGuildRolePositions(client httd.Patcher, guildID Snowflake, params *ModifyGuildRolePositionsParams) (ret []*Role, err error)

ModifyGuildRolePositions [PATCH] Modify the positions of a set of role objects for the guild. Requires the

'MANAGE_ROLES' permission. Returns a list of all of the guild's role objects
on success. Fires multiple Guild Role Update Gateway events.

Endpoint /guilds/{guild.id}/roles Rate limiter /guilds/{guild.id}/roles Discord documentation https://discordapp.com/developers/docs/resources/guild#modify-guild-role-positions Reviewed 2018-08-18 Comment -

func NewRole added in v0.6.0

func NewRole() *Role

func (*Role) Clear added in v0.6.0

func (r *Role) Clear()

func (*Role) Mention added in v0.6.0

func (r *Role) Mention() string

type Session

type Session interface {

	// Request For interacting with Discord. Sending messages, creating channels, guilds, etc.
	// To read object state such as guilds, State() should be used in stead. However some data
	// might not exist in the state. If so it should be requested. Note that this only holds http
	// CRUD operation and not the actual rest endpoints for discord (See Rest()).
	Req() httd.Requester

	// Event let's developers listen for specific events, event groups, or every event as one listener.
	// Supports both channels and callbacks
	Evt() EvtDispatcher

	// State reflects the latest changes received from Discord gateway.
	// Should be used instead of requesting objects.
	State() Cacher

	// RateLimiter the ratelimiter for the discord REST API
	RateLimiter() httd.RateLimiter

	// Discord Gateway, web socket
	//
	Connect() error
	Disconnect() error
	DisconnectOnInterrupt() error

	// event callbacks
	AddListener(evtName string, callback interface{})
	AddListenerOnce(evtName string, callback interface{})

	// all discord REST functions
	// TODO: support caching for each
	// Audit-log
	GetGuildAuditLogs(guildID Snowflake, params *GuildAuditLogsParams) (log *AuditLog, err error)
	// Channel
	GetChannel(id Snowflake) (ret *Channel, err error)
	ModifyChannel(changes *ModifyChannelParams) (ret *Channel, err error)
	DeleteChannel(id Snowflake) (err error)
	EditChannelPermissions(chanID, overwriteID Snowflake, params *EditChannelPermissionsParams) (err error)
	GetChannelInvites(id Snowflake) (ret []*Invite, err error)
	CreateChannelInvites(id Snowflake, params *CreateChannelInvitesParams) (ret *Invite, err error)
	DeleteChannelPermission(channelID, overwriteID Snowflake) (err error)
	TriggerTypingIndicator(channelID Snowflake) (err error)
	GetPinnedMessages(channelID Snowflake) (ret []*Message, err error)
	AddPinnedChannelMessage(channelID, msgID Snowflake) (err error)
	DeletePinnedChannelMessage(channelID, msgID Snowflake) (err error)
	GroupDMAddRecipient(channelID, userID Snowflake, params *GroupDMAddRecipientParams) (err error)
	GroupDMRemoveRecipient(channelID, userID Snowflake) (err error)
	GetChannelMessages(channelID Snowflake, params URLParameters) (ret []*Message, err error)
	GetChannelMessage(channelID, messageID Snowflake) (ret *Message, err error)
	CreateChannelMessage(channelID Snowflake, params *CreateChannelMessageParams) (ret *Message, err error)
	EditMessage(chanID, msgID Snowflake, params *EditMessageParams) (ret *Message, err error)
	DeleteMessage(channelID, msgID Snowflake) (err error)
	BulkDeleteMessages(chanID Snowflake, params *BulkDeleteMessagesParams) (err error)
	CreateReaction(channelID, messageID Snowflake, emoji interface{}) (ret *Reaction, err error)
	DeleteOwnReaction(channelID, messageID Snowflake, emoji interface{}) (err error)
	DeleteUserReaction(channelID, messageID, userID Snowflake, emoji interface{}) (err error)
	GetReaction(channelID, messageID Snowflake, emoji interface{}, params URLParameters) (ret []*User, err error)
	DeleteAllReactions(channelID, messageID Snowflake) (err error)
	// Emoji
	GetGuildEmojis(id Snowflake) (ret []*Emoji, err error)
	GetGuildEmoji(guildID, emojiID Snowflake) (ret *Emoji, err error)
	CreateGuildEmoji(guildID Snowflake, params *CreateGuildEmojiParams) (ret *Emoji, err error)
	ModifyGuildEmoji(guildID, emojiID Snowflake, params *ModifyGuildEmojiParams) (ret *Emoji, err error)
	DeleteGuildEmoji(guildID, emojiID Snowflake) (err error)
	// Guild
	CreateGuild(params *CreateGuildParams) (ret *Guild, err error)
	GetGuild(id Snowflake) (ret *Guild, err error)
	ModifyGuild(id Snowflake, params *ModifyGuildParams) (ret *Guild, err error)
	DeleteGuild(id Snowflake) (err error)
	GetGuildChannels(id Snowflake) (ret []*Channel, err error)
	CreateGuildChannel(id Snowflake, params *CreateGuildChannelParams) (ret *Channel, err error)
	GetGuildMember(guildID, userID Snowflake) (ret *Member, err error)
	GetGuildMembers(guildID, after Snowflake, limit int) (ret []*Member, err error)
	AddGuildMember(guildID, userID Snowflake, params *AddGuildMemberParams) (ret *Member, err error)
	ModifyGuildMember(guildID, userID Snowflake, params *ModifyGuildMemberParams) (err error)
	ModifyCurrentUserNick(id Snowflake, params *ModifyCurrentUserNickParams) (nick string, err error)
	AddGuildMemberRole(guildID, userID, roleID Snowflake) (err error)
	RemoveGuildMemberRole(guildID, userID, roleID Snowflake) (err error)
	RemoveGuildMember(guildID, userID Snowflake) (err error)
	GetGuildBans(id Snowflake) (ret []*Ban, err error)
	GetGuildBan(guildID, userID Snowflake) (ret *Ban, err error)
	CreateGuildBan(guildID, userID Snowflake, params *CreateGuildBanParams) (err error)
	RemoveGuildBan(guildID, userID Snowflake) (err error)
	GetGuildRoles(guildID Snowflake) (ret []*Role, err error)
	CreateGuildRole(id Snowflake, params *CreateGuildRoleParams) (ret *Role, err error)
	ModifyGuildRolePositions(guildID Snowflake, params *ModifyGuildRolePositionsParams) (ret []*Role, err error)
	ModifyGuildRole(guildID, roleID Snowflake, params *ModifyGuildRoleParams) (ret []*Role, err error)
	DeleteGuildRole(guildID, roleID Snowflake) (err error)
	GetGuildPruneCount(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)
	BeginGuildPrune(id Snowflake, params *GuildPruneParams) (ret *GuildPruneCount, err error)
	GetGuildVoiceRegions(id Snowflake) (ret []*VoiceRegion, err error)
	GetGuildInvites(id Snowflake) (ret []*Invite, err error)
	GetGuildIntegrations(id Snowflake) (ret []*Integration, err error)
	CreateGuildIntegration(guildID Snowflake, params *CreateGuildIntegrationParams) (err error)
	ModifyGuildIntegration(guildID, integrationID Snowflake, params *ModifyGuildIntegrationParams) (err error)
	DeleteGuildIntegration(guildID, integrationID Snowflake) (err error)
	SyncGuildIntegration(guildID, integrationID Snowflake) (err error)
	GetGuildEmbed(guildID Snowflake) (ret *GuildEmbed, err error)
	ModifyGuildEmbed(guildID Snowflake, params *GuildEmbed) (ret *GuildEmbed, err error)
	GetGuildVanityURL(guildID Snowflake) (ret *PartialInvite, err error)
	// Invite
	GetInvite(inviteCode string, withCounts bool) (invite *Invite, err error)
	DeleteInvite(inviteCode string) (invite *Invite, err error)
	// User
	GetCurrentUser() (ret *User, err error)
	GetUser(id Snowflake) (ret *User, err error)
	ModifyCurrentUser(params *ModifyCurrentUserParams) (ret *User, err error)
	GetCurrentUserGuilds(params *GetCurrentUserGuildsParams) (ret []*Guild, err error)
	LeaveGuild(id Snowflake) (err error)
	GetUserDMs() (ret []*Channel, err error)
	CreateDM(recipientID Snowflake) (ret *Channel, err error)
	CreateGroupDM(params *CreateGroupDMParams) (ret *Channel, err error)
	GetUserConnections() (ret []*UserConnection, err error)
	// Voice
	GetVoiceRegions() (ret []*VoiceRegion, err error)
	// Webhook
	CreateWebhook(channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error)
	GetChannelWebhooks(channelID Snowflake) (ret []*Webhook, err error)
	GetGuildWebhooks(guildID Snowflake) (ret []*Webhook, err error)
	GetWebhook(id Snowflake) (ret *Webhook, err error)
	GetWebhookWithToken(id Snowflake, token string) (ret *Webhook, err error)
	ModifyWebhook(newWebhook *Webhook) (ret *Webhook, err error)
	ModifyWebhookWithToken(newWebhook *Webhook) (ret *Webhook, err error)
	DeleteWebhook(webhookID Snowflake) (err error)
	DeleteWebhookWithToken(id Snowflake, token string) (err error)
	ExecuteWebhook(params *ExecuteWebhookParams, wait bool, URLSuffix string) (err error)
	ExecuteSlackWebhook(params *ExecuteWebhookParams, wait bool) (err error)
	ExecuteGitHubWebhook(params *ExecuteWebhookParams, wait bool) (err error)
	// Custom
	SendMsg(channelID Snowflake, message *Message) (msg *Message, err error)
	SendMsgString(channelID Snowflake, content string) (msg *Message, err error)
	UpdateMessage(message *Message) (msg *Message, err error)
	UpdateChannel(channel *Channel) (err error)
}

Session the discord api is split in two. socket for keeping the client up to date, and http api for requests.

func NewSession

func NewSession(conf *Config) (Session, error)

NewSession create a client and return the Session interface

func NewSessionMustCompile

func NewSessionMustCompile(conf *Config) Session

NewSessionMustCompile same as NewClientMustCompile, but with the Session interface

type Snowflake added in v0.6.0

type Snowflake = snowflake.Snowflake

Snowflake twitter snowflake identification for Discord

func GetSnowflake added in v0.6.0

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

func NewSnowflake added in v0.6.0

func NewSnowflake(id uint64) Snowflake

func ParseSnowflakeString added in v0.6.0

func ParseSnowflakeString(v string) Snowflake

type Timestamp added in v0.6.0

type Timestamp time.Time

func (Timestamp) String added in v0.6.0

func (t Timestamp) String() string

String converts the timestamp into a discord formatted timestamp. time.RFC3331 does not suffice

func (Timestamp) Time added in v0.6.0

func (t Timestamp) Time() time.Time

Time converts the DiscordTimestamp into a time.Time type.......

func (*Timestamp) UnmarshalJSON added in v0.6.0

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

type TypingStart added in v0.6.0

type TypingStart struct {
	ChannelID     Snowflake       `json:"channel_id"`
	UserID        Snowflake       `json:"user_id"`
	TimestampUnix int             `json:"timestamp"`
	Ctx           context.Context `json:"-"`
}

TypingStart user started typing in a channel

type TypingStartCallback

type TypingStartCallback = func(session Session, ts *TypingStart)

TypingStartCallback triggered on TYPING_START events

type URLParameters added in v0.6.0

type URLParameters interface {
	GetQueryString() string
}

URLParameters converts a struct of values to a valid URL query string

type Unmarshaler added in v0.6.0

type Unmarshaler interface {
	UnmarshalJSON(data []byte) error
}

type User added in v0.6.0

type User struct {
	ID            Snowflake `json:"id,omitempty"`
	Username      string    `json:"username,omitempty"`
	Discriminator string    `json:"discriminator,omitempty"`
	Email         string    `json:"email,omitempty"`
	Avatar        *string   `json:"avatar"` // data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA //TODO: pointer?
	Token         string    `json:"token,omitempty"`
	Verified      bool      `json:"verified,omitempty"`
	MFAEnabled    bool      `json:"mfa_enabled,omitempty"`
	Bot           bool      `json:"bot,omitempty"`

	sync.RWMutex `json:"-"`
}

func GetCurrentUser added in v0.6.0

func GetCurrentUser(client httd.Getter) (ret *User, err error)

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

Endpoint /users/@me Rate limiter /users Discord documentation https://discordapp.com/developers/docs/resources/user#get-current-user Reviewed 2018-06-10 Comment -

func GetReaction added in v0.6.0

func GetReaction(client httd.Getter, channelID, messageID Snowflake, emoji interface{}, params URLParameters) (ret []*User, err error)

GetReaction [GET] Get a list of users that reacted with this emoji. Returns an array of user objects on success. Endpoint /channels/{channel.id}/messages/{message.id}/reactions/{emoji} Rate limiter [MAJOR] /channels/{channel.id}/messages TODO: I have no idea if this is the correct key Discord documentation https://discordapp.com/developers/docs/resources/channel#get-reactions Reviewed 2018-06-07 Comment - emoji either unicode (string) or *Emoji with an snowflake Snowflake if it's custom

func GetUser added in v0.6.0

func GetUser(client httd.Getter, id Snowflake) (ret *User, err error)

GetUser [GET] Returns a user object for a given user Snowflake. Endpoint /users/{user.id} Rate limiter /users Discord documentation https://discordapp.com/developers/docs/resources/user#get-user Reviewed 2018-06-10 Comment -

func ModifyCurrentUser added in v0.6.0

func ModifyCurrentUser(client httd.Patcher, params *ModifyCurrentUserParams) (ret *User, err error)

ModifyCurrentUser [PATCH] Modify the requester's user account settings. Returns a user object on success. Endpoint /users/@me Rate limiter /users Discord documentation https://discordapp.com/developers/docs/resources/user#modify-current-user Reviewed 2018-06-10 Comment -

func NewUser added in v0.6.0

func NewUser() *User

TODO: should a user object always have a Snowflake?

func (*User) Clear added in v0.6.0

func (u *User) Clear()

func (*User) DeepCopy added in v0.6.0

func (u *User) DeepCopy() *User

func (*User) MarshalJSON added in v0.6.0

func (u *User) MarshalJSON() ([]byte, error)

func (*User) Mention added in v0.6.0

func (u *User) Mention() string

func (*User) MentionNickname added in v0.6.0

func (u *User) MentionNickname() string

func (*User) Partial added in v0.6.0

func (u *User) Partial() bool

Partial check if this is not a complete user object Assumption: has a snowflake.

func (*User) SendMsg added in v0.6.0

func (u *User) SendMsg(session Session, message *Message) (channel *Channel, msg *Message, err error)

func (*User) SendMsgString added in v0.6.0

func (u *User) SendMsgString(session Session, content string) (channel *Channel, msg *Message, err error)

func (*User) String added in v0.6.0

func (u *User) String() string

func (*User) Valid added in v0.6.0

func (u *User) Valid() bool

type UserConnection added in v0.6.0

type UserConnection struct {
	ID           string                `json:"id"`           // id of the connection account
	Name         string                `json:"name"`         // the username of the connection account
	Type         string                `json:"type"`         // the service of the connection (twitch, youtube)
	Revoked      bool                  `json:"revoked"`      // whether the connection is revoked
	Integrations []*IntegrationAccount `json:"integrations"` // an array of partial server integrations
}

func GetUserConnections added in v0.6.0

func GetUserConnections(client httd.Getter) (ret []*UserConnection, err error)

GetUserConnections [GET] Returns a list of connection objects. Requires the connections OAuth2 scope. Endpoint /users/@me/connections Rate limiter /users TODO: is this correct? Discord documentation https://discordapp.com/developers/docs/resources/user#get-user-connections Reviewed 2018-06-10 Comment -

type UserInterface added in v0.6.0

type UserInterface interface {
	Mention() string
	MentionNickname() string
	String() string
}

type UserPresence added in v0.6.0

type UserPresence struct {
	User    *User         `json:"user"`
	Roles   []Snowflake   `json:"roles"`
	Game    *UserActivity `json:"activity"`
	GuildID Snowflake     `json:"guild_id"`
	Nick    string        `json:"nick"`
	Status  string        `json:"status"`
}

func NewUserPresence added in v0.6.0

func NewUserPresence() *UserPresence

func (*UserPresence) Clear added in v0.6.0

func (p *UserPresence) Clear()

func (*UserPresence) String added in v0.6.0

func (p *UserPresence) String() string

func (*UserPresence) Update added in v0.6.0

func (p *UserPresence) Update(status string)

type UserUpdate added in v0.6.0

type UserUpdate struct {
	User *User           `json:"user"`
	Ctx  context.Context `json:"-"`
}

UserUpdate properties about a user changed

type UserUpdateCallback

type UserUpdateCallback = func(session Session, uu *UserUpdate)

UserUpdateCallback triggerd on USER_UPDATE events

type VerificationLvl added in v0.6.0

type VerificationLvl uint

Verification ... https://discordapp.com/developers/docs/resources/guild#guild-object-verification-level

func (*VerificationLvl) High added in v0.6.0

func (vl *VerificationLvl) High() bool

High (╯°□°)╯︵ ┻━┻ - must be a member of the server for longer than 10 minutes

func (*VerificationLvl) Low added in v0.6.0

func (vl *VerificationLvl) Low() bool

Low must have verified email on account

func (*VerificationLvl) Medium added in v0.6.0

func (vl *VerificationLvl) Medium() bool

Medium must be registered on Discord for longer than 5 minutes

func (*VerificationLvl) None added in v0.6.0

func (vl *VerificationLvl) None() bool

None unrestricted

func (*VerificationLvl) VeryHigh added in v0.6.0

func (vl *VerificationLvl) VeryHigh() bool

VeryHigh ┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻ - must have a verified phone number

type VoiceRegion added in v0.6.0

type VoiceRegion struct {
	// Snowflake unique Snowflake for the region
	ID string `json:"id"`

	// Name name of the region
	Name string `json:"name"`

	// SampleHostname an example hostname for the region
	SampleHostname string `json:"sample_hostname"`

	// SamplePort an example port for the region
	SamplePort uint `json:"sample_port"`

	// VIP true if this is a vip-only server
	VIP bool `json:"vip"`

	// Optimal true for a single server that is closest to the current user's client
	Optimal bool `json:"optimal"`

	// Deprecated 	whether this is a deprecated voice region (avoid switching to these)
	Deprecated bool `json:"deprecated"`

	// Custom whether this is a custom voice region (used for events/etc)
	Custom bool `json:"custom"`
}

Region voice region structure https://discordapp.com/developers/docs/resources/voice#voice-region

func GetGuildVoiceRegions added in v0.6.0

func GetGuildVoiceRegions(client httd.Getter, id Snowflake) (ret []*VoiceRegion, err error)

GetGuildVoiceRegions [GET] Returns a list of voice region objects for the guild. Unlike the similar /voice

route, this returns VIP servers when the guild is VIP-enabled.

Endpoint /guilds/{guild.id}/regions Rate limiter /guilds/{guild.id}/regions Discord documentation https://discordapp.com/developers/docs/resources/guild#get-guild-voice-regions Reviewed 2018-08-18 Comment -

func ListVoiceRegions added in v0.6.0

func ListVoiceRegions(client httd.Getter) (ret []*VoiceRegion, err error)

ListVoiceRegions [GET] Returns an array of voice region objects that can be used when creating servers. Endpoint /voice/regions Rate limiter /voice/regions Discord documentation https://discordapp.com/developers/docs/resources/voice#list-voice-regions Reviewed 2018-08-21 Comment -

type VoiceServerUpdate added in v0.6.0

type VoiceServerUpdate struct {
	Token    string          `json:"token"`
	GuildID  Snowflake       `json:"guild_id"`
	Endpoint string          `json:"endpoint"`
	Ctx      context.Context `json:"-"`
}

VoiceServerUpdate guild's voice server was updated Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.

type VoiceServerUpdateCallback

type VoiceServerUpdateCallback = func(session Session, vsu *VoiceServerUpdate)

VoiceServerUpdateCallback triggered on VOICE_SERVER_UPDATE events

type VoiceState added in v0.6.0

type VoiceState struct {
	// GuildID the guild id this voice state is for
	GuildID Snowflake `json:"guild_id,omitempty"` // ? |

	// ChannelID the channel id this user is connected to
	ChannelID Snowflake `json:"channel_id"` // |

	// UserID the user id this voice state is for
	UserID Snowflake `json:"user_id"` // |

	// SessionID the session id for this voice state
	SessionID string `json:"session_id"` // |

	// Deaf whether this user is deafened by the server
	Deaf bool `json:"deaf"` // |

	// Mute whether this user is muted by the server
	Mute bool `json:"mute"` // |

	// SelfDeaf whether this user is locally deafened
	SelfDeaf bool `json:"self_deaf"` // |

	// SelfMute whether this user is locally muted
	SelfMute bool `json:"self_mute"` // |

	// Suppress whether this user is muted by the current user
	Suppress bool `json:"suppress"` // |
}

State Voice State structure https://discordapp.com/developers/docs/resources/voice#voice-state-object

func (*VoiceState) Clear added in v0.6.0

func (vst *VoiceState) Clear()

type VoiceStateUpdate added in v0.6.0

type VoiceStateUpdate struct {
	VoiceState *VoiceState     `json:"voice_state"`
	Ctx        context.Context `json:"-"`
}

VoiceStateUpdate someone joined, left, or moved a voice channel

type VoiceStateUpdateCallback

type VoiceStateUpdateCallback = func(session Session, vsu *VoiceStateUpdate)

VoiceStateUpdateCallback triggered on VOICE_STATE_UPDATE events

type Webhook added in v0.6.0

type Webhook struct {
	ID        Snowflake `json:"id"`                 //  |
	GuildID   Snowflake `json:"guild_id,omitempty"` //  |?
	ChannelID Snowflake `json:"channel_id"`         //  |
	User      *User     `json:"user,omitempty"`     // ?|
	Name      string    `json:"name"`               //  |?
	Avatar    string    `json:"avatar"`             //  |?
	Token     string    `json:"token"`              //  |
}

Webhook Used to represent a webhook https://discordapp.com/developers/docs/resources/webhook#webhook-object

func CreateWebhook added in v0.6.0

func CreateWebhook(client httd.Poster, channelID Snowflake, params *CreateWebhookParams) (ret *Webhook, err error)

CreateWebhook [POST] Create a new webhook. Requires the 'MANAGE_WEBHOOKS' permission.

Returns a webhook object on success.

Endpoint /channels/{channel.id}/webhooks Rate limiter /channels/{channel.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#create-webhook Reviewed 2018-08-14 Comment -

func GetChannelWebhooks added in v0.6.0

func GetChannelWebhooks(client httd.Getter, channelID Snowflake) (ret []*Webhook, err error)

GetChannelWebhooks [GET] Returns a list of channel webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. Endpoint /channels/{channel.id}/webhooks Rate limiter /channels/{channel.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-channel-webhooks Reviewed 2018-08-14 Comment -

func GetGuildWebhooks added in v0.6.0

func GetGuildWebhooks(client httd.Getter, guildID Snowflake) (ret []*Webhook, err error)

GetGuildWebhooks [GET] Returns a list of guild webhook objects. Requires the 'MANAGE_WEBHOOKS' permission. Endpoint /guilds/{guild.id}/webhooks Rate limiter /guilds/{guild.id}/webhooks Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-guild-webhooks Reviewed 2018-08-14 Comment -

func GetWebhook added in v0.6.0

func GetWebhook(client httd.Getter, id Snowflake) (ret *Webhook, err error)

GetWebhook [GET] Returns the new webhook object for the given id. Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-webhook Reviewed 2018-08-14 Comment -

func GetWebhookWithToken added in v0.6.0

func GetWebhookWithToken(client httd.Getter, id Snowflake, token string) (ret *Webhook, err error)

GetWebhookWithToken [GET] Same as GetWebhook, except this call does not require authentication and returns

no user in the webhook object.

Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#get-webhook-with-token Reviewed 2018-08-14 Comment -

func ModifyWebhook added in v0.6.0

func ModifyWebhook(client httd.Patcher, newWebhook *Webhook) (ret *Webhook, err error)

ModifyWebhook [PATCH] Modify a webhook. Requires the 'MANAGE_WEBHOOKS' permission.

Returns the updated webhook object on success.

Endpoint /webhooks/{webhook.id} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#modify-webhook Reviewed 2018-08-14 Comment All parameters to this endpoint. are optional. Not tested:extra json fields might

cause an issue. Consider writing a json params object.

func ModifyWebhookWithToken added in v0.6.0

func ModifyWebhookWithToken(client httd.Patcher, newWebhook *Webhook) (ret *Webhook, err error)

ModifyWebhookWithToken [PATCH] Same as ModifyWebhook, except this call does not require authentication,

does not accept a channel_id parameter in the body, and does not return
a user in the webhook object.

Endpoint /webhooks/{webhook.id}/{webhook.token} Rate limiter /webhooks/{webhook.id} Discord documentation https://discordapp.com/developers/docs/resources/webhook#modify-webhook-with-token Reviewed 2018-08-14 Comment All parameters to this endpoint. are optional. Not tested:extra json fields might

cause an issue. Consider writing a json params object.

type WebhooksUpdate added in v0.6.0

type WebhooksUpdate struct {
	GuildID   Snowflake       `json:"guild_id"`
	ChannelID Snowflake       `json:"channel_id"`
	Ctx       context.Context `json:"-"`
}

WebhooksUpdate guild channel webhook was created, update, or deleted

type WebhooksUpdateCallback

type WebhooksUpdateCallback = func(session Session, wu *WebhooksUpdate)

WebhooksUpdateCallback triggered on WEBHOOK_UPDATE events

Directories

Path Synopsis
endpoint holds all discord urls for the REST endpoints
endpoint holds all discord urls for the REST endpoints
generate
discorddocs Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL