github.com/meowstercatel/discordgo@v0.0.0-20250615204139-29b43d676735/events.go (about) 1 package discordgo 2 3 import ( 4 "encoding/json" 5 ) 6 7 // This file contains all the possible structs that can be 8 // handled by AddHandler/EventHandler. 9 // DO NOT ADD ANYTHING BUT EVENT HANDLER STRUCTS TO THIS FILE. 10 //go:generate go run tools/cmd/eventhandlers/main.go 11 12 // Connect is the data for a Connect event. 13 // This is a synthetic event and is not dispatched by Discord. 14 type Connect struct{} 15 16 // Disconnect is the data for a Disconnect event. 17 // This is a synthetic event and is not dispatched by Discord. 18 type Disconnect struct{} 19 20 // RateLimit is the data for a RateLimit event. 21 // This is a synthetic event and is not dispatched by Discord. 22 type RateLimit struct { 23 *TooManyRequests 24 URL string 25 } 26 27 // Event provides a basic initial struct for all websocket events. 28 type Event struct { 29 Operation int `json:"op"` 30 Sequence int64 `json:"s"` 31 Type string `json:"t"` 32 RawData json.RawMessage `json:"d"` 33 // Struct contains one of the other types in this file. 34 Struct interface{} `json:"-"` 35 } 36 37 // A Ready stores all data for the websocket READY event. 38 type Ready struct { 39 Version int `json:"v"` 40 SessionID string `json:"session_id"` 41 User *User `json:"user"` 42 Shard *[2]int `json:"shard"` 43 Application *Application `json:"application"` 44 Guilds []*Guild `json:"guilds"` 45 PrivateChannels []*Channel `json:"private_channels"` 46 } 47 48 // ChannelCreate is the data for a ChannelCreate event. 49 type ChannelCreate struct { 50 *Channel 51 } 52 53 // ChannelUpdate is the data for a ChannelUpdate event. 54 type ChannelUpdate struct { 55 *Channel 56 BeforeUpdate *Channel `json:"-"` 57 } 58 59 // ChannelDelete is the data for a ChannelDelete event. 60 type ChannelDelete struct { 61 *Channel 62 } 63 64 // ChannelPinsUpdate stores data for a ChannelPinsUpdate event. 65 type ChannelPinsUpdate struct { 66 LastPinTimestamp string `json:"last_pin_timestamp"` 67 ChannelID string `json:"channel_id"` 68 GuildID string `json:"guild_id,omitempty"` 69 } 70 71 // ThreadCreate is the data for a ThreadCreate event. 72 type ThreadCreate struct { 73 *Channel 74 NewlyCreated bool `json:"newly_created"` 75 } 76 77 // ThreadUpdate is the data for a ThreadUpdate event. 78 type ThreadUpdate struct { 79 *Channel 80 BeforeUpdate *Channel `json:"-"` 81 } 82 83 // ThreadDelete is the data for a ThreadDelete event. 84 type ThreadDelete struct { 85 *Channel 86 } 87 88 // ThreadListSync is the data for a ThreadListSync event. 89 type ThreadListSync struct { 90 // The id of the guild 91 GuildID string `json:"guild_id"` 92 // The parent channel ids whose threads are being synced. 93 // If omitted, then threads were synced for the entire guild. 94 // This array may contain channel_ids that have no active threads as well, so you know to clear that data. 95 ChannelIDs []string `json:"channel_ids"` 96 // All active threads in the given channels that the current user can access 97 Threads []*Channel `json:"threads"` 98 // All thread member objects from the synced threads for the current user, 99 // indicating which threads the current user has been added to 100 Members []*ThreadMember `json:"members"` 101 } 102 103 // ThreadMemberUpdate is the data for a ThreadMemberUpdate event. 104 type ThreadMemberUpdate struct { 105 *ThreadMember 106 GuildID string `json:"guild_id"` 107 } 108 109 // ThreadMembersUpdate is the data for a ThreadMembersUpdate event. 110 type ThreadMembersUpdate struct { 111 ID string `json:"id"` 112 GuildID string `json:"guild_id"` 113 MemberCount int `json:"member_count"` 114 AddedMembers []AddedThreadMember `json:"added_members"` 115 RemovedMembers []string `json:"removed_member_ids"` 116 } 117 118 // GuildCreate is the data for a GuildCreate event. 119 type GuildCreate struct { 120 *Guild 121 } 122 123 // GuildUpdate is the data for a GuildUpdate event. 124 type GuildUpdate struct { 125 *Guild 126 } 127 128 // GuildDelete is the data for a GuildDelete event. 129 type GuildDelete struct { 130 *Guild 131 BeforeDelete *Guild `json:"-"` 132 } 133 134 // GuildBanAdd is the data for a GuildBanAdd event. 135 type GuildBanAdd struct { 136 User *User `json:"user"` 137 GuildID string `json:"guild_id"` 138 } 139 140 // GuildBanRemove is the data for a GuildBanRemove event. 141 type GuildBanRemove struct { 142 User *User `json:"user"` 143 GuildID string `json:"guild_id"` 144 } 145 146 // GuildMemberAdd is the data for a GuildMemberAdd event. 147 type GuildMemberAdd struct { 148 *Member 149 } 150 151 // GuildMemberUpdate is the data for a GuildMemberUpdate event. 152 type GuildMemberUpdate struct { 153 *Member 154 BeforeUpdate *Member `json:"-"` 155 } 156 157 // GuildMemberRemove is the data for a GuildMemberRemove event. 158 type GuildMemberRemove struct { 159 *Member 160 } 161 162 // GuildRoleCreate is the data for a GuildRoleCreate event. 163 type GuildRoleCreate struct { 164 *GuildRole 165 } 166 167 // GuildRoleUpdate is the data for a GuildRoleUpdate event. 168 type GuildRoleUpdate struct { 169 *GuildRole 170 } 171 172 // A GuildRoleDelete is the data for a GuildRoleDelete event. 173 type GuildRoleDelete struct { 174 RoleID string `json:"role_id"` 175 GuildID string `json:"guild_id"` 176 } 177 178 // A GuildEmojisUpdate is the data for a guild emoji update event. 179 type GuildEmojisUpdate struct { 180 GuildID string `json:"guild_id"` 181 Emojis []*Emoji `json:"emojis"` 182 } 183 184 // A GuildStickersUpdate is the data for a GuildStickersUpdate event. 185 type GuildStickersUpdate struct { 186 GuildID string `json:"guild_id"` 187 Stickers []*Sticker `json:"stickers"` 188 } 189 190 // A GuildMembersChunk is the data for a GuildMembersChunk event. 191 type GuildMembersChunk struct { 192 GuildID string `json:"guild_id"` 193 Members []*Member `json:"members"` 194 ChunkIndex int `json:"chunk_index"` 195 ChunkCount int `json:"chunk_count"` 196 NotFound []string `json:"not_found,omitempty"` 197 Presences []*Presence `json:"presences,omitempty"` 198 Nonce string `json:"nonce,omitempty"` 199 } 200 201 // GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event. 202 type GuildIntegrationsUpdate struct { 203 GuildID string `json:"guild_id"` 204 } 205 206 // StageInstanceEventCreate is the data for a StageInstanceEventCreate event. 207 type StageInstanceEventCreate struct { 208 *StageInstance 209 } 210 211 // StageInstanceEventUpdate is the data for a StageInstanceEventUpdate event. 212 type StageInstanceEventUpdate struct { 213 *StageInstance 214 } 215 216 // StageInstanceEventDelete is the data for a StageInstanceEventDelete event. 217 type StageInstanceEventDelete struct { 218 *StageInstance 219 } 220 221 // GuildScheduledEventCreate is the data for a GuildScheduledEventCreate event. 222 type GuildScheduledEventCreate struct { 223 *GuildScheduledEvent 224 } 225 226 // GuildScheduledEventUpdate is the data for a GuildScheduledEventUpdate event. 227 type GuildScheduledEventUpdate struct { 228 *GuildScheduledEvent 229 } 230 231 // GuildScheduledEventDelete is the data for a GuildScheduledEventDelete event. 232 type GuildScheduledEventDelete struct { 233 *GuildScheduledEvent 234 } 235 236 // GuildScheduledEventUserAdd is the data for a GuildScheduledEventUserAdd event. 237 type GuildScheduledEventUserAdd struct { 238 GuildScheduledEventID string `json:"guild_scheduled_event_id"` 239 UserID string `json:"user_id"` 240 GuildID string `json:"guild_id"` 241 } 242 243 // GuildScheduledEventUserRemove is the data for a GuildScheduledEventUserRemove event. 244 type GuildScheduledEventUserRemove struct { 245 GuildScheduledEventID string `json:"guild_scheduled_event_id"` 246 UserID string `json:"user_id"` 247 GuildID string `json:"guild_id"` 248 } 249 250 // IntegrationCreate is the data for a IntegrationCreate event. 251 type IntegrationCreate struct { 252 *Integration 253 GuildID string `json:"guild_id"` 254 } 255 256 // IntegrationUpdate is the data for a IntegrationUpdate event. 257 type IntegrationUpdate struct { 258 *Integration 259 GuildID string `json:"guild_id"` 260 } 261 262 // IntegrationDelete is the data for a IntegrationDelete event. 263 type IntegrationDelete struct { 264 ID string `json:"id"` 265 GuildID string `json:"guild_id"` 266 ApplicationID string `json:"application_id,omitempty"` 267 } 268 269 // MessageCreate is the data for a MessageCreate event. 270 type MessageCreate struct { 271 *Message 272 } 273 274 // UnmarshalJSON is a helper function to unmarshal MessageCreate object. 275 func (m *MessageCreate) UnmarshalJSON(b []byte) error { 276 return json.Unmarshal(b, &m.Message) 277 } 278 279 // MessageUpdate is the data for a MessageUpdate event. 280 type MessageUpdate struct { 281 *Message 282 // BeforeUpdate will be nil if the Message was not previously cached in the state cache. 283 BeforeUpdate *Message `json:"-"` 284 } 285 286 // UnmarshalJSON is a helper function to unmarshal MessageUpdate object. 287 func (m *MessageUpdate) UnmarshalJSON(b []byte) error { 288 return json.Unmarshal(b, &m.Message) 289 } 290 291 // MessageDelete is the data for a MessageDelete event. 292 type MessageDelete struct { 293 *Message 294 BeforeDelete *Message `json:"-"` 295 } 296 297 // UnmarshalJSON is a helper function to unmarshal MessageDelete object. 298 func (m *MessageDelete) UnmarshalJSON(b []byte) error { 299 return json.Unmarshal(b, &m.Message) 300 } 301 302 // MessageReactionAdd is the data for a MessageReactionAdd event. 303 type MessageReactionAdd struct { 304 *MessageReaction 305 Member *Member `json:"member,omitempty"` 306 } 307 308 // MessageReactionRemove is the data for a MessageReactionRemove event. 309 type MessageReactionRemove struct { 310 *MessageReaction 311 } 312 313 // MessageReactionRemoveAll is the data for a MessageReactionRemoveAll event. 314 type MessageReactionRemoveAll struct { 315 *MessageReaction 316 } 317 318 // PresencesReplace is the data for a PresencesReplace event. 319 type PresencesReplace []*Presence 320 321 // PresenceUpdate is the data for a PresenceUpdate event. 322 type PresenceUpdate struct { 323 Presence 324 GuildID string `json:"guild_id"` 325 } 326 327 // Resumed is the data for a Resumed event. 328 type Resumed struct { 329 Trace []string `json:"_trace"` 330 } 331 332 // TypingStart is the data for a TypingStart event. 333 type TypingStart struct { 334 UserID string `json:"user_id"` 335 ChannelID string `json:"channel_id"` 336 GuildID string `json:"guild_id,omitempty"` 337 Timestamp int `json:"timestamp"` 338 } 339 340 // UserUpdate is the data for a UserUpdate event. 341 type UserUpdate struct { 342 *User 343 } 344 345 // VoiceServerUpdate is the data for a VoiceServerUpdate event. 346 type VoiceServerUpdate struct { 347 Token string `json:"token"` 348 GuildID string `json:"guild_id"` 349 Endpoint string `json:"endpoint"` 350 } 351 352 // VoiceStateUpdate is the data for a VoiceStateUpdate event. 353 type VoiceStateUpdate struct { 354 *VoiceState 355 // BeforeUpdate will be nil if the VoiceState was not previously cached in the state cache. 356 BeforeUpdate *VoiceState `json:"-"` 357 } 358 359 // MessageDeleteBulk is the data for a MessageDeleteBulk event 360 type MessageDeleteBulk struct { 361 Messages []string `json:"ids"` 362 ChannelID string `json:"channel_id"` 363 GuildID string `json:"guild_id"` 364 } 365 366 // WebhooksUpdate is the data for a WebhooksUpdate event 367 type WebhooksUpdate struct { 368 GuildID string `json:"guild_id"` 369 ChannelID string `json:"channel_id"` 370 } 371 372 // InteractionCreate is the data for a InteractionCreate event 373 type InteractionCreate struct { 374 *Interaction 375 } 376 377 // UnmarshalJSON is a helper function to unmarshal Interaction object. 378 func (i *InteractionCreate) UnmarshalJSON(b []byte) error { 379 return json.Unmarshal(b, &i.Interaction) 380 } 381 382 // InviteCreate is the data for a InviteCreate event 383 type InviteCreate struct { 384 *Invite 385 ChannelID string `json:"channel_id"` 386 GuildID string `json:"guild_id"` 387 } 388 389 // InviteDelete is the data for a InviteDelete event 390 type InviteDelete struct { 391 ChannelID string `json:"channel_id"` 392 GuildID string `json:"guild_id"` 393 Code string `json:"code"` 394 } 395 396 // ApplicationCommandPermissionsUpdate is the data for an ApplicationCommandPermissionsUpdate event 397 type ApplicationCommandPermissionsUpdate struct { 398 *GuildApplicationCommandPermissions 399 } 400 401 // AutoModerationRuleCreate is the data for an AutoModerationRuleCreate event. 402 type AutoModerationRuleCreate struct { 403 *AutoModerationRule 404 } 405 406 // AutoModerationRuleUpdate is the data for an AutoModerationRuleUpdate event. 407 type AutoModerationRuleUpdate struct { 408 *AutoModerationRule 409 } 410 411 // AutoModerationRuleDelete is the data for an AutoModerationRuleDelete event. 412 type AutoModerationRuleDelete struct { 413 *AutoModerationRule 414 } 415 416 // AutoModerationActionExecution is the data for an AutoModerationActionExecution event. 417 type AutoModerationActionExecution struct { 418 GuildID string `json:"guild_id"` 419 Action AutoModerationAction `json:"action"` 420 RuleID string `json:"rule_id"` 421 RuleTriggerType AutoModerationRuleTriggerType `json:"rule_trigger_type"` 422 UserID string `json:"user_id"` 423 ChannelID string `json:"channel_id"` 424 MessageID string `json:"message_id"` 425 AlertSystemMessageID string `json:"alert_system_message_id"` 426 Content string `json:"content"` 427 MatchedKeyword string `json:"matched_keyword"` 428 MatchedContent string `json:"matched_content"` 429 } 430 431 // GuildAuditLogEntryCreate is the data for a GuildAuditLogEntryCreate event. 432 type GuildAuditLogEntryCreate struct { 433 *AuditLogEntry 434 GuildID string `json:"guild_id"` 435 } 436 437 // MessagePollVoteAdd is the data for a MessagePollVoteAdd event. 438 type MessagePollVoteAdd struct { 439 UserID string `json:"user_id"` 440 ChannelID string `json:"channel_id"` 441 MessageID string `json:"message_id"` 442 GuildID string `json:"guild_id,omitempty"` 443 AnswerID int `json:"answer_id"` 444 } 445 446 // MessagePollVoteRemove is the data for a MessagePollVoteRemove event. 447 type MessagePollVoteRemove struct { 448 UserID string `json:"user_id"` 449 ChannelID string `json:"channel_id"` 450 MessageID string `json:"message_id"` 451 GuildID string `json:"guild_id,omitempty"` 452 AnswerID int `json:"answer_id"` 453 } 454 455 // EntitlementCreate is the data for an EntitlementCreate event. 456 type EntitlementCreate struct { 457 *Entitlement 458 } 459 460 // EntitlementUpdate is the data for an EntitlementUpdate event. 461 type EntitlementUpdate struct { 462 *Entitlement 463 } 464 465 // EntitlementDelete is the data for an EntitlementDelete event. 466 // NOTE: Entitlements are not deleted when they expire. 467 type EntitlementDelete struct { 468 *Entitlement 469 } 470 471 // SubscriptionCreate is the data for an SubscriptionCreate event. 472 // https://discord.com/developers/docs/monetization/implementing-app-subscriptions#using-subscription-events-for-the-subscription-lifecycle 473 type SubscriptionCreate struct { 474 *Subscription 475 } 476 477 // SubscriptionUpdate is the data for an SubscriptionUpdate event. 478 // https://discord.com/developers/docs/monetization/implementing-app-subscriptions#using-subscription-events-for-the-subscription-lifecycle 479 type SubscriptionUpdate struct { 480 *Subscription 481 } 482 483 // SubscriptionDelete is the data for an SubscriptionDelete event. 484 // https://discord.com/developers/docs/monetization/implementing-app-subscriptions#using-subscription-events-for-the-subscription-lifecycle 485 type SubscriptionDelete struct { 486 *Subscription 487 }