forked from andersfylling/disgord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
804 lines (612 loc) · 28.2 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
package disgord
import (
"context"
"sync"
"github.com/andersfylling/disgord/event"
)
type eventBox interface {
registerContext(ctx context.Context)
}
// EventAllEvents keys that does not fit within one of the existing files goes here
const EventAllEvents = "*"
// EventCallback is triggered on every event type
type EventCallback = func(session Session, box interface{})
// ---------------------------
// Hello defines the heartbeat interval
type Hello struct {
HeartbeatInterval uint `json:"heartbeat_interval"`
Trace []string `json:"_trace"`
Ctx context.Context `json:"-"`
}
func (h *Hello) registerContext(ctx context.Context) { h.Ctx = ctx }
// HelloCallback triggered in hello events
type HelloCallback = func(session Session, h *Hello)
// ---------------------------
// EventPresencesReplace Holds and array of presence update objects
const EventPresencesReplace = event.PresencesReplace
// PresencesReplace holds the event content
type PresencesReplace struct {
Presnces []*PresenceUpdate `json:"presences_replace"` // TODO: verify json tag
Ctx context.Context `json:"-"`
}
func (p *PresencesReplace) registerContext(ctx context.Context) { p.Ctx = ctx }
// PresencesReplaceCallback callback for EventPresencesReplace
type PresencesReplaceCallback = func(session Session, pr *PresencesReplace)
// ---------------------------
// EventReady The ready event is dispatched when a client has completed the
// initial handshake with the gateway (for new sessions). The ready
// event can be the largest and most complex event the gateway will
// send, as it contains all the state required for a client to begin
// interacting with the rest of the platform.
// Fields:
// * V uint8
// * User *discord.user.User
// * PrivateChannels []*discord.channel.Private
// * Guilds []*discord.guild.Unavailable
// * SessionID string
// * Trace []string
const EventReady = event.Ready
// Ready contains the initial state information
type Ready struct {
APIVersion int `json:"v"`
User *User `json:"user"`
Guilds []*GuildUnavailable `json:"guilds"`
// not really needed, as it is handled on the socket layer.
SessionID string `json:"session_id"`
Trace []string `json:"_trace"`
// private_channels will be an empty array. As bots receive private messages,
// they will be notified via Channel Create events.
//PrivateChannels []*channel.Channel `json:"private_channels"`
// bot can't have presences
//Presences []*Presence `json:"presences"`
// bot cant have relationships
//Relationships []interface{} `son:"relationships"`
// bot can't have user settings
// UserSettings interface{} `json:"user_settings"`
sync.RWMutex `json:"-"`
Ctx context.Context `json:"-"`
}
func (obj *Ready) registerContext(ctx context.Context) { obj.Ctx = ctx }
// ReadyCallback triggered on READY events
type ReadyCallback = func(session Session, r *Ready)
// ---------------------------
// EventResumed The resumed event is dispatched when a client has sent a resume
// payload to the gateway (for resuming existing sessions).
// Fields:
// * Trace []string
const EventResumed = event.Resumed
// Resumed response to Resume
type Resumed struct {
Trace []string `json:"_trace"`
Ctx context.Context `json:"-"`
}
func (obj *Resumed) registerContext(ctx context.Context) { obj.Ctx = ctx }
// ResumedCallback triggered on RESUME events
type ResumedCallback = func(session Session, r *Resumed)
// ---------------------------
// InvalidSession failure response to Identify or Resume or invalid active session
type InvalidSession struct {
Ctx context.Context `json:"-"`
}
func (obj *InvalidSession) registerContext(ctx context.Context) { obj.Ctx = ctx }
// InvalidSessionCallback triggered on INVALID_SESSION events
type InvalidSessionCallback = func(session Session, is *InvalidSession)
// ---------------------------
// EventChannelCreate Sent when a new channel is created, relevant to the current
// user. The inner payload is a DM channel or guild channel
// object.
const EventChannelCreate = event.ChannelCreate
// ChannelCreateBox new channel created
type ChannelCreate struct {
Channel *Channel `json:"channel"`
Ctx context.Context `json:"-"`
}
func (obj *ChannelCreate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *ChannelCreate) UnmarshalJSON(data []byte) error {
obj.Channel = &Channel{}
return unmarshal(data, obj.Channel)
}
// ChannelCreateCallback triggered on CHANNEL_CREATE events
type ChannelCreateCallback = func(session Session, cc *ChannelCreate)
// ---------------------------
// EventChannelUpdate Sent when a channel is updated. The inner payload is a guild
// channel object.
const EventChannelUpdate = event.ChannelUpdate
// ChannelUpdateBox channel was updated
type ChannelUpdate struct {
Channel *Channel `json:"channel"`
Ctx context.Context `json:"-"`
}
func (obj *ChannelUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *ChannelUpdate) UnmarshalJSON(data []byte) error {
obj.Channel = &Channel{}
return unmarshal(data, obj.Channel)
}
// ChannelUpdateCallback triggered on CHANNEL_UPDATE events
type ChannelUpdateCallback = func(session Session, cu *ChannelUpdate)
// ---------------------------
// EventChannelDelete Sent when a channel relevant to the current user is deleted.
// The inner payload is a DM or Guild channel object.
const EventChannelDelete = event.ChannelDelete
// ChannelDelete channel was deleted
type ChannelDelete struct {
Channel *Channel `json:"channel"`
Ctx context.Context `json:"-"`
}
func (obj *ChannelDelete) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *ChannelDelete) UnmarshalJSON(data []byte) error {
obj.Channel = &Channel{}
return unmarshal(data, obj.Channel)
}
// ChannelDeleteCallback triggered on CHANNEL_DELETE events
type ChannelDeleteCallback = func(session Session, cd *ChannelDelete)
// ---------------------------
// EventChannelPinsUpdate Sent when a message is pinned or unpinned in a text
// channel. This is not sent when a pinned message is
// deleted.
// Fields:
// * ChannelID int64 or discord.Snowflake
// * LastPinTimestamp time.Now().UTC().Format(time.RFC3339)
// TODO fix.
const EventChannelPinsUpdate = event.ChannelPinsUpdate
// ChannelPinsUpdate message was pinned or unpinned
type ChannelPinsUpdate struct {
// ChannelID snowflake the id of the channel
ChannelID Snowflake `json:"channel_id"`
// LastPinTimestamp ISO8601 timestamp the time at which the most recent pinned message was pinned
LastPinTimestamp Timestamp `json:"last_pin_timestamp,omitempty"` // ?|
Ctx context.Context `json:"-"`
}
func (obj *ChannelPinsUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// ChannelPinsUpdateCallback triggered on CHANNEL_PINS_UPDATE events
type ChannelPinsUpdateCallback = func(session Session, cpu *ChannelPinsUpdate)
// ---------------------------
// EventTypingStart Sent when a user starts typing in a channel.
// Fields: TODO
const EventTypingStart = event.TypingStart
// TypingStart user started typing in a channel
type TypingStart struct {
ChannelID Snowflake `json:"channel_id"`
UserID Snowflake `json:"user_id"`
TimestampUnix int `json:"timestamp"`
Ctx context.Context `json:"-"`
}
func (obj *TypingStart) registerContext(ctx context.Context) { obj.Ctx = ctx }
// TypingStartCallback triggered on TYPING_START events
type TypingStartCallback = func(session Session, ts *TypingStart)
// ---------------------------
// EventMessageCreate Sent when a message is created. The inner payload is a
// message object.
const EventMessageCreate = event.MessageCreate
// MessageCreate message was created
type MessageCreate struct {
Message *Message
Ctx context.Context `json:"-"`
}
func (obj *MessageCreate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *MessageCreate) UnmarshalJSON(data []byte) error {
obj.Message = &Message{}
return unmarshal(data, obj.Message)
}
// MessageCreateCallback triggered on MESSAGE_CREATE events
type MessageCreateCallback = func(session Session, mc *MessageCreate)
// ---------------------------
// EventMessageUpdate Sent when a message is updated. The inner payload is a
// message object.
// NOTE! Has _at_least_ the GuildID and ChannelID fields.
const EventMessageUpdate = event.MessageUpdate
// MessageUpdate message was edited
type MessageUpdate struct {
Message *Message
Ctx context.Context `json:"-"`
}
func (obj *MessageUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *MessageUpdate) UnmarshalJSON(data []byte) error {
obj.Message = &Message{}
return unmarshal(data, obj.Message)
}
// MessageUpdateCallback triggered on MESSAGE_UPDATE events
type MessageUpdateCallback = func(session Session, mu *MessageUpdate)
// ---------------------------
// EventMessageDelete Sent when a message is deleted.
// Fields:
// * ID int64 or discord.Snowflake
// * ChannelID int64 or discord.Snowflake
const EventMessageDelete = event.MessageDelete
// MessageDelete message was deleted
type MessageDelete struct {
MessageID Snowflake `json:"id"`
ChannelID Snowflake `json:"channel_id"`
Ctx context.Context `json:"-"`
}
func (obj *MessageDelete) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *MessageDelete) UnmarshalJSON(data []byte) (err error) {
msg := &Message{}
err = unmarshal(data, msg)
if err != nil {
return
}
obj.MessageID = msg.ID
obj.ChannelID = msg.ChannelID
return
}
// MessageDeleteCallback triggered on MESSAGE_DELETE events
type MessageDeleteCallback = func(session Session, md *MessageDelete)
// ---------------------------
// EventMessageDeleteBulk Sent when multiple messages are deleted at once.
// Fields:
// * IDs []int64 or []discord.Snowflake
// * ChannelID int64 or discord.Snowflake
const EventMessageDeleteBulk = event.MessageDeleteBulk
// MessageDeleteBulk multiple messages were deleted at once
type MessageDeleteBulk struct {
MessageIDs []Snowflake `json:"ids"`
ChannelID Snowflake `json:"channel_id"`
Ctx context.Context `json:"-"`
}
func (obj *MessageDeleteBulk) registerContext(ctx context.Context) { obj.Ctx = ctx }
// MessageDeleteBulkCallback triggered on MESSAGE_DELETE_BULK events
type MessageDeleteBulkCallback = func(session Session, mdb *MessageDeleteBulk)
// ---------------------------
// EventMessageReactionAdd Sent when a user adds a reaction to a message.
// Fields:
// * UserID int64 or discord.Snowflake
// * ChannelID int64 or discord.Snowflake
// * MessageID int64 or discord.Snowflake
// * Emoji *discord.emoji.Emoji
const EventMessageReactionAdd = event.MessageReactionAdd
// MessageReactionAdd user reacted to a message
type MessageReactionAdd struct {
UserID Snowflake `json:"user_id"`
ChannelID Snowflake `json:"channel_id"`
MessageID Snowflake `json:"message_id"`
// PartialEmoji id and name. id might be nil
PartialEmoji *Emoji `json:"emoji"`
Ctx context.Context `json:"-"`
}
func (obj *MessageReactionAdd) registerContext(ctx context.Context) { obj.Ctx = ctx }
// MessageReactionAddCallback triggered on MESSAGE_REACTION_ADD events
type MessageReactionAddCallback = func(session Session, mra *MessageReactionAdd)
// ---------------------------
// EventMessageReactionRemove Sent when a user removes a reaction from a message.
// Fields:
// * UserID int64 or discord.Snowflake
// * ChannelID int64 or discord.Snowflake
// * MessageID int64 or discord.Snowflake
// * Emoji *discord.emoji.Emoji
const EventMessageReactionRemove = event.MessageReactionRemove
// MessageReactionRemove user removed a reaction from a message
type MessageReactionRemove struct {
UserID Snowflake `json:"user_id"`
ChannelID Snowflake `json:"channel_id"`
MessageID Snowflake `json:"message_id"`
// PartialEmoji id and name. id might be nil
PartialEmoji *Emoji `json:"emoji"`
Ctx context.Context `json:"-"`
}
func (obj *MessageReactionRemove) registerContext(ctx context.Context) { obj.Ctx = ctx }
// MessageReactionRemoveCallback triggered on MESSAGE_REACTION_REMOVE events
type MessageReactionRemoveCallback = func(session Session, mrr *MessageReactionRemove)
// ---------------------------
// EventMessageReactionRemoveAll Sent when a user explicitly removes all reactions
// from a message.
// Fields:
// * ChannelID int64 or discord.Snowflake
// * MessageID int64 or discord.Snowflake
const EventMessageReactionRemoveAll = event.MessageReactionRemoveAll
// MessageReactionRemoveAll all reactions were explicitly removed from a message
type MessageReactionRemoveAll struct {
ChannelID Snowflake `json:"channel_id"`
MessageID Snowflake `json:"id"`
Ctx context.Context `json:"-"`
}
func (obj *MessageReactionRemoveAll) registerContext(ctx context.Context) { obj.Ctx = ctx }
// MessageReactionRemoveAllCallback triggered on MESSAGE_REACTION_REMOVE_ALL events
type MessageReactionRemoveAllCallback = func(session Session, mrra *MessageReactionRemoveAll)
// ---------------------------
// EventGuildEmojisUpdate Sent when a guild's emojis have been updated.
// Fields:
// * GuildID int64 or discord.Snowflake
const EventGuildEmojisUpdate = event.GuildEmojisUpdate
// GuildEmojisUpdate guild emojis were updated
type GuildEmojisUpdate struct {
GuildID Snowflake `json:"guild_id"`
Emojis []*Emoji `json:"emojis"`
Ctx context.Context `json:"-"`
}
func (obj *GuildEmojisUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildEmojisUpdateCallback triggered on GUILD_EMOJIS_UPDATE events
type GuildEmojisUpdateCallback = func(session Session, geu *GuildEmojisUpdate)
// ---------------------------
// EventGuildCreate This event can be sent in three different scenarios:
// 1. When a user is initially connecting, to lazily load and
// backfill information for all unavailable guilds sent in the
// Ready event.
// 2. When a Guild becomes available again to the client.
// 3. When the current user joins a new Guild.
// The inner payload is a guild object, with all the extra fields
// specified.
const EventGuildCreate = event.GuildCreate
// GuildCreate This event can be sent in three different scenarios:
// 1. When a user is initially connecting, to lazily load and backfill information for
// all unavailable guilds sent in the Ready event.
// 2. When a Guild becomes available again to the client.
// 3. When the current user joins a new Guild.
type GuildCreate struct {
Guild *Guild `json:"guild"`
Ctx context.Context `json:"-"`
}
func (obj *GuildCreate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *GuildCreate) UnmarshalJSON(data []byte) error {
obj.Guild = &Guild{}
return unmarshal(data, obj.Guild)
}
// GuildCreateCallback triggered on GUILD_CREATE events
type GuildCreateCallback = func(session Session, gc *GuildCreate)
// ---------------------------
// EventGuildUpdate Sent when a guild is updated. The inner payload is a guild
// object.
const EventGuildUpdate = event.GuildUpdate
// GuildUpdate guild was updated
type GuildUpdate struct {
Guild *Guild `json:"guild"`
Ctx context.Context `json:"-"`
}
func (obj *GuildUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *GuildUpdate) UnmarshalJSON(data []byte) error {
obj.Guild = &Guild{}
return unmarshal(data, obj.Guild)
}
// GuildUpdateCallback triggered on GUILD_UPDATE events
type GuildUpdateCallback = func(session Session, gu *GuildUpdate)
// ---------------------------
// EventGuildDelete Sent when a guild becomes unavailable during a guild outage,
// or when the user leaves or is removed from a guild. The inner
// payload is an unavailable guild object. If the unavailable
// field is not set, the user was removed from the guild.
const EventGuildDelete = event.GuildDelete
// GuildDelete guild became unavailable, or user left/was removed from a guild
type GuildDelete struct {
UnavailableGuild *GuildUnavailable `json:"guild_unavailable"`
Ctx context.Context `json:"-"`
}
func (obj *GuildDelete) registerContext(ctx context.Context) { obj.Ctx = ctx }
func (obj *GuildDelete) UnmarshalJSON(data []byte) error {
obj.UnavailableGuild = &GuildUnavailable{}
return unmarshal(data, obj.UnavailableGuild)
}
// GuildDeleteCallback triggered on GUILD_DELETE events
type GuildDeleteCallback = func(session Session, gd *GuildDelete)
// ---------------------------
// EventGuildBanAdd Sent when a user is banned from a guild. The inner payload is
// a user object, with an extra guild_id key.
const EventGuildBanAdd = event.GuildBanAdd
// GuildBanAdd user was banned from a guild
type GuildBanAdd struct {
User *User `json:"user"`
Ctx context.Context `json:"-"`
}
func (obj *GuildBanAdd) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildBanAddCallback triggered on GUILD_BAN_ADD events
type GuildBanAddCallback = func(session Session, gba *GuildBanAdd)
// ---------------------------
// EventGuildBanRemove Sent when a user is unbanned from a guild. The inner
// payload is a user object, with an extra guild_id key.
const EventGuildBanRemove = event.GuildBanRemove
// GuildBanRemove user was unbanned from a guild
type GuildBanRemove struct {
User *User `json:"user"`
Ctx context.Context `json:"-"`
}
func (obj *GuildBanRemove) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildBanRemoveCallback triggered on GUILD_BAN_REMOVE events
type GuildBanRemoveCallback = func(session Session, gbr *GuildBanRemove)
// ---------------------------
// EventGuildIntegrationsUpdate Sent when a guild integration is updated.
// Fields:
// * GuildID int64 or discord.Snowflake
// * Emojis []*discord.emoji.Emoji
const EventGuildIntegrationsUpdate = event.GuildIntegrationsUpdate
// GuildIntegrationsUpdate guild integration was updated
type GuildIntegrationsUpdate struct {
GuildID Snowflake `json:"guild_id"`
Ctx context.Context `json:"-"`
}
func (obj *GuildIntegrationsUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildIntegrationsUpdateCallback triggered on GUILD_INTEGRATIONS_UPDATE events
type GuildIntegrationsUpdateCallback = func(session Session, giu *GuildIntegrationsUpdate)
// ---------------------------
// EventGuildMemberAdd Sent when a new user joins a guild. The inner payload is a
// guild member object with these extra fields:
// * GuildID int64 or discord.Snowflake
const EventGuildMemberAdd = event.GuildMemberAdd
// GuildMemberAdd new user joined a guild
type GuildMemberAdd struct {
Member *Member `json:"member"`
Ctx context.Context `json:"-"`
}
func (obj *GuildMemberAdd) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildMemberAddCallback triggered on GUILD_MEMBER_ADD events
type GuildMemberAddCallback = func(session Session, gma *GuildMemberAdd)
// ---------------------------
// EventGuildMemberRemove Sent when a user is removed from a guild
// (leave/kick/ban).
// Fields:
// * GuildID int64 or discord.Snowflake
// * User *discord.user.User
const EventGuildMemberRemove = event.GuildMemberRemove
// GuildMemberRemove user was removed from a guild
type GuildMemberRemove struct {
GuildID Snowflake `json:"guild_id"`
User *User `json:"user"`
Ctx context.Context `json:"-"`
}
func (obj *GuildMemberRemove) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildMemberRemoveCallback triggered on GUILD_MEMBER_REMOVE events
type GuildMemberRemoveCallback = func(session Session, gmr *GuildMemberRemove)
// ---------------------------
// EventGuildMemberUpdate Sent when a guild member is updated.
// Fields:
// * GuildID int64 or discord.Snowflake
// * Roles []int64 or []discord.Snowflake
// * User *discord.user.User
// * Nick string
const EventGuildMemberUpdate = event.GuildMemberUpdate
// GuildMemberUpdate guild member was updated
type GuildMemberUpdate struct {
GuildID Snowflake `json:"guild_id"`
Roles []*Role `json:"roles"`
User *User `json:"user"`
Nick string `json:"nick"`
Ctx context.Context `json:"-"`
}
func (obj *GuildMemberUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildMemberUpdateCallback triggered on GUILD_MEMBER_UPDATE events
type GuildMemberUpdateCallback = func(session Session, gmu *GuildMemberUpdate)
// ---------------------------
// EventGuildMemberChunk Sent in response to Gateway Request Guild Members.
// Fields:
// * GuildID int64 or discord.Snowflake
// * Members []*discord.member.Member
const EventGuildMembersChunk = event.GuildMembersChunk
// GuildMembersChunk response to Request Guild Members
type GuildMembersChunk struct {
GuildID Snowflake `json:"guild_id"`
Members []*Member `json:"members"`
Ctx context.Context `json:"-"`
}
func (obj *GuildMembersChunk) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildMembersChunkCallback triggered on GUILD_MEMBERS_CHUNK events
type GuildMembersChunkCallback = func(session Session, gmc *GuildMembersChunk)
// ---------------------------
// EventGuildRoleCreate Sent when a guild role is created.
// Fields:
// * GuildID int64 or discord.Snowflake
// * Role *discord.role.Role
const EventGuildRoleCreate = event.GuildRoleCreate
// GuildRoleCreate guild role was created
type GuildRoleCreate struct {
GuildID Snowflake `json:"guild_id"`
Role *Role `json:"role"`
Ctx context.Context `json:"-"`
}
func (obj *GuildRoleCreate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildRoleCreateCallback triggered on GUILD_ROLE_CREATE events
type GuildRoleCreateCallback = func(session Session, grc *GuildRoleCreate)
// ---------------------------
// EventGuildRoleUpdate Sent when a guild role is created.
// Fields:
// * GuildID int64 or discord.Snowflake
// * Role *discord.role.Role
const EventGuildRoleUpdate = event.GuildRoleUpdate
// GuildRoleUpdate guild role was updated
type GuildRoleUpdate struct {
GuildID Snowflake `json:"guild_id"`
Role *Role `json:"role"`
Ctx context.Context `json:"-"`
}
func (obj *GuildRoleUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildRoleUpdateCallback triggered on GUILD_ROLE_UPDATE events
type GuildRoleUpdateCallback = func(session Session, gru *GuildRoleUpdate)
// ---------------------------
// EventGuildRoleDelete Sent when a guild role is created.
// Fields:
// * GuildID int64 or discord.Snowflake
// * RoleID int64 or discord.Snowflake
const EventGuildRoleDelete = event.GuildRoleDelete
// GuildRoleDelete guild role was deleted
type GuildRoleDelete struct {
GuildID Snowflake `json:"guild_id"`
RoleID Snowflake `json:"role_id"`
Ctx context.Context `json:"-"`
}
func (obj *GuildRoleDelete) registerContext(ctx context.Context) { obj.Ctx = ctx }
// GuildRoleDeleteCallback triggered on GUILD_ROLE_DELETE events
type GuildRoleDeleteCallback = func(session Session, grd *GuildRoleDelete)
// ---------------------------
// EventPresenceUpdate A user's presence is their current state on a guild.
// This event is sent when a user's presence is updated
// for a guild.
// Fields:
// User *discord.user.User
// Roles []*discord.role.Role
// Game *discord.game.Game
// GuildID int64 or discord.Snowflake
// Status *string or *discord.presence.Status
const EventPresenceUpdate = event.PresenceUpdate
// PresenceUpdate user's presence was updated in a guild
type PresenceUpdate struct {
User *User `json:"user"`
RoleIDs []Snowflake `json:"roles"`
Game *Activity `json:"game"`
GuildID Snowflake `json:"guild_id"`
// Status either "idle", "dnd", "online", or "offline"
// TODO: constants somewhere..
Status string `json:"status"`
Ctx context.Context `json:"-"`
}
func (obj *PresenceUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// PresenceUpdateCallback triggered on PRESENCE_UPDATE events
type PresenceUpdateCallback = func(session Session, pu *PresenceUpdate)
// ---------------------------
// EventUserUpdate Sent when properties about the user change. Inner payload is a
// user object.
const EventUserUpdate = event.UserUpdate
// UserUpdate properties about a user changed
type UserUpdate struct {
User *User `json:"user"`
Ctx context.Context `json:"-"`
}
func (obj *UserUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// UserUpdateCallback triggerd on USER_UPDATE events
type UserUpdateCallback = func(session Session, uu *UserUpdate)
// ---------------------------
// EventVoiceStateUpdate Sent when someone joins/leaves/moves voice channels.
// Inner payload is a voice state object.
const EventVoiceStateUpdate = event.VoiceStateUpdate
// VoiceStateUpdate someone joined, left, or moved a voice channel
type VoiceStateUpdate struct {
VoiceState *VoiceState `json:"voice_state"`
Ctx context.Context `json:"-"`
}
func (obj *VoiceStateUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// VoiceStateUpdateCallback triggered on VOICE_STATE_UPDATE events
type VoiceStateUpdateCallback = func(session Session, vsu *VoiceStateUpdate)
// ---------------------------
// EventVoiceServerUpdate Sent when a guild's voice server is updated. This is
// sent when initially connecting to voice, and when the
// current voice instance fails over to a new server.
// Fields:
// * Token string or discord.Token
// * ChannelID int64 or discord.Snowflake
// * Endpoint string or discord.Endpoint
const EventVoiceServerUpdate = event.VoiceServerUpdate
// VoiceServerUpdate guild's voice server was updated
// Sent when a guild's voice server is updated.
// This is sent when initially connecting to voice,
// and when the current voice instance fails over to a new server.
type VoiceServerUpdate struct {
Token string `json:"token"`
GuildID Snowflake `json:"guild_id"`
Endpoint string `json:"endpoint"`
Ctx context.Context `json:"-"`
}
func (obj *VoiceServerUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// VoiceServerUpdateCallback triggered on VOICE_SERVER_UPDATE events
type VoiceServerUpdateCallback = func(session Session, vsu *VoiceServerUpdate)
// ---------------------------
// EventWebhooksUpdate Sent when a guild channel's webhook is created, updated, or
// deleted.
// Fields:
// * GuildID int64 or discord.Snowflake
// * ChannelID int64 or discord.Snowflake
const EventWebhooksUpdate = event.WebhooksUpdate
// WebhooksUpdate guild channel webhook was created, update, or deleted
type WebhooksUpdate struct {
GuildID Snowflake `json:"guild_id"`
ChannelID Snowflake `json:"channel_id"`
Ctx context.Context `json:"-"`
}
func (obj *WebhooksUpdate) registerContext(ctx context.Context) { obj.Ctx = ctx }
// WebhooksUpdateCallback triggered on WEBHOOK_UPDATE events
type WebhooksUpdateCallback = func(session Session, wu *WebhooksUpdate)