2020-01-15 04:43:34 +00:00
|
|
|
package gateway
|
|
|
|
|
2021-08-03 15:53:22 +00:00
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"github.com/diamondburned/arikawa/v3/discord"
|
|
|
|
"github.com/diamondburned/arikawa/v3/utils/json"
|
|
|
|
)
|
2020-01-15 04:43:34 +00:00
|
|
|
|
|
|
|
// Rules: VOICE_STATE_UPDATE -> VoiceStateUpdateEvent
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#connecting-and-resuming
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
|
|
|
HelloEvent struct {
|
|
|
|
HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
|
|
|
|
}
|
|
|
|
|
2020-01-19 21:54:16 +00:00
|
|
|
// Ready is too big, so it's moved to ready.go
|
2020-01-15 04:43:34 +00:00
|
|
|
|
|
|
|
ResumedEvent struct{}
|
|
|
|
|
|
|
|
// InvalidSessionEvent indicates if the event is resumable.
|
|
|
|
InvalidSessionEvent bool
|
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#channels
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
2020-07-15 04:38:31 +00:00
|
|
|
ChannelCreateEvent struct {
|
|
|
|
discord.Channel
|
|
|
|
}
|
|
|
|
ChannelUpdateEvent struct {
|
|
|
|
discord.Channel
|
|
|
|
}
|
|
|
|
ChannelDeleteEvent struct {
|
|
|
|
discord.Channel
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
ChannelPinsUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
LastPin discord.Timestamp `json:"timestamp,omitempty"`
|
|
|
|
}
|
2020-02-16 05:29:25 +00:00
|
|
|
|
|
|
|
ChannelUnreadUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
2020-02-16 05:29:25 +00:00
|
|
|
|
|
|
|
ChannelUnreadUpdates []struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ID discord.ChannelID `json:"id"`
|
|
|
|
LastMessageID discord.MessageID `json:"last_message_id"`
|
2020-02-16 05:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#guilds
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
2020-01-18 21:04:12 +00:00
|
|
|
GuildCreateEvent struct {
|
|
|
|
discord.Guild
|
|
|
|
|
2021-04-11 23:56:05 +00:00
|
|
|
Joined discord.Timestamp `json:"joined_at,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
Large bool `json:"large,omitempty"`
|
|
|
|
Unavailable bool `json:"unavailable,omitempty"`
|
|
|
|
MemberCount uint64 `json:"member_count,omitempty"`
|
|
|
|
|
2020-04-21 22:30:10 +00:00
|
|
|
VoiceStates []discord.VoiceState `json:"voice_states,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
Members []discord.Member `json:"members,omitempty"`
|
2020-05-18 05:48:16 +00:00
|
|
|
Channels []discord.Channel `json:"channels,omitempty"`
|
2020-11-29 06:36:33 +00:00
|
|
|
Presences []Presence `json:"presences,omitempty"`
|
2020-01-18 21:04:12 +00:00
|
|
|
}
|
2020-07-15 04:38:31 +00:00
|
|
|
GuildUpdateEvent struct {
|
|
|
|
discord.Guild
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
GuildDeleteEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ID discord.GuildID `json:"id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
// Unavailable if false == removed
|
|
|
|
Unavailable bool `json:"unavailable"`
|
|
|
|
}
|
|
|
|
|
|
|
|
GuildBanAddEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
GuildBanRemoveEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuildEmojisUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
Emojis []discord.Emoji `json:"emoji"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuildIntegrationsUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuildMemberAddEvent struct {
|
|
|
|
discord.Member
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
GuildMemberRemoveEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
GuildMemberUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
RoleIDs []discord.RoleID `json:"roles"`
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
Nick string `json:"nick"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GuildMembersChunkEvent is sent when Guild Request Members is called.
|
|
|
|
GuildMembersChunkEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
Members []discord.Member `json:"members"`
|
2020-01-15 04:43:34 +00:00
|
|
|
|
2020-07-11 19:50:32 +00:00
|
|
|
ChunkIndex int `json:"chunk_index"`
|
|
|
|
ChunkCount int `json:"chunk_count"`
|
|
|
|
|
2020-01-15 04:43:34 +00:00
|
|
|
// Whatever's not found goes here
|
|
|
|
NotFound []string `json:"not_found,omitempty"`
|
|
|
|
|
|
|
|
// Only filled if requested
|
2020-11-29 01:22:03 +00:00
|
|
|
Presences []Presence `json:"presences,omitempty"`
|
2020-11-29 06:36:33 +00:00
|
|
|
Nonce string `json:"nonce,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 05:55:45 +00:00
|
|
|
// GuildMemberListUpdate is an undocumented event. It's received when the
|
|
|
|
// client sends over GuildSubscriptions with the Channels field used.
|
|
|
|
// The State package does not handle this event.
|
|
|
|
GuildMemberListUpdate struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ID string `json:"id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
MemberCount uint64 `json:"member_count"`
|
|
|
|
OnlineCount uint64 `json:"online_count"`
|
2020-03-16 05:55:45 +00:00
|
|
|
|
|
|
|
// Groups is all the visible role sections.
|
|
|
|
Groups []GuildMemberListGroup `json:"groups"`
|
|
|
|
|
|
|
|
Ops []GuildMemberListOp `json:"ops"`
|
|
|
|
}
|
|
|
|
GuildMemberListGroup struct {
|
2020-08-15 04:13:48 +00:00
|
|
|
ID string `json:"id"` // either discord.RoleID, "online" or "offline"
|
2020-03-16 05:55:45 +00:00
|
|
|
Count uint64 `json:"count"`
|
|
|
|
}
|
|
|
|
GuildMemberListOp struct {
|
|
|
|
// Mysterious string, so far spotted to be [SYNC, INSERT, UPDATE, DELETE].
|
|
|
|
Op string `json:"op"`
|
|
|
|
|
|
|
|
// NON-SYNC ONLY
|
|
|
|
// Only available for Ops that aren't "SYNC".
|
|
|
|
Index int `json:"index,omitempty"`
|
|
|
|
Item GuildMemberListOpItem `json:"item,omitempty"`
|
|
|
|
|
|
|
|
// SYNC ONLY
|
|
|
|
// Range requested in GuildSubscribeData.
|
|
|
|
Range [2]int `json:"range,omitempty"`
|
|
|
|
// Items is basically a linear list of roles and members, similarly to
|
|
|
|
// how the client renders it. No, it's not nested.
|
|
|
|
Items []GuildMemberListOpItem `json:"items,omitempty"`
|
|
|
|
}
|
|
|
|
// GuildMemberListOpItem is an enum. Either of the fields are provided, but
|
|
|
|
// never both. Refer to (*GuildMemberListUpdate).Ops for more.
|
|
|
|
GuildMemberListOpItem struct {
|
|
|
|
Group *GuildMemberListGroup `json:"group,omitempty"`
|
|
|
|
Member *struct {
|
|
|
|
discord.Member
|
2020-11-29 06:36:33 +00:00
|
|
|
HoistedRole string `json:"hoisted_role"`
|
2020-11-29 01:22:03 +00:00
|
|
|
Presence Presence `json:"presence"`
|
2020-03-16 05:55:45 +00:00
|
|
|
} `json:"member,omitempty"`
|
|
|
|
}
|
|
|
|
|
2020-01-15 04:43:34 +00:00
|
|
|
GuildRoleCreateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
Role discord.Role `json:"role"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
GuildRoleUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
Role discord.Role `json:"role"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
GuildRoleDeleteEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
RoleID discord.RoleID `json:"role_id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-01-18 21:04:12 +00:00
|
|
|
func (u GuildMemberUpdateEvent) Update(m *discord.Member) {
|
|
|
|
m.RoleIDs = u.RoleIDs
|
|
|
|
m.User = u.User
|
|
|
|
m.Nick = u.Nick
|
|
|
|
}
|
|
|
|
|
2020-05-13 00:51:23 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#invites
|
|
|
|
type (
|
|
|
|
InviteCreateEvent struct {
|
|
|
|
Code string `json:"code"`
|
|
|
|
CreatedAt discord.Timestamp `json:"created_at"`
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-05-13 00:51:23 +00:00
|
|
|
|
|
|
|
// Similar to discord.Invite
|
|
|
|
Inviter *discord.User `json:"inviter,omitempty"`
|
|
|
|
Target *discord.User `json:"target_user,omitempty"`
|
|
|
|
TargetType discord.InviteUserType `json:"target_user_type,omitempty"`
|
|
|
|
|
|
|
|
discord.InviteMetadata
|
|
|
|
}
|
|
|
|
InviteDeleteEvent struct {
|
|
|
|
Code string `json:"code"`
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-05-13 00:51:23 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#messages
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
2020-04-12 23:14:27 +00:00
|
|
|
MessageCreateEvent struct {
|
|
|
|
discord.Message
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
|
|
|
}
|
|
|
|
MessageUpdateEvent struct {
|
|
|
|
discord.Message
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
MessageDeleteEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ID discord.MessageID `json:"id"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
MessageDeleteBulkEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
IDs []discord.MessageID `json:"ids"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageReactionAddEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
UserID discord.UserID `json:"user_id"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
MessageID discord.MessageID `json:"message_id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
|
|
|
|
Emoji discord.Emoji `json:"emoji,omitempty"`
|
|
|
|
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
MessageReactionRemoveEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
UserID discord.UserID `json:"user_id"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
MessageID discord.MessageID `json:"message_id"`
|
2020-04-12 23:14:27 +00:00
|
|
|
Emoji discord.Emoji `json:"emoji"`
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
MessageReactionRemoveAllEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
MessageID discord.MessageID `json:"message_id"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-04-12 23:14:27 +00:00
|
|
|
}
|
2020-10-29 02:31:43 +00:00
|
|
|
MessageReactionRemoveEmojiEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
MessageID discord.MessageID `json:"message_id"`
|
2020-04-12 23:14:27 +00:00
|
|
|
Emoji discord.Emoji `json:"emoji"`
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
2020-02-16 05:29:25 +00:00
|
|
|
|
|
|
|
MessageAckEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
MessageID discord.MessageID `json:"message_id"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
2020-02-16 05:29:25 +00:00
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
)
|
|
|
|
|
2020-11-29 01:22:03 +00:00
|
|
|
// Status is the enumerate type for a user's status.
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
const (
|
|
|
|
UnknownStatus Status = ""
|
|
|
|
OnlineStatus Status = "online"
|
|
|
|
DoNotDisturbStatus Status = "dnd"
|
|
|
|
IdleStatus Status = "idle"
|
|
|
|
InvisibleStatus Status = "invisible"
|
|
|
|
OfflineStatus Status = "offline"
|
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#presence
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
2020-11-29 01:22:03 +00:00
|
|
|
// Presence represents a partial Presence structure used by other structs to be
|
|
|
|
// easily embedded. It does not contain any ID to identify who it belongs
|
|
|
|
// to. For more information, refer to the PresenceUpdateEvent struct.
|
|
|
|
Presence struct {
|
2020-11-29 06:36:33 +00:00
|
|
|
// User is the user presence is being updated for. Only the ID field is
|
|
|
|
// guaranteed to be valid per Discord documentation.
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
// GuildID is the id of the guild
|
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
2020-11-29 01:22:03 +00:00
|
|
|
// Status is either "idle", "dnd", "online", or "offline".
|
|
|
|
Status Status `json:"status"`
|
|
|
|
// Activities are the user's current activities.
|
|
|
|
Activities []discord.Activity `json:"activities"`
|
2021-01-27 17:43:38 +00:00
|
|
|
// ClientStatus is the user's platform-dependent status.
|
2020-11-29 01:22:03 +00:00
|
|
|
ClientStatus ClientStatus `json:"client_status"`
|
|
|
|
}
|
|
|
|
|
2021-01-27 17:43:38 +00:00
|
|
|
// ClientStatus is the user's platform-dependent status.
|
2020-11-29 01:22:03 +00:00
|
|
|
//
|
|
|
|
// https://discord.com/developers/docs/topics/gateway#client-status-object
|
|
|
|
ClientStatus struct {
|
|
|
|
// Desktop is the user's status set for an active desktop (Windows,
|
|
|
|
// Linux, Mac) application session.
|
|
|
|
Desktop Status `json:"desktop,omitempty"`
|
|
|
|
// Mobile is the user's status set for an active mobile (iOS, Android)
|
|
|
|
// application session.
|
|
|
|
Mobile Status `json:"mobile,omitempty"`
|
|
|
|
// Web is the user's status set for an active web (browser, bot
|
|
|
|
// account) application session.
|
|
|
|
Web Status `json:"web,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PresenceUpdateEvent represents the structure of the Presence Update Event
|
2020-11-29 06:36:33 +00:00
|
|
|
// object.
|
2020-11-29 01:22:03 +00:00
|
|
|
//
|
|
|
|
// https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields
|
2020-05-12 02:49:11 +00:00
|
|
|
PresenceUpdateEvent struct {
|
2020-11-29 01:22:03 +00:00
|
|
|
Presence
|
2020-05-12 02:49:11 +00:00
|
|
|
}
|
2020-11-29 01:22:03 +00:00
|
|
|
|
|
|
|
PresencesReplaceEvent []PresenceUpdateEvent
|
2020-02-23 17:56:16 +00:00
|
|
|
|
|
|
|
// SessionsReplaceEvent is an undocumented user event. It's likely used for
|
|
|
|
// current user's presence updates.
|
|
|
|
SessionsReplaceEvent []struct {
|
2020-11-29 01:22:03 +00:00
|
|
|
Status Status `json:"status"`
|
|
|
|
SessionID string `json:"session_id"`
|
2020-02-23 17:56:16 +00:00
|
|
|
|
|
|
|
Activities []discord.Activity `json:"activities"`
|
|
|
|
|
|
|
|
ClientInfo struct {
|
|
|
|
Version int `json:"version"`
|
|
|
|
OS string `json:"os"`
|
|
|
|
Client string `json:"client"`
|
|
|
|
} `json:"client_info"`
|
|
|
|
|
|
|
|
Active bool `json:"active"`
|
|
|
|
}
|
|
|
|
|
|
|
|
TypingStartEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
|
|
|
UserID discord.UserID `json:"user_id"`
|
2020-01-20 08:53:23 +00:00
|
|
|
Timestamp discord.UnixTimestamp `json:"timestamp"`
|
2020-01-15 04:43:34 +00:00
|
|
|
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
2020-02-23 17:56:16 +00:00
|
|
|
|
2020-05-12 02:49:11 +00:00
|
|
|
UserUpdateEvent struct {
|
|
|
|
discord.User
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#voice
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
2020-05-12 02:49:11 +00:00
|
|
|
VoiceStateUpdateEvent struct {
|
|
|
|
discord.VoiceState
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
VoiceServerUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
Token string `json:"token"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
Endpoint string `json:"endpoint"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#webhooks
|
2020-01-15 04:43:34 +00:00
|
|
|
type (
|
|
|
|
WebhooksUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
)
|
2020-01-19 21:54:16 +00:00
|
|
|
|
2021-01-27 17:43:38 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#interactions
|
|
|
|
type (
|
|
|
|
InteractionCreateEvent struct {
|
2021-02-18 01:41:19 +00:00
|
|
|
ID discord.InteractionID `json:"id"`
|
2021-05-12 05:36:03 +00:00
|
|
|
AppID discord.AppID `json:"application_id"`
|
2021-05-30 04:28:37 +00:00
|
|
|
Type InteractionType `json:"type"`
|
|
|
|
Data *InteractionData `json:"data,omitempty"`
|
|
|
|
ChannelID discord.ChannelID `json:"channel_id,omitempty"`
|
2021-02-18 01:41:19 +00:00
|
|
|
Token string `json:"token"`
|
|
|
|
Version int `json:"version"`
|
2021-05-30 04:28:37 +00:00
|
|
|
Message *discord.Message `json:"message"`
|
2021-05-30 04:30:20 +00:00
|
|
|
|
|
|
|
// Member is only present if this came from a guild.
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
|
|
|
GuildID discord.GuildID `json:"guild_id,omitempty"`
|
|
|
|
|
|
|
|
// User is only present if this didn't come from a guild.
|
|
|
|
User *discord.User `json:"user,omitempty"`
|
2021-01-27 17:43:38 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
type InteractionType uint
|
|
|
|
|
|
|
|
const (
|
|
|
|
PingInteraction InteractionType = iota + 1
|
|
|
|
CommandInteraction
|
2021-05-12 05:36:03 +00:00
|
|
|
ButtonInteraction
|
2021-01-27 17:43:38 +00:00
|
|
|
)
|
|
|
|
|
2021-05-12 05:36:03 +00:00
|
|
|
// TODO: InteractionData is being overloaded by Slash Command and Button at the moment.
|
|
|
|
// Separate them when v3 rolls out.
|
|
|
|
|
2021-01-27 17:43:38 +00:00
|
|
|
type InteractionData struct {
|
2021-05-12 05:36:03 +00:00
|
|
|
// Slash commands
|
2021-02-18 01:41:19 +00:00
|
|
|
ID discord.CommandID `json:"id"`
|
2021-01-27 17:43:38 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
Options []InteractionOption `json:"options"`
|
2021-05-12 05:36:03 +00:00
|
|
|
|
|
|
|
// Button
|
|
|
|
CustomID string `json:"custom_id"`
|
|
|
|
ComponentType discord.ComponentType `json:"component_type"`
|
2021-01-27 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type InteractionOption struct {
|
|
|
|
Name string `json:"name"`
|
2021-08-03 15:53:22 +00:00
|
|
|
Value json.Raw `json:"value"`
|
2021-01-27 17:43:38 +00:00
|
|
|
Options []InteractionOption `json:"options"`
|
|
|
|
}
|
|
|
|
|
2021-08-03 15:53:22 +00:00
|
|
|
func (o InteractionOption) String() string {
|
|
|
|
val := bytes.Trim([]byte(o.Value), `"`)
|
|
|
|
return string(val)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o InteractionOption) Int() (int64, error) {
|
|
|
|
var i int64
|
|
|
|
err := o.Value.UnmarshalTo(&i)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o InteractionOption) Bool() (bool, error) {
|
|
|
|
var b bool
|
|
|
|
err := o.Value.UnmarshalTo(&b)
|
|
|
|
return b, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o InteractionOption) Snowflake() (discord.Snowflake, error) {
|
|
|
|
var id discord.Snowflake
|
|
|
|
err := o.Value.UnmarshalTo(&id)
|
|
|
|
return id, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o InteractionOption) Float() (float64, error) {
|
|
|
|
var f float64
|
|
|
|
err := o.Value.UnmarshalTo(&f)
|
|
|
|
return f, err
|
|
|
|
}
|
|
|
|
|
2020-01-19 21:54:16 +00:00
|
|
|
// Undocumented
|
|
|
|
type (
|
2020-05-12 02:49:11 +00:00
|
|
|
UserGuildSettingsUpdateEvent struct {
|
2020-12-02 02:07:42 +00:00
|
|
|
UserGuildSetting
|
2020-05-12 02:49:11 +00:00
|
|
|
}
|
|
|
|
UserSettingsUpdateEvent struct {
|
|
|
|
UserSettings
|
|
|
|
}
|
|
|
|
UserNoteUpdateEvent struct {
|
2020-07-21 20:27:59 +00:00
|
|
|
ID discord.UserID `json:"id"`
|
|
|
|
Note string `json:"note"`
|
2020-02-16 05:29:25 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2020-07-11 07:01:02 +00:00
|
|
|
RelationshipAddEvent struct {
|
2020-07-15 01:01:24 +00:00
|
|
|
discord.Relationship
|
2020-05-12 02:49:11 +00:00
|
|
|
}
|
2020-07-11 07:01:02 +00:00
|
|
|
RelationshipRemoveEvent struct {
|
2020-07-15 01:01:24 +00:00
|
|
|
discord.Relationship
|
2020-05-12 02:49:11 +00:00
|
|
|
}
|
2020-01-19 21:54:16 +00:00
|
|
|
)
|
2021-01-27 17:43:38 +00:00
|
|
|
|
|
|
|
type (
|
|
|
|
ApplicationCommandUpdateEvent struct {
|
|
|
|
discord.Command
|
|
|
|
GuildID discord.GuildID `json:"guild_id"`
|
|
|
|
}
|
|
|
|
)
|