Documentation ¶
Overview ¶
Package harmony provides an interface to the Discord API (https://discord.com/developers/docs/intro).
Getting started ¶
The first thing you do with Harmony is to create a Client. NewClient does just that by returning a new Client pre-configured with sain defaults which should work fine in most cases. However, should you need a more specific configuration, you can always tweak it with optional `ClientOption`s. See the documentation of NewClient and the ClientOption type for more information on how to do so.
client, err := harmony.NewClient("your.bot.token") if err != nil { // Handle error }
Once you have a Client, you can start interacting with the Discord API, but some methods (such as event handlers) won't be available until you connect to Discord's Gateway. You can do so by simply calling the Connect method of the Client:
if err := client.Connect(context.TODO()); err != nil { // Handle error } defer client.Disconnect() // Gracefully disconnect
It is only when successfully connected to the Gateway that your bot will appear as online and your Client will be able to receive events and send messages.
Using the HTTP API ¶
Harmony's HTTP API is organized by resource. A resource maps to a core concept in the Discord world, such as a User or a Channel. Here is the list of resources you can interact with:
- Guild
- Channel
- User
- Webhook
- Invite
Every interaction you can have with a resource can be accessed via methods attached to it. For example, if you wish to send a message to a channel, first access to the desired channel resource, then send the message:
msg, err := client.Channel("channel-id").SendMessage("content of the message") if err != nil { // Handle error } // msg is the message sent
Endpoints that do not fall into one of those resource (creating a Guild for example, or getting valid Voice Regions) are directly available on the Client.
Registering event handlers ¶
To receive messages, use the OnMessageCreate method and give it your handler. It will be called each time a message is sent to a channel your bot is in with the message as a parameter.
client.OnMessageCreate(func(msg *discord.Message) { fmt.Println(msg.Content) })
To register handlers for other types of events, see Client.On* methods.
Note that your handlers are called in their own goroutine, meaning whatever you do inside of them won't block future events.
Using the state ¶
When connecting to Discord, a session state is created with initial data sent by Discord's Gateway. As events are received by the client, this state is constantly updated so it always have the newest data available.
This session state acts as a cache to avoid making requests over the HTTP API each time. If you need to get information about the current user, you can simply query the current state like so:
user := client.State.Me()
Because this state might become memory hungry for bots that are in a very large number of servers, you can fine-tune events you want to track with the WithGatewayIntents option. State can also be completely disabled using the WithStateTracking option while creating the harmony client.
Index ¶
- type ChannelPinsUpdate
- type Client
- func (c *Client) Channel(id string) *channel.Resource
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) CreateGuild(ctx context.Context, name string) (*discord.Guild, error)
- func (c *Client) Disconnect()
- func (c *Client) Gateway(ctx context.Context) (string, error)
- func (c *Client) GatewayBot(ctx context.Context) (string, int, error)
- func (c *Client) GetApplicationInfo(ctx context.Context) (*discord.Application, error)
- func (c *Client) GetVoiceRegions(ctx context.Context) ([]discord.VoiceRegion, error)
- func (c *Client) Guild(id string) *guild.Resource
- func (c *Client) Invite(code string) *invite.Resource
- func (c *Client) JoinVoiceChannel(ctx context.Context, guildID, channelID string, mute, deaf bool) (*voice.Connection, error)
- func (c *Client) LeaveVoiceChannel(ctx context.Context, guildID string) error
- func (c *Client) OnChannelCreate(f func(c *discord.Channel))
- func (c *Client) OnChannelDelete(f func(c *discord.Channel))
- func (c *Client) OnChannelPinsUpdate(f func(cpu *ChannelPinsUpdate))
- func (c *Client) OnChannelUpdate(f func(c *discord.Channel))
- func (c *Client) OnGuildBanAdd(f func(ban *GuildBan))
- func (c *Client) OnGuildBanRemove(f func(ban *GuildBan))
- func (c *Client) OnGuildCreate(f func(g *discord.Guild))
- func (c *Client) OnGuildDelete(f func(g *discord.UnavailableGuild))
- func (c *Client) OnGuildEmojisUpdate(f func(emojis *GuildEmojis))
- func (c *Client) OnGuildIntegrationsUpdate(f func(u *GuildIntegrationUpdate))
- func (c *Client) OnGuildInviteCreate(f func(i *GuildInviteCreate))
- func (c *Client) OnGuildInviteDelete(f func(i *GuildInviteDelete))
- func (c *Client) OnGuildMemberAdd(f func(m *GuildMemberAdd))
- func (c *Client) OnGuildMemberRemove(f func(m *GuildMemberRemove))
- func (c *Client) OnGuildMemberUpdate(f func(m *GuildMemberUpdate))
- func (c *Client) OnGuildMembersChunk(f func(m *GuildMembersChunk))
- func (c *Client) OnGuildRoleCreate(f func(r *GuildRole))
- func (c *Client) OnGuildRoleDelete(f func(r *GuildRoleDelete))
- func (c *Client) OnGuildRoleUpdate(f func(r *GuildRole))
- func (c *Client) OnGuildUpdate(f func(g *discord.Guild))
- func (c *Client) OnMessageAck(f func(ack *MessageAck))
- func (c *Client) OnMessageCreate(f func(m *discord.Message))
- func (c *Client) OnMessageDelete(f func(m *MessageDelete))
- func (c *Client) OnMessageDeleteBulk(f func(mdb *MessageDeleteBulk))
- func (c *Client) OnMessageReactionAdd(f func(r *MessageReaction))
- func (c *Client) OnMessageReactionRemove(f func(r *MessageReaction))
- func (c *Client) OnMessageReactionRemoveAll(f func(r *MessageReactionRemoveAll))
- func (c *Client) OnMessageReactionRemoveEmoji(f func(r *MessageReactionRemoveEmoji))
- func (c *Client) OnMessageUpdate(f func(m *discord.Message))
- func (c *Client) OnPresenceUpdate(f func(p *discord.Presence))
- func (c *Client) OnReady(f func(r *Ready))
- func (c *Client) OnTypingStart(f func(ts *TypingStart))
- func (c *Client) OnUserUpdate(f func(u *discord.User))
- func (c *Client) OnVoiceServerUpdate(f func(update *voice.ServerUpdate))
- func (c *Client) OnVoiceStateUpdate(f func(update *voice.StateUpdate))
- func (c *Client) OnWebhooksUpdate(f func(wu *WebhooksUpdate))
- func (c *Client) RequestGuildMembers(guildID, query string, limit int) error
- func (c *Client) SetBotStatus(status *discord.BotStatus) error
- func (c *Client) SwitchVoiceChannel(ctx context.Context, guildID string, channelID string) error
- func (c *Client) User(id string) *user.Resource
- func (c *Client) Webhook(id string) *webhook.Resource
- type ClientOption
- func WithBackoffStrategy(baseDelay, maxDelay time.Duration, factor, jitter float64) ClientOption
- func WithGatewayIntents(i discord.GatewayIntent) ClientOption
- func WithGuildSubscriptions(y bool) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithInitialBotStatus(s *discord.BotStatus) ClientOption
- func WithLargeThreshold(t int) ClientOption
- func WithLogger(l log.Logger) ClientOption
- func WithName(n string) ClientOption
- func WithSharding(current, total int) ClientOption
- func WithStateTracking(y bool) ClientOption
- type GuildBan
- type GuildEmojis
- type GuildIntegrationUpdate
- type GuildInviteCreate
- type GuildInviteDelete
- type GuildMemberAdd
- type GuildMemberRemove
- type GuildMemberUpdate
- type GuildMembersChunk
- type GuildRole
- type GuildRoleDelete
- type MessageAck
- type MessageDelete
- type MessageDeleteBulk
- type MessageReaction
- type MessageReactionRemoveAll
- type MessageReactionRemoveEmoji
- type Ready
- type State
- func (s *State) Channel(id string) *discord.Channel
- func (s *State) Channels() map[string]*discord.Channel
- func (s *State) DM(id string) *discord.Channel
- func (s *State) DMs() map[string]*discord.Channel
- func (s *State) GroupDM(id string) *discord.Channel
- func (s *State) GroupDMs() map[string]*discord.Channel
- func (s *State) Guild(id string) *discord.Guild
- func (s *State) Guilds() map[string]*discord.Guild
- func (s *State) Me() *discord.User
- func (s *State) Presence(userID string) *discord.Presence
- func (s *State) Presences() map[string]*discord.Presence
- func (s *State) RTT() time.Duration
- func (s *State) UnavailableGuild(id string) *discord.UnavailableGuild
- func (s *State) UnavailableGuilds() map[string]*discord.UnavailableGuild
- func (s *State) User(id string) *discord.User
- func (s *State) Users() map[string]*discord.User
- type TypingStart
- type WebhooksUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelPinsUpdate ¶
type ChannelPinsUpdate struct { ChannelID string `json:"channel_id"` LastPinTimestamp discord.Time `json:"last_pin_timestamp"` }
ChannelPinsUpdate is Fired when a message is pinned or unpinned in a text channel.
type Client ¶
type Client struct { State *State // contains filtered or unexported fields }
Client is used to communicate with Discord's API. To start receiving events from the Gateway with a Client, you first need to call its Connect method.
func NewClient ¶
func NewClient(token string, opts ...ClientOption) (*Client, error)
NewClient creates a new client to work with Discord's API. It is meant to be long lived and shared across your application. The token is automatically prefixed with "Bot ", which is a requirement by Discord for bot users. Automated normal user accounts (generally called "self-bots"), are not supported. To customize a Client, refer to available ClientOption.
func (*Client) Channel ¶
Channel returns a new channel resource to manage the channel with the given ID.
func (*Client) CreateGuild ¶
CreateGuild creates a new guild with the given name. Returns the created guild on success. Fires a Guild Create Gateway event.
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
Disconnect closes the connection to the Discord Gateway.
func (*Client) GatewayBot ¶
GatewayBot returns a valid WSS URL and the recommended number of shards to connect with.
func (*Client) GetApplicationInfo ¶ added in v0.19.0
GetApplicationInfo returns the current user's OAuth2 application info.
func (*Client) GetVoiceRegions ¶
GetVoiceRegions returns a list of available voice regions that can be used when creating or updating servers.
func (*Client) Invite ¶
Invite returns a new invite resource to manage the invite with the given code.
func (*Client) JoinVoiceChannel ¶ added in v0.14.0
func (c *Client) JoinVoiceChannel(ctx context.Context, guildID, channelID string, mute, deaf bool) (*voice.Connection, error)
JoinVoiceChannel will create a new voice connection to the given voice channel. If you already have an existing connection and want to switch to a different channel instead, use the SwitchVoiceChannel method. This method is safe to call from multiple goroutines, but connections will happen sequentially. To properly leave the voice channel, call LeaveVoiceChannel.
func (*Client) LeaveVoiceChannel ¶ added in v0.14.0
LeaveVoiceChannel notifies the Gateway we want the voice channel we are connected to in the given guild.
func (*Client) OnChannelCreate ¶ added in v0.6.0
OnChannelCreate registers the handler function for the "CHANNEL_CREATE" event. This event is fired when a new channel is created, relevant to the current user.
func (*Client) OnChannelDelete ¶ added in v0.6.0
OnChannelDelete registers the handler function for the "CHANNEL_DELETE" event. This event is fired when a channel is deleted, relevant to the current user.
func (*Client) OnChannelPinsUpdate ¶ added in v0.6.0
func (c *Client) OnChannelPinsUpdate(f func(cpu *ChannelPinsUpdate))
OnChannelPinsUpdate registers the handler function for the "CHANNEL_PINS_UPDATE" event. This event is fired when a message is pinned or unpinned, but not when a pinned message is deleted.
func (*Client) OnChannelUpdate ¶ added in v0.6.0
OnChannelUpdate registers the handler function for the "CHANNEL_UPDATE" event. This event is fired when a channel is updated, relevant to the current user.
func (*Client) OnGuildBanAdd ¶ added in v0.6.0
OnGuildBanAdd registers the handler function for the "GUILD_BAN_ADD" event.
func (*Client) OnGuildBanRemove ¶ added in v0.6.0
OnGuildBanRemove registers the handler function for the "GUILD_BAN_REMOVE" event. This event is fired when a guild is updated.
func (*Client) OnGuildCreate ¶ added in v0.6.0
OnGuildCreate registers the handler function for the "GUILD_CREATE" event. This event can be sent in three different scenarios:
- When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the Ready event.
- When a Guild becomes available again to the client.
- When the current user joins a new Guild.
func (*Client) OnGuildDelete ¶ added in v0.6.0
func (c *Client) OnGuildDelete(f func(g *discord.UnavailableGuild))
OnGuildDelete registers the handler function for the "GUILD_DELETE" event. This event is fired when a guild becomes unavailable during a guild outage, or when the user leaves or is removed from a guild. If the unavailable field is not set, the user was removed from the guild.
func (*Client) OnGuildEmojisUpdate ¶ added in v0.6.0
func (c *Client) OnGuildEmojisUpdate(f func(emojis *GuildEmojis))
OnGuildEmojisUpdate registers the handler function for the "GUILD_EMOJIS_UPDATE" event. Fired when a guild's emojis have been updated.
func (*Client) OnGuildIntegrationsUpdate ¶ added in v0.6.0
func (c *Client) OnGuildIntegrationsUpdate(f func(u *GuildIntegrationUpdate))
OnGuildIntegrationsUpdate registers the handler function for the "GUILD_INTEGRATIONS_UPDATE" event. Fired when a guild integration is updated.
func (*Client) OnGuildInviteCreate ¶ added in v0.17.0
func (c *Client) OnGuildInviteCreate(f func(i *GuildInviteCreate))
OnGuildInviteCreate registers the handler function for the "GUILD_ROLE_DELETE" event. Fired when a guild role is deleted.
func (*Client) OnGuildInviteDelete ¶ added in v0.17.0
func (c *Client) OnGuildInviteDelete(f func(i *GuildInviteDelete))
OnGuildInviteDelete registers the handler function for the "GUILD_ROLE_DELETE" event. Fired when a guild role is deleted.
func (*Client) OnGuildMemberAdd ¶ added in v0.6.0
func (c *Client) OnGuildMemberAdd(f func(m *GuildMemberAdd))
OnGuildMemberAdd registers the handler function for the "GUILD_MEMBER_ADD" event. Fired when a new user joins a guild.
func (*Client) OnGuildMemberRemove ¶ added in v0.6.0
func (c *Client) OnGuildMemberRemove(f func(m *GuildMemberRemove))
OnGuildMemberRemove registers the handler function for the "GUILD_MEMBER_REMOVE" event. Fired when a user is removed from a guild (leave/kick/ban).
func (*Client) OnGuildMemberUpdate ¶ added in v0.6.0
func (c *Client) OnGuildMemberUpdate(f func(m *GuildMemberUpdate))
OnGuildMemberUpdate registers the handler function for the "GUILD_MEMBER_UPDATE" event. Fired when a guild member is updated.
func (*Client) OnGuildMembersChunk ¶ added in v0.6.0
func (c *Client) OnGuildMembersChunk(f func(m *GuildMembersChunk))
OnGuildMembersChunk registers the handler function for the "GUILD_MEMBERS_CHUNK" event. Sent in response to Guild Request Members.
func (*Client) OnGuildRoleCreate ¶ added in v0.6.0
OnGuildRoleCreate registers the handler function for the "GUILD_ROLE_CREATE" event. Fired when a guild role is created.
func (*Client) OnGuildRoleDelete ¶ added in v0.6.0
func (c *Client) OnGuildRoleDelete(f func(r *GuildRoleDelete))
OnGuildRoleDelete registers the handler function for the "GUILD_ROLE_DELETE" event. Fired when a guild role is deleted.
func (*Client) OnGuildRoleUpdate ¶ added in v0.6.0
OnGuildRoleUpdate registers the handler function for the "GUILD_ROLE_UPDATE" event. Fired when a guild role is updated.
func (*Client) OnGuildUpdate ¶ added in v0.6.0
HandleGuildUpdate registers the handler function for the "GUILD_UPDATE" event.
func (*Client) OnMessageAck ¶ added in v0.6.0
func (c *Client) OnMessageAck(f func(ack *MessageAck))
OnMessageAck registers the handler function for the "MESSAGE_ACK" event.
func (*Client) OnMessageCreate ¶ added in v0.6.0
OnMessageCreate registers the handler function for the "MESSAGE_CREATE" event. Fired when a message is created.
func (*Client) OnMessageDelete ¶ added in v0.6.0
func (c *Client) OnMessageDelete(f func(m *MessageDelete))
OnMessageDelete registers the handler function for the "MESSAGE_DELETE" event. Fired when a message is deleted.
func (*Client) OnMessageDeleteBulk ¶ added in v0.6.0
func (c *Client) OnMessageDeleteBulk(f func(mdb *MessageDeleteBulk))
OnMessageDeleteBulk registers the handler function for the "MESSAGE_DELETE_BULK" event. Fired when multiple messages are deleted at once.
func (*Client) OnMessageReactionAdd ¶ added in v0.6.0
func (c *Client) OnMessageReactionAdd(f func(r *MessageReaction))
OnMessageReactionAdd registers the handler function for the "MESSAGE_REACTION_ADD" event. Fired when a user adds a reaction to a message.
func (*Client) OnMessageReactionRemove ¶ added in v0.6.0
func (c *Client) OnMessageReactionRemove(f func(r *MessageReaction))
OnMessageReactionRemove registers the handler function for the "MESSAGE_REACTION_REMOVE" event. Fired when a user removes a reaction from a message.
func (*Client) OnMessageReactionRemoveAll ¶ added in v0.6.0
func (c *Client) OnMessageReactionRemoveAll(f func(r *MessageReactionRemoveAll))
OnMessageReactionRemoveAll registers the handler function for the "MESSAGE_REACTION_REMOVE_ALL" event. Fired when a user explicitly removes all reactions from a message.
func (*Client) OnMessageReactionRemoveEmoji ¶ added in v0.17.0
func (c *Client) OnMessageReactionRemoveEmoji(f func(r *MessageReactionRemoveEmoji))
HandleMessageReactionRemoveEmoji registers the handler function for the "MESSAGE_REACTION_REMOVE_ALL" event. Fired when a user explicitly removes all reactions from a message.
func (*Client) OnMessageUpdate ¶ added in v0.6.0
OnMessageUpdate registers the handler function for the "MESSAGE_UPDATE" event. Fired when a message is updated. Unlike creates, message updates may contain only a subset of the full message object payload (but will always contain an id and channel_id).
func (*Client) OnPresenceUpdate ¶ added in v0.6.0
OnPresenceUpdate registers the handler function for the "PRESENCE_UPDATE" event. This event is fired when a user's presence is updated for a guild. The user object within this event can be partial, the only field which must be sent is the id field, everything else is optional. Along with this limitation, no fields are required, and the types of the fields are not validated. Your client should expect any combination of fields and types within this event.
func (*Client) OnReady ¶ added in v0.6.0
OnReady registers the handler function for the "READY" event.
func (*Client) OnTypingStart ¶ added in v0.6.0
func (c *Client) OnTypingStart(f func(ts *TypingStart))
OnTypingStart registers the handler function for the "TYPING_START" event. Fired when a user starts typing in a channel.
func (*Client) OnUserUpdate ¶ added in v0.6.0
OnUserUpdate registers the handler function for the "USER_UPDATE" event. Fired when properties about the user change.
func (*Client) OnVoiceServerUpdate ¶ added in v0.6.0
func (c *Client) OnVoiceServerUpdate(f func(update *voice.ServerUpdate))
OnVoiceServerUpdate registers the handler function for the "VOICE_SERVER_UPDATE" event. Fired when a guild's voice server is updated. This is Fired when initially connecting to voice, and when the current voice instance fails over to a new server.
func (*Client) OnVoiceStateUpdate ¶ added in v0.6.0
func (c *Client) OnVoiceStateUpdate(f func(update *voice.StateUpdate))
OnVoiceStateUpdate registers the handler function for the "VOICE_STATE_UPDATE" event. Fired when someone joins/leaves/moves voice channels.
func (*Client) OnWebhooksUpdate ¶ added in v0.6.0
func (c *Client) OnWebhooksUpdate(f func(wu *WebhooksUpdate))
OnWebhooksUpdate registers the handler function for the "WEBHOOKS_UPDATE" event. Fired when a guild channel's webhook is created, updated, or deleted.
func (*Client) RequestGuildMembers ¶ added in v0.19.0
RequestGuildMembers is used to request offline members for the guild. When initially connecting, the gateway will only send offline members if a guild has less than the large_threshold members (value in the Gateway Identify). If a client wishes to receive additional members, they need to explicitly request them via this operation. The server will send Guild Members Chunk events in response with up to 1000 members per chunk until all members that match the request have been sent. query is a string that username starts with, or an empty string to return all members. limit is the maximum number of members to send or 0 to request all members matched. You need to be connected to the Gateway to call this method, else it will return ErrGatewayNotConnected.
func (*Client) SetBotStatus ¶ added in v0.19.0
SetBotStatus sets the bot's status. You need to be connected to the Gateway to call this method, else it will return ErrGatewayNotConnected.
func (*Client) SwitchVoiceChannel ¶ added in v0.16.0
SwitchVoiceChannel can be used to switch from a voice channel to another. It requires an active voice connection in the guild. You can get one with JoinVoiceChannel.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures a Client. It is used in NewClient.
func WithBackoffStrategy ¶
func WithBackoffStrategy(baseDelay, maxDelay time.Duration, factor, jitter float64) ClientOption
WithBackoffStrategy allows you to customize the backoff strategy used when trying to reconnect to the Discord Gateway after an error occurred (such as a network failure). Defaults to 1s (baseDelay), 120s (maxDelay), 1.6 (factor), 0.2 (jitter).
func WithGatewayIntents ¶ added in v0.17.0
func WithGatewayIntents(i discord.GatewayIntent) ClientOption
WithGatewayIntents allows to customize which Gateway Intents the client should subscribe to. See https://discord.com/developers/docs/topics/gateway#gateway-intents for more information. By default, the client subscribes to all unprivileged events.
func WithGuildSubscriptions ¶ added in v0.17.0
func WithGuildSubscriptions(y bool) ClientOption
WithGuildSubscriptions allows to set whether the client should identify to the Gateway with guild subscription enabled or not. Guild subscriptions are guild member presence updates and typing events. Defaults to true. While not deprecated, Guild Subscriptions have been superseded by Gateway Intents. It is recommended to use WithGatewayIntents for better results.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient can be used to specify the http.Client to use when making HTTP requests to the Discord HTTP API. Defaults to http.DefaultClient.
func WithInitialBotStatus ¶ added in v0.19.0
func WithInitialBotStatus(s *discord.BotStatus) ClientOption
WithInitialBotStatus sets the initial status of the bot that is sent when identifying to the Gateway. It can be later modified with SetBotStatus.
func WithLargeThreshold ¶
func WithLargeThreshold(t int) ClientOption
WithLargeThreshold allows you to set the large threshold when connecting to the Gateway. This threshold will dictate the number of offline guild members are returned with a guild. See: https://discord.com/developers/docs/topics/gateway#request-guild-members for more details. Defaults to 250.
func WithLogger ¶ added in v0.12.0
func WithLogger(l log.Logger) ClientOption
WithLogger can be used to set the logger used by Harmony. Defaults to a standard logger reporting only errors. See the log package for more information about logging with Harmony.
func WithName ¶ added in v0.10.0
func WithName(n string) ClientOption
WithName sets the name of the client. It will be used to set the User-Agent of HTTP requests sent by the Client. Defaults to "Harmony".
func WithSharding ¶
func WithSharding(current, total int) ClientOption
WithSharding allows you to specify a sharding configuration when connecting to the Gateway. See https://discord.com/developers/docs/topics/gateway#sharding for more details. Defaults to nothing, sharding is not enabled.
func WithStateTracking ¶
func WithStateTracking(y bool) ClientOption
WithStateTracking allows you to specify whether the client is tracking the state of the current connection or not. Defaults to true.
type GuildEmojis ¶
type GuildIntegrationUpdate ¶ added in v0.17.0
type GuildIntegrationUpdate struct {
GuildID string `json:"guild_id"`
}
type GuildInviteCreate ¶ added in v0.17.0
type GuildInviteCreate struct { ChannelID string `json:"channel_id"` Code string `json:"code"` CreatedAt discord.Time `json:"created_at"` GuildID string `json:"guild_id"` Inviter *discord.User `json:"inviter"` MaxAge int `json:"max_age"` MaxUses int `json:"max_uses"` TargetUser *discord.User `json:"target_user"` TargetUserType int `json:"target_user_type"` Temporary bool `json:"temporary"` Uses int `json:"uses"` }
type GuildInviteDelete ¶ added in v0.17.0
type GuildMemberAdd ¶
type GuildMemberAdd struct { *discord.GuildMember GuildID string `json:"guild_id"` }
type GuildMemberRemove ¶
type GuildMemberUpdate ¶
type GuildMembersChunk ¶
type GuildMembersChunk struct { GuildID string `json:"guild_id"` Members []discord.GuildMember `json:"members"` }
type GuildRoleDelete ¶
type MessageAck ¶
type MessageDelete ¶
type MessageDeleteBulk ¶
type MessageReaction ¶
type MessageReactionRemoveEmoji ¶ added in v0.17.0
type Ready ¶
type Ready struct { V int `json:"v"` // Gateway version. User *discord.User `json:"user"` Guilds []discord.UnavailableGuild `json:"guilds"` SessionID string `json:"session_id"` Application discord.PartialApplication `json:"application"` GeoOrderedRTCRegions []string `json:"geo_ordered_rtc_regions"` Shard [2]int `json:"shard"` }
Ready is the Event fired by the Gateway after the client sent a valid Identify payload.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is a cache of the state of the application that is updated in real-time as events are received from the Gateway. Objects returned by State methods are snapshots of original objects used internally by the State. This means they are safe to be used and modified but they won't be updated as new events are received.
func (*State) RTT ¶
RTT returns the Round Trip Time between the client and Discord's Gateway. It is calculated and updated when sending heartbeat payloads (roughly every minute).
func (*State) UnavailableGuild ¶
func (s *State) UnavailableGuild(id string) *discord.UnavailableGuild
UnavailableGuild returns an unavailable guild given its ID from the state.
func (*State) UnavailableGuilds ¶
func (s *State) UnavailableGuilds() map[string]*discord.UnavailableGuild
UnavailableGuilds returns a map of guild ID to unavailable guild from the state.
type TypingStart ¶
type WebhooksUpdate ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
Package discord contains every Discord resources used throughout Harmony as well as some utility functions and methods to work with them.
|
Package discord contains every Discord resources used throughout Harmony as well as some utility functions and methods to work with them. |
internal
|
|
Package log defines an interface that can be implemented in order to provide a logger for Harmony.
|
Package log defines an interface that can be implemented in order to provide a logger for Harmony. |
Package optional defines optional versions of primitive types that can be nil.
|
Package optional defines optional versions of primitive types that can be nil. |
voiceutil
Package voiceutil provides utilities to work with harmony voice connections.
|
Package voiceutil provides utilities to work with harmony voice connections. |