github.com/diamondburned/arikawa@v1.3.14/gateway/events.go (about) 1 package gateway 2 3 import "github.com/diamondburned/arikawa/discord" 4 5 // Rules: VOICE_STATE_UPDATE -> VoiceStateUpdateEvent 6 7 // https://discordapp.com/developers/docs/topics/gateway#connecting-and-resuming 8 type ( 9 HelloEvent struct { 10 HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"` 11 } 12 13 // Ready is too big, so it's moved to ready.go 14 15 ResumedEvent struct{} 16 17 // InvalidSessionEvent indicates if the event is resumable. 18 InvalidSessionEvent bool 19 ) 20 21 // https://discordapp.com/developers/docs/topics/gateway#channels 22 type ( 23 ChannelCreateEvent struct { 24 discord.Channel 25 } 26 ChannelUpdateEvent struct { 27 discord.Channel 28 } 29 ChannelDeleteEvent struct { 30 discord.Channel 31 } 32 ChannelPinsUpdateEvent struct { 33 GuildID discord.GuildID `json:"guild_id,omitempty"` 34 ChannelID discord.ChannelID `json:"channel_id,omitempty"` 35 LastPin discord.Timestamp `json:"timestamp,omitempty"` 36 } 37 38 ChannelUnreadUpdateEvent struct { 39 GuildID discord.GuildID `json:"guild_id"` 40 41 ChannelUnreadUpdates []struct { 42 ID discord.ChannelID `json:"id"` 43 LastMessageID discord.MessageID `json:"last_message_id"` 44 } 45 } 46 ) 47 48 // https://discordapp.com/developers/docs/topics/gateway#guilds 49 type ( 50 GuildCreateEvent struct { 51 discord.Guild 52 53 Joined discord.Timestamp `json:"timestamp,omitempty"` 54 Large bool `json:"large,omitempty"` 55 Unavailable bool `json:"unavailable,omitempty"` 56 MemberCount uint64 `json:"member_count,omitempty"` 57 58 VoiceStates []discord.VoiceState `json:"voice_states,omitempty"` 59 Members []discord.Member `json:"members,omitempty"` 60 Channels []discord.Channel `json:"channels,omitempty"` 61 Presences []discord.Presence `json:"presences,omitempty"` 62 } 63 GuildUpdateEvent struct { 64 discord.Guild 65 } 66 GuildDeleteEvent struct { 67 ID discord.GuildID `json:"id"` 68 // Unavailable if false == removed 69 Unavailable bool `json:"unavailable"` 70 } 71 72 GuildBanAddEvent struct { 73 GuildID discord.GuildID `json:"guild_id"` 74 User discord.User `json:"user"` 75 } 76 GuildBanRemoveEvent struct { 77 GuildID discord.GuildID `json:"guild_id"` 78 User discord.User `json:"user"` 79 } 80 81 GuildEmojisUpdateEvent struct { 82 GuildID discord.GuildID `json:"guild_id"` 83 Emojis []discord.Emoji `json:"emoji"` 84 } 85 86 GuildIntegrationsUpdateEvent struct { 87 GuildID discord.GuildID `json:"guild_id"` 88 } 89 90 GuildMemberAddEvent struct { 91 discord.Member 92 GuildID discord.GuildID `json:"guild_id"` 93 } 94 GuildMemberRemoveEvent struct { 95 GuildID discord.GuildID `json:"guild_id"` 96 User discord.User `json:"user"` 97 } 98 GuildMemberUpdateEvent struct { 99 GuildID discord.GuildID `json:"guild_id"` 100 RoleIDs []discord.RoleID `json:"roles"` 101 User discord.User `json:"user"` 102 Nick string `json:"nick"` 103 } 104 105 // GuildMembersChunkEvent is sent when Guild Request Members is called. 106 GuildMembersChunkEvent struct { 107 GuildID discord.GuildID `json:"guild_id"` 108 Members []discord.Member `json:"members"` 109 110 ChunkIndex int `json:"chunk_index"` 111 ChunkCount int `json:"chunk_count"` 112 113 // Whatever's not found goes here 114 NotFound []string `json:"not_found,omitempty"` 115 116 // Only filled if requested 117 Presences []discord.Presence `json:"presences,omitempty"` 118 Nonce string `json:"nonce,omitempty"` 119 } 120 121 // GuildMemberListUpdate is an undocumented event. It's received when the 122 // client sends over GuildSubscriptions with the Channels field used. 123 // The State package does not handle this event. 124 GuildMemberListUpdate struct { 125 ID string `json:"id"` 126 GuildID discord.GuildID `json:"guild_id"` 127 MemberCount uint64 `json:"member_count"` 128 OnlineCount uint64 `json:"online_count"` 129 130 // Groups is all the visible role sections. 131 Groups []GuildMemberListGroup `json:"groups"` 132 133 Ops []GuildMemberListOp `json:"ops"` 134 } 135 GuildMemberListGroup struct { 136 ID string `json:"id"` // either discord.RoleID, "online" or "offline" 137 Count uint64 `json:"count"` 138 } 139 GuildMemberListOp struct { 140 // Mysterious string, so far spotted to be [SYNC, INSERT, UPDATE, DELETE]. 141 Op string `json:"op"` 142 143 // NON-SYNC ONLY 144 // Only available for Ops that aren't "SYNC". 145 Index int `json:"index,omitempty"` 146 Item GuildMemberListOpItem `json:"item,omitempty"` 147 148 // SYNC ONLY 149 // Range requested in GuildSubscribeData. 150 Range [2]int `json:"range,omitempty"` 151 // Items is basically a linear list of roles and members, similarly to 152 // how the client renders it. No, it's not nested. 153 Items []GuildMemberListOpItem `json:"items,omitempty"` 154 } 155 // GuildMemberListOpItem is an enum. Either of the fields are provided, but 156 // never both. Refer to (*GuildMemberListUpdate).Ops for more. 157 GuildMemberListOpItem struct { 158 Group *GuildMemberListGroup `json:"group,omitempty"` 159 Member *struct { 160 discord.Member 161 HoistedRole string `json:"hoisted_role"` 162 Presence discord.Presence `json:"presence"` 163 } `json:"member,omitempty"` 164 } 165 166 GuildRoleCreateEvent struct { 167 GuildID discord.GuildID `json:"guild_id"` 168 Role discord.Role `json:"role"` 169 } 170 GuildRoleUpdateEvent struct { 171 GuildID discord.GuildID `json:"guild_id"` 172 Role discord.Role `json:"role"` 173 } 174 GuildRoleDeleteEvent struct { 175 GuildID discord.GuildID `json:"guild_id"` 176 RoleID discord.RoleID `json:"role_id"` 177 } 178 ) 179 180 func (u GuildMemberUpdateEvent) Update(m *discord.Member) { 181 m.RoleIDs = u.RoleIDs 182 m.User = u.User 183 m.Nick = u.Nick 184 } 185 186 // https://discord.com/developers/docs/topics/gateway#invites 187 type ( 188 InviteCreateEvent struct { 189 Code string `json:"code"` 190 CreatedAt discord.Timestamp `json:"created_at"` 191 ChannelID discord.ChannelID `json:"channel_id"` 192 GuildID discord.GuildID `json:"guild_id,omitempty"` 193 194 // Similar to discord.Invite 195 Inviter *discord.User `json:"inviter,omitempty"` 196 Target *discord.User `json:"target_user,omitempty"` 197 TargetType discord.InviteUserType `json:"target_user_type,omitempty"` 198 199 discord.InviteMetadata 200 } 201 InviteDeleteEvent struct { 202 Code string `json:"code"` 203 ChannelID discord.ChannelID `json:"channel_id"` 204 GuildID discord.GuildID `json:"guild_id,omitempty"` 205 } 206 ) 207 208 // https://discordapp.com/developers/docs/topics/gateway#messages 209 type ( 210 MessageCreateEvent struct { 211 discord.Message 212 Member *discord.Member `json:"member,omitempty"` 213 } 214 MessageUpdateEvent struct { 215 discord.Message 216 Member *discord.Member `json:"member,omitempty"` 217 } 218 MessageDeleteEvent struct { 219 ID discord.MessageID `json:"id"` 220 ChannelID discord.ChannelID `json:"channel_id"` 221 GuildID discord.GuildID `json:"guild_id,omitempty"` 222 } 223 MessageDeleteBulkEvent struct { 224 IDs []discord.MessageID `json:"ids"` 225 ChannelID discord.ChannelID `json:"channel_id"` 226 GuildID discord.GuildID `json:"guild_id,omitempty"` 227 } 228 229 MessageReactionAddEvent struct { 230 UserID discord.UserID `json:"user_id"` 231 ChannelID discord.ChannelID `json:"channel_id"` 232 MessageID discord.MessageID `json:"message_id"` 233 234 Emoji discord.Emoji `json:"emoji,omitempty"` 235 236 GuildID discord.GuildID `json:"guild_id,omitempty"` 237 Member *discord.Member `json:"member,omitempty"` 238 } 239 MessageReactionRemoveEvent struct { 240 UserID discord.UserID `json:"user_id"` 241 ChannelID discord.ChannelID `json:"channel_id"` 242 MessageID discord.MessageID `json:"message_id"` 243 Emoji discord.Emoji `json:"emoji"` 244 GuildID discord.GuildID `json:"guild_id,omitempty"` 245 } 246 MessageReactionRemoveAllEvent struct { 247 ChannelID discord.ChannelID `json:"channel_id"` 248 MessageID discord.MessageID `json:"message_id"` 249 GuildID discord.GuildID `json:"guild_id,omitempty"` 250 } 251 MessageReactionRemoveEmoji struct { 252 ChannelID discord.ChannelID `json:"channel_id"` 253 MessageID discord.MessageID `json:"message_id"` 254 Emoji discord.Emoji `json:"emoji"` 255 GuildID discord.GuildID `json:"guild_id,omitempty"` 256 } 257 258 MessageAckEvent struct { 259 MessageID discord.MessageID `json:"message_id"` 260 ChannelID discord.ChannelID `json:"channel_id"` 261 } 262 ) 263 264 // https://discordapp.com/developers/docs/topics/gateway#presence 265 type ( 266 // Clients may only update their game status 5 times per 20 seconds. 267 PresenceUpdateEvent struct { 268 discord.Presence 269 } 270 PresencesReplaceEvent []discord.Presence 271 272 // SessionsReplaceEvent is an undocumented user event. It's likely used for 273 // current user's presence updates. 274 SessionsReplaceEvent []struct { 275 Status discord.Status `json:"status"` 276 SessionID string `json:"session_id"` 277 278 Game *discord.Activity `json:"game"` 279 Activities []discord.Activity `json:"activities"` 280 281 ClientInfo struct { 282 Version int `json:"version"` 283 OS string `json:"os"` 284 Client string `json:"client"` 285 } `json:"client_info"` 286 287 Active bool `json:"active"` 288 } 289 290 TypingStartEvent struct { 291 ChannelID discord.ChannelID `json:"channel_id"` 292 UserID discord.UserID `json:"user_id"` 293 Timestamp discord.UnixTimestamp `json:"timestamp"` 294 295 GuildID discord.GuildID `json:"guild_id,omitempty"` 296 Member *discord.Member `json:"member,omitempty"` 297 } 298 299 UserUpdateEvent struct { 300 discord.User 301 } 302 ) 303 304 // https://discordapp.com/developers/docs/topics/gateway#voice 305 type ( 306 VoiceStateUpdateEvent struct { 307 discord.VoiceState 308 } 309 VoiceServerUpdateEvent struct { 310 Token string `json:"token"` 311 GuildID discord.GuildID `json:"guild_id"` 312 Endpoint string `json:"endpoint"` 313 } 314 ) 315 316 // https://discordapp.com/developers/docs/topics/gateway#webhooks 317 type ( 318 WebhooksUpdateEvent struct { 319 GuildID discord.GuildID `json:"guild_id"` 320 ChannelID discord.ChannelID `json:"channel_id"` 321 } 322 ) 323 324 // Undocumented 325 type ( 326 UserGuildSettingsUpdateEvent struct { 327 UserGuildSettings 328 } 329 UserSettingsUpdateEvent struct { 330 UserSettings 331 } 332 UserNoteUpdateEvent struct { 333 ID discord.UserID `json:"id"` 334 Note string `json:"note"` 335 } 336 ) 337 338 type ( 339 RelationshipAddEvent struct { 340 discord.Relationship 341 } 342 RelationshipRemoveEvent struct { 343 discord.Relationship 344 } 345 )