Categorygithub.com/uplol/discordgo
modulepackage
0.19.1
Repository: https://github.com/uplol/discordgo.git
Documentation: pkg.go.dev

# README

DiscordGo

GoDoc Go report Build Status Discord Gophers Discord API

DiscordGo is a Go package that provides low level bindings to the Discord chat client API. DiscordGo has nearly complete support for all of the Discord API endpoints, websocket interface, and voice interface.

If you would like to help the DiscordGo package please use this link to add the official DiscordGo test bot dgo to your server. This provides indispensable help to this project.

  • See dgVoice package for an example of additional voice helper functions and features for DiscordGo.

  • See dca for an experimental stand alone tool that wraps ffmpeg to create opus encoded audio appropriate for use with Discord (and DiscordGo).

For help with this package or general Go discussion, please join the Discord Gophers chat server.

Getting Started

master vs develop Branch

  • The master branch represents the latest released version of DiscordGo. This branch will always have a stable and tested version of the library. Each release is tagged and you can easily download a specific release and view release notes on the github releases page.

  • The develop branch is where all development happens and almost always has new features over the master branch. However breaking changes are frequently added to develop and even sometimes bugs are introduced. Bugs get fixed and the breaking changes get documented before pushing to master.

So, what should you use?

If you can accept the constant changing nature of develop, it is the recommended branch to use. Otherwise, if you want to tail behind development slightly and have a more stable package with documented releases, use master.

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get will always pull the latest released version from the master branch.

go get github.com/bwmarrin/discordgo

If you want to use the develop branch, follow these steps next.

cd $GOPATH/src/github.com/bwmarrin/discordgo
git checkout develop

Usage

Import the package into your project.

import "github.com/bwmarrin/discordgo"

Construct a new Discord client which can be used to access the variety of Discord API functions and to set callback functions for Discord events.

discord, err := discordgo.New("Bot " + "authentication token")

See Documentation and Examples below for more detailed information.

Documentation

NOTICE : This library and the Discord API are unfinished. Because of that there may be major changes to library in the future.

The DiscordGo code is fairly well documented at this point and is currently the only documentation available. Both GoDoc and GoWalker (below) present that information in a nice format.

  • GoDoc
  • Go Walker
  • Hand crafted documentation coming eventually.

Examples

Below is a list of examples and other projects using DiscordGo. Please submit an issue if you would like your project added or removed from this list.

Troubleshooting

For help with common problems please reference the Troubleshooting section of the project wiki.

Contributing

Contributions are very welcomed, however please follow the below guidelines.

  • First open an issue describing the bug or enhancement so it can be discussed.
  • Fork the develop branch and make your changes.
  • Try to match current naming conventions as closely as possible.
  • This package is intended to be a low level direct mapping of the Discord API, so please avoid adding enhancements outside of that scope without first discussing it.
  • Create a Pull Request with your changes against the develop branch.

List of Discord APIs

See this chart for a feature comparison and list of other Discord API libraries.

Special Thanks

Chris Rhodes - For the DiscordGo logo and tons of PRs.

# Packages

No description provided by the author
No description provided by the author

# Functions

New creates a new Discord session and will automate some startup tasks if given enough information to do so.
NewMessageEdit returns a MessageEdit struct, initialized with the Channel and ID.
NewRatelimiter returns a new RateLimiter.
NewState creates an empty state.

# Constants

Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains Discord Audit Log Action Types.
Block contains known ChannelType values.
Block contains known ChannelType values.
Block contains known ChannelType values.
Block contains known ChannelType values.
Block contains known ChannelType values.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Block contains Discord JSON Error Response codes.
Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive.
Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive.
Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive.
FailedHeartbeatAcks is the Number of heartbeat intervals to wait until forcing a connection restart.
Valid GameType values.
Valid GameType values.
Valid GameType values.
Valid GameType values.
LogDebug level is for very detailed non-error activity.
LogError level is used for critical errors that could lead to data loss or panic that would not be returned to a calling function.
LogInformational level is used for normal non-error activity.
LogWarning level is used for very abnormal events and errors that are also returned to a calling function.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Block contains the valid known MessageType values.
Constants for MfaLevel levels from 0 to 1 inclusive.
Constants for MfaLevel levels from 0 to 1 inclusive.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of general permissions.
Constants for general management.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of general permissions.
Constants for general management.
Constants for the different bit offsets of text channel permissions.
Constants for general management.
Constants for general management.
Constants for the different bit offsets of general permissions.
Constants for general management.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of text channel permissions.
Constants for the different bit offsets of general permissions.
Constants for the different bit offsets of voice permissions.
Constants for the different bit offsets of voice permissions.
Constants for the different bit offsets of voice permissions.
Constants for the different bit offsets of voice permissions.
Constants for the different bit offsets of voice permissions.
Constants for the different bit offsets of voice permissions.
Constants for Status with the different current available status.
Constants for Status with the different current available status.
Constants for Status with the different current available status.
Constants for Status with the different current available status.
Constants for Status with the different current available status.
Constants for VerificationLevel levels from 0 to 4 inclusive.
Constants for VerificationLevel levels from 0 to 4 inclusive.
Constants for VerificationLevel levels from 0 to 4 inclusive.
Constants for VerificationLevel levels from 0 to 4 inclusive.
Constants for VerificationLevel levels from 0 to 4 inclusive.
VERSION of DiscordGo, follows Semantic Versioning.

# Variables

APIVersion is the Discord API version used for the REST and Websocket API.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
Known Discord API Endpoints.
All error constants.
All error constants.
All error constants.
ErrMFA will be risen by New when the user has 2FA.
ErrNilState is returned when the state is nil.
All error constants.
ErrStateNotFound is returned when the state cache requested is not found.
All error constants.
All error constants.
All error constants.
ErrWSAlreadyOpen is thrown when you attempt to open a websocket that already is open.
ErrWSNotFound is thrown when you attempt to use a websocket that doesn't exist.
ErrWSShardBounds is thrown when you try to use a shard ID that is less than the total shard count.
Logger can be used to replace the standard logging for discordgo.

# Structs

An Ack is used to ack messages.
An APIErrorMessage is an api error message returned from discord.
An Application struct stores values for a Discord OAuth2 Application.
An Assets struct contains assets and labels used in the rich presence "playing .." Game.
Bucket represents a ratelimit bucket, each bucket gets ratelimited individually (-global ratelimits).
A Channel holds all data related to an individual Discord channel.
ChannelCreate is the data for a ChannelCreate event.
ChannelDelete is the data for a ChannelDelete event.
A ChannelEdit holds Channel Field data for a channel edit.
ChannelPinsUpdate stores data for a ChannelPinsUpdate event.
ChannelUpdate is the data for a ChannelUpdate event.
Connect is the data for a Connect event.
Disconnect is the data for a Disconnect event.
Emoji struct holds data related to Emoji's.
Event provides a basic initial struct for all websocket events.
File stores info about files you e.g.
FriendSourceFlags stores ..
A Game struct holds the name of the "playing .." game for a user.
GatewayBotResponse stores the data for the gateway/bot response.
A Guild holds all data related to a specific Discord Guild.
A GuildAuditLog stores data for a guild audit log.
A GuildBan stores data for a guild ban.
GuildBanAdd is the data for a GuildBanAdd event.
GuildBanRemove is the data for a GuildBanRemove event.
GuildChannelCreateData is provided to GuildChannelCreateComplex.
GuildCreate is the data for a GuildCreate event.
GuildDelete is the data for a GuildDelete event.
A GuildEmbed stores data for a guild embed.
A GuildEmojisUpdate is the data for a guild emoji update event.
GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event.
GuildMemberAdd is the data for a GuildMemberAdd event.
GuildMemberRemove is the data for a GuildMemberRemove event.
A GuildMembersChunk is the data for a GuildMembersChunk event.
GuildMemberUpdate is the data for a GuildMemberUpdate event.
A GuildParams stores all the data needed to update discord guild settings.
A GuildRole stores data for guild roles.
GuildRoleCreate is the data for a GuildRoleCreate event.
A GuildRoleDelete is the data for a GuildRoleDelete event.
GuildRoleUpdate is the data for a GuildRoleUpdate event.
GuildUpdate is the data for a GuildUpdate event.
A ICEServer stores data for a specific voice ICE server.
Integration stores integration information.
IntegrationAccount is integration account information sent by the UserConnections endpoint.
A Invite stores all data related to a specific Discord Guild or Channel invite.
A Member stores user information for Guild members.
A Message stores all data related to a specific Discord message.
MessageAck is the data for a MessageAck event.
A MessageAttachment stores data for message attachments.
MessageCreate is the data for a MessageCreate event.
MessageDelete is the data for a MessageDelete event.
MessageDeleteBulk is the data for a MessageDeleteBulk event.
MessageEdit is used to chain parameters via ChannelMessageEditComplex, which is also where you should get the instance from.
An MessageEmbed stores data for message embeds.
MessageEmbedAuthor is a part of a MessageEmbed struct.
MessageEmbedField is a part of a MessageEmbed struct.
MessageEmbedFooter is a part of a MessageEmbed struct.
MessageEmbedImage is a part of a MessageEmbed struct.
MessageEmbedProvider is a part of a MessageEmbed struct.
MessageEmbedThumbnail is a part of a MessageEmbed struct.
MessageEmbedVideo is a part of a MessageEmbed struct.
MessageReaction stores the data for a message reaction.
MessageReactionAdd is the data for a MessageReactionAdd event.
MessageReactionRemove is the data for a MessageReactionRemove event.
MessageReactionRemoveAll is the data for a MessageReactionRemoveAll event.
MessageReactions holds a reactions object for a message.
MessageSend stores all parameters you can send with ChannelMessageSendComplex.
MessageUpdate is the data for a MessageUpdate event.
A Packet contains the headers and content of a received voice packet.
A PermissionOverwrite holds permission overwrite data for a Channel.
A Presence stores the online, offline, or idle and game status of Guild members.
PresenceUpdate is the data for a PresenceUpdate event.
RateLimit is the data for a RateLimit event.
RateLimiter holds all ratelimit buckets.
A ReadState stores data on the read state of channels.
A Ready stores all data for the websocket READY event.
A Relationship between the logged in user and Relationship.User.
RelationshipAdd is the data for a RelationshipAdd event.
RelationshipRemove is the data for a RelationshipRemove event.
RESTError stores error information about a request with a bad response code.
Resumed is the data for a Resumed event.
A Role stores information about Discord guild member roles.
A Session represents a connection to the Discord API.
A Settings stores data for a specific users Discord client settings.
A State contains the current known state.
A TimeStamps struct contains start and end times used in the rich presence "playing .." Game.
A TooManyRequests struct holds information received from Discord when receiving a HTTP 429 response.
TypingStart is the data for a TypingStart event.
UpdateStatusData ia provided to UpdateStatusComplex().
A User stores all data for an individual Discord user.
UserConnection is a Connection returned from the UserConnections endpoint.
A UserGuild holds a brief version of a Guild.
A UserGuildSettings stores data for a users guild settings.
A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
A UserGuildSettingsEdit stores data for editing UserGuildSettings.
UserGuildSettingsUpdate is the data for a UserGuildSettingsUpdate event.
UserNoteUpdate is the data for a UserNoteUpdate event.
UserUpdate is the data for a UserUpdate event.
A VoiceConnection struct holds all the data and functions related to a Discord Voice Connection.
A VoiceICE stores data for voice ICE servers.
A VoiceRegion stores data for a specific voice region server.
VoiceServerUpdate is the data for a VoiceServerUpdate event.
VoiceSpeakingUpdate is a struct for a VoiceSpeakingUpdate event.
A VoiceState stores the voice states of Guilds.
VoiceStateUpdate is the data for a VoiceStateUpdate event.
Webhook stores the data for a webhook.
WebhookParams is a struct for webhook params, used in the WebhookExecute command.
WebhooksUpdate is the data for a WebhooksUpdate event.

# Interfaces

EventHandler is an interface for Discord events.
EventInterfaceProvider is an interface for providing empty interfaces for Discord events.

# Type aliases

ChannelType is the type of a Channel.
ExplicitContentFilterLevel type definition.
GameType is the type of "game" (see GameType* consts) in the Game struct.
MessageType is the type of Message.
MfaLevel type definition.
PresencesReplace is the data for a PresencesReplace event.
Roles are a collection of Role.
Status type definition.
Timestamp stores a timestamp, as sent by the Discord API.
UserSettingsUpdate is the data for a UserSettingsUpdate event.
VerificationLevel type definition.
VoiceSpeakingUpdateHandler type provides a function definition for the VoiceSpeakingUpdate event.