2020-01-15 04:43:34 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import "github.com/diamondburned/arikawa/discord"
|
|
|
|
|
|
|
|
// Rules: VOICE_STATE_UPDATE -> VoiceStateUpdateEvent
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#connecting-and-resuming
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#channels
|
|
|
|
type (
|
|
|
|
ChannelCreateEvent discord.Channel
|
|
|
|
ChannelUpdateEvent discord.Channel
|
|
|
|
ChannelDeleteEvent discord.Channel
|
|
|
|
ChannelPinsUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id,omitempty"`
|
|
|
|
LastPin discord.Timestamp `json:"timestamp,omitempty"`
|
|
|
|
}
|
2020-02-16 05:29:25 +00:00
|
|
|
|
|
|
|
ChannelUnreadUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
|
|
|
|
ChannelUnreadUpdates []struct {
|
|
|
|
ID discord.Snowflake `json:"id"`
|
|
|
|
LastMessageID discord.Snowflake `json:"last_message_id"`
|
|
|
|
}
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#guilds
|
|
|
|
type (
|
2020-01-18 21:04:12 +00:00
|
|
|
GuildCreateEvent struct {
|
|
|
|
discord.Guild
|
|
|
|
|
|
|
|
Joined discord.Timestamp `json:"timestamp,omitempty"`
|
|
|
|
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-01-18 21:04:12 +00:00
|
|
|
Presences []discord.Presence `json:"presences,omitempty"`
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
GuildUpdateEvent discord.Guild
|
|
|
|
GuildDeleteEvent struct {
|
|
|
|
ID discord.Snowflake `json:"id"`
|
|
|
|
// Unavailable if false == removed
|
|
|
|
Unavailable bool `json:"unavailable"`
|
|
|
|
}
|
|
|
|
|
|
|
|
GuildBanAddEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
}
|
|
|
|
GuildBanRemoveEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
}
|
|
|
|
|
|
|
|
GuildEmojisUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
Emojis []discord.Emoji `json:"emoji"`
|
|
|
|
}
|
|
|
|
|
|
|
|
GuildIntegrationsUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
GuildMemberAddEvent struct {
|
|
|
|
discord.Member
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
}
|
|
|
|
GuildMemberRemoveEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
User discord.User `json:"user"`
|
|
|
|
}
|
|
|
|
GuildMemberUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
2020-01-18 21:04:12 +00:00
|
|
|
RoleIDs []discord.Snowflake `json:"roles"`
|
2020-01-15 04:43:34 +00:00
|
|
|
User discord.User `json:"user"`
|
|
|
|
Nick string `json:"nick"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GuildMembersChunkEvent is sent when Guild Request Members is called.
|
|
|
|
GuildMembersChunkEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
Members []discord.Member `json:"members"`
|
|
|
|
|
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
|
|
|
|
Presences []discord.Presence `json:"presences,omitempty"`
|
2020-07-11 19:50:32 +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 {
|
|
|
|
ID string `json:"id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
MemberCount uint64 `json:"member_count"`
|
|
|
|
OnlineCount uint64 `json:"online_count"`
|
|
|
|
|
|
|
|
// Groups is all the visible role sections.
|
|
|
|
Groups []GuildMemberListGroup `json:"groups"`
|
|
|
|
|
|
|
|
Ops []GuildMemberListOp `json:"ops"`
|
|
|
|
}
|
|
|
|
GuildMemberListGroup struct {
|
|
|
|
ID string `json:"id"` // either discord.Snowflake Role IDs or "online"
|
|
|
|
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
|
|
|
|
HoistedRole string `json:"hoisted_role"`
|
|
|
|
Presence discord.Presence `json:"presence"`
|
|
|
|
} `json:"member,omitempty"`
|
|
|
|
}
|
|
|
|
|
2020-01-15 04:43:34 +00:00
|
|
|
GuildRoleCreateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
Role discord.Role `json:"role"`
|
|
|
|
}
|
|
|
|
GuildRoleUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
Role discord.Role `json:"role"`
|
|
|
|
}
|
|
|
|
GuildRoleDeleteEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
RoleID discord.Snowflake `json:"role_id"`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
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"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
|
|
|
|
// 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"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-01-15 04:43:34 +00:00
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#messages
|
|
|
|
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 {
|
|
|
|
ID discord.Snowflake `json:"id"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
}
|
|
|
|
MessageDeleteBulkEvent struct {
|
|
|
|
IDs []discord.Snowflake `json:"ids"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageReactionAddEvent struct {
|
|
|
|
UserID discord.Snowflake `json:"user_id"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
MessageID discord.Snowflake `json:"message_id"`
|
|
|
|
|
|
|
|
Emoji discord.Emoji `json:"emoji,omitempty"`
|
|
|
|
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
|
|
|
}
|
|
|
|
MessageReactionRemoveEvent struct {
|
|
|
|
UserID discord.Snowflake `json:"user_id"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
MessageID discord.Snowflake `json:"message_id"`
|
2020-04-12 23:14:27 +00:00
|
|
|
Emoji discord.Emoji `json:"emoji"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
|
|
|
MessageReactionRemoveAllEvent struct {
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
2020-04-12 23:14:27 +00:00
|
|
|
MessageID discord.Snowflake `json:"message_id"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
}
|
|
|
|
MessageReactionRemoveEmoji struct {
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
MessageID discord.Snowflake `json:"message_id"`
|
|
|
|
Emoji discord.Emoji `json:"emoji"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
2020-01-15 04:43:34 +00:00
|
|
|
}
|
2020-02-16 05:29:25 +00:00
|
|
|
|
|
|
|
MessageAckEvent struct {
|
|
|
|
MessageID discord.Snowflake `json:"message_id"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#presence
|
|
|
|
type (
|
|
|
|
// Clients may only update their game status 5 times per 20 seconds.
|
2020-05-12 02:49:11 +00:00
|
|
|
PresenceUpdateEvent struct {
|
|
|
|
discord.Presence
|
|
|
|
}
|
2020-02-16 05:29:25 +00:00
|
|
|
PresencesReplaceEvent []discord.Presence
|
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 {
|
|
|
|
Status discord.Status `json:"status"`
|
|
|
|
SessionID string `json:"session_id"`
|
|
|
|
|
|
|
|
Game *discord.Activity `json:"game"`
|
|
|
|
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-01-20 08:53:23 +00:00
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
UserID discord.Snowflake `json:"user_id"`
|
|
|
|
Timestamp discord.UnixTimestamp `json:"timestamp"`
|
2020-01-15 04:43:34 +00:00
|
|
|
|
|
|
|
GuildID discord.Snowflake `json:"guild_id,omitempty"`
|
|
|
|
Member *discord.Member `json:"member,omitempty"`
|
|
|
|
}
|
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
|
|
|
)
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#voice
|
|
|
|
type (
|
2020-05-12 02:49:11 +00:00
|
|
|
VoiceStateUpdateEvent struct {
|
|
|
|
discord.VoiceState
|
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
VoiceServerUpdateEvent struct {
|
|
|
|
Token string `json:"token"`
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
Endpoint string `json:"endpoint"`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// https://discordapp.com/developers/docs/topics/gateway#webhooks
|
|
|
|
type (
|
|
|
|
WebhooksUpdateEvent struct {
|
|
|
|
GuildID discord.Snowflake `json:"guild_id"`
|
|
|
|
ChannelID discord.Snowflake `json:"channel_id"`
|
|
|
|
}
|
|
|
|
)
|
2020-01-19 21:54:16 +00:00
|
|
|
|
|
|
|
// Undocumented
|
|
|
|
type (
|
2020-05-12 02:49:11 +00:00
|
|
|
UserGuildSettingsUpdateEvent struct {
|
|
|
|
UserGuildSettings
|
|
|
|
}
|
|
|
|
UserSettingsUpdateEvent struct {
|
|
|
|
UserSettings
|
|
|
|
}
|
|
|
|
UserNoteUpdateEvent struct {
|
2020-02-16 05:29:25 +00:00
|
|
|
ID discord.Snowflake `json:"id"`
|
|
|
|
Note string `json:"note"`
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2020-07-11 07:01:02 +00:00
|
|
|
RelationshipAddEvent struct {
|
2020-05-12 02:49:11 +00:00
|
|
|
Relationship
|
|
|
|
}
|
2020-07-11 07:01:02 +00:00
|
|
|
RelationshipRemoveEvent struct {
|
2020-05-12 02:49:11 +00:00
|
|
|
Relationship
|
|
|
|
}
|
2020-01-19 21:54:16 +00:00
|
|
|
)
|