-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractions.go
728 lines (603 loc) · 21.5 KB
/
interactions.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
package httpcord
import (
"encoding/json"
"httpcord/permissions"
)
type (
InteractionType int
InteractionCallbackType int
ApplicationCommandType int
ButtonStyle int
TextStyle int
ComponentType int
ApplicationCommandOptionType int
AnyComponent interface{}
)
// Interaction Types
const (
PingInteraction InteractionType = iota + 1
ApplicationCommandInteraction
MessageComponentInteraction
AutoCompleteInteraction
ModalSubmitInteraction
)
// Interaction Callback Types
const (
PongResponse InteractionCallbackType = iota + 1
_
_
ChannelMessageWithSourceResponse
DeferredChannelMessageWithSourceResponse
DeferredUpdateResponse
UpdateMessageResponse
ApplicationCommandAutoCompleteResultResponse
ModalResponse
)
// Commands Types
const (
ChatInputApplicationCommandType ApplicationCommandType = iota + 1
UserApplicationCommandType
MessageApplicationCommandType
)
// Button Styles
const (
PrimaryButtonStyle ButtonStyle = iota + 1
SecondaryButtonStyle
SuccessButtonStyle
DangerButtonStyle
LinkButtonStyle
)
// Text Styles
const (
ShortTextStyle TextStyle = iota + 1
ParagraphTextStyle
)
// Component Types
const (
ActionRowComponentType ComponentType = iota + 1
ButtonComponentType
SelectMenuComponentType
InputTextComponentType
)
// Application Command Option Type
const (
SubCommandApplicationCommandOptionType ApplicationCommandOptionType = iota + 1
SubCommandGroupApplicationCommandOptionType
StringApplicationCommandOptionType
IntApplicationCommandOptionType
BoolApplicationCommandOptionType
UserApplicationCommandOptionType
ChannelApplicationCommandOptionType
RoleApplicationCommandOptionType
MentionableApplicationCommandOptionType
NumberApplicationCommandOptionType
AttachmentApplicationCommandOptionType
)
type Interaction struct {
ID Snowflake `json:"id"`
ApplicationID Snowflake `json:"application_id"`
Type InteractionType `json:"type"`
Data interface{} `json:"data,omitempty"`
GuildID Snowflake `json:"guild_id"`
ChannelID Snowflake `json:"channel_id"`
Member *Member `json:"member"`
User *User `json:"user"`
Token string `json:"token"`
Message *Message `json:"message,omitempty"`
Version int `json:"version,omitempty"`
Locale string `json:"locale"`
GuildLocale string `json:"guild_locale"`
}
type ApplicationCommandInteractionData struct {
ID Snowflake `json:"id"`
Name string `json:"name"`
Type ApplicationCommandOptionType `json:"type"`
Resolved ResolvedData `json:"resolved,omitempty"`
Options []ApplicationCommandOption `json:"options,omitempty"`
GuildID Snowflake `json:"guild_id,omitempty"`
TargetID Snowflake `json:"target_id,omitempty"`
}
type ResolvedData struct {
Users []*User `json:"users,omitempty"`
Members []*Member `json:"members,omitempty"`
Roles []*Role `json:"roles,omitempty"`
Channels []*Channel `json:"channels,omitempty"`
Messages []*Message `json:"messages,omitempty"`
Attachments []*Attachment `json:"attachment,omitempty"`
}
type InteractionCallbackData struct {
TTS bool `json:"tts,omitempty"`
Content string `json:"content,omitempty"`
Embeds []*Embed `json:"embeds,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
Flags MessageFlag `json:"flags,omitempty"`
Components []*ActionRowComponent `json:"components"`
Attachments []*Attachment `json:"attachments,omitempty"`
Files []*DiscordFile `json:"-"`
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`
CustomID string `json:"custom_id,omitempty"`
Title string `json:"title,omitempty"`
}
type InteractionResponse struct {
Type InteractionCallbackType `json:"type"`
Data *InteractionCallbackData `json:"data,omitempty"`
}
type TextInputComponent struct {
Type ComponentType `json:"type"`
CustomID string `json:"custom_id,omitempty"`
Style TextStyle `json:"style,omitempty"`
Label string `json:"label,omitempty"`
MinLength *int `json:"min_length,omitempty"`
MaxLength *int `json:"max_length,omitempty"`
Required bool `json:"required,omitempty"`
Value string `json:"value,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
}
type ButtonComponent struct {
Type ComponentType `json:"type"`
CustomID string `json:"custom_id,omitempty"`
Style ButtonStyle `json:"style,omitempty"`
Label string `json:"label,omitempty"`
Emoji *Emoji `json:"emoji,omitempty"`
URL string `json:"url,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
type SelectMenuComponent struct {
Type ComponentType `json:"type"`
CustomID string `json:"custom_id"`
Options []*ComponentOption `json:"options,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
MinValues *int `json:"min_values,omitempty"`
MaxValues *int `json:"max_values,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
type ActionRowComponent struct {
Type ComponentType `json:"type"`
Components []AnyComponent `json:"components"`
}
type Modal struct {
CustomID string `json:"custom_id"`
Title string `json:"title"`
Components []*ActionRowComponent `json:"components"`
}
type ComponentOption struct {
Label string `json:"label"`
Value string `json:"value"`
Description string `json:"description,omitempty"`
Emoji *Emoji `json:"emoji,omitempty"`
Default bool `json:"default"`
}
type ApplicationCommandOptionChoice struct {
Name string `json:"name"`
NameLocalizations Dictionary `json:"name_localizations,omitempty"`
Value interface{} `json:"value"`
}
type ApplicationCommandOption struct {
Type ApplicationCommandOptionType `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Required bool `json:"required,omitempty"`
Choices []ApplicationCommandOptionChoice `json:"choices,omitempty"`
Options []ApplicationCommandOption `json:"options,omitempty"`
ChannelTypes []ChannelType `json:"channel_types,omitempty"`
MinValue float64 `json:"min_value,omitempty"`
MaxValue *float64 `json:"max_value,omitempty"`
Autocomplete bool `json:"autocomplete,omitempty"`
Value interface{}
}
type ApplicationCommand struct {
// ID is the unique id of the command
ID Snowflake `json:"id,omitempty"`
// ApplicationCommandType is the type of command, defaults 1 if not set
Type *ApplicationCommandType `json:"type,omitempty"`
// ApplicationID is the unique id of the parent application
ApplicationID Snowflake `json:"application_id,omitempty"`
// GuildID guild id of the command, if not global
GuildID *Snowflake `json:"guild_id,omitempty"`
// Name is a 1-32 character name
Name string `json:"name"`
// NameLocalizations dictionary for name field. Values follow the same restrictions as name
NameLocalizations Dictionary `json:"name_localizations,omitempty"`
// Description is a 1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands
Description string `json:"description,omitempty"`
// DescriptionLocalizations dictionary for description field. Values follow the same restrictions as description
DescriptionLocalizations Dictionary `json:"description_localizations,omitempty"`
// Options are the parameters for the command, max 25, only valid for CHAT_INPUT commands
Options []ApplicationCommandOption `json:"options"`
// DefaultPermissions Set of permissions represented as a bit set
DefaultPermissions *permissions.PermissionBit `json:"default_member_permissions,omitempty"`
// AllowUseInDMs Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
AllowUseInDMs *bool `json:"dm_permission,omitempty"`
// DefaultPermission is whether the command is enabled by default when the app is added to a guild
DefaultPermission *bool `json:"default_permission,omitempty"`
// Version is an autoincrement version identifier updated during substantial record changes
Version Snowflake `json:"version,omitempty"`
}
type ComponentInteractionData struct {
CustomID string `json:"custom_id"`
ComponentType ComponentType `json:"component_type"`
Values []string `json:"values"`
}
type ModalSubmitInteractionData struct {
CustomID string `json:"custom_id"`
Components []*ActionRowComponent `json:"components"`
}
func (i *Interaction) ModalSubmitData() ModalSubmitInteractionData {
if i.Type != ModalSubmitInteraction {
panic("The Interaction is not a ModalSubmit")
}
return i.Data.(ModalSubmitInteractionData)
}
func (i *Interaction) ApplicationCommandData() ApplicationCommandInteractionData {
if i.Type != ApplicationCommandInteraction && i.Type != AutoCompleteInteraction {
panic("The Interaction is not a ApplicationCommand")
}
return i.Data.(ApplicationCommandInteractionData)
}
func (i *Interaction) ComponentData() ComponentInteractionData {
if i.Type != MessageComponentInteraction {
panic("The Interaction is not a Component")
}
return i.Data.(ComponentInteractionData)
}
func (c *ApplicationCommandInteractionData) UserValue(name string, required bool) *User {
return c.GetOption(name, UserApplicationCommandOptionType, required).(*User)
}
func (c *ApplicationCommandInteractionData) StringValue(name string, required bool) string {
return c.GetOption(name, UserApplicationCommandOptionType, required).(string)
}
func (c *ApplicationCommandInteractionData) BoolValue(name string, required bool) bool {
return c.GetOption(name, UserApplicationCommandOptionType, required).(bool)
}
func (c *ApplicationCommandInteractionData) MemberValue(name string, required bool) *Member {
return c.GetOption(name, UserApplicationCommandOptionType, required).(*Member)
}
func (c *ApplicationCommandInteractionData) IntValue(name string, required bool) int {
return c.GetOption(name, UserApplicationCommandOptionType, required).(int)
}
func (c *ApplicationCommandInteractionData) NumberValue(name string, required bool) float64 {
return c.GetOption(name, UserApplicationCommandOptionType, required).(float64)
}
func (c *ApplicationCommandInteractionData) ChannelValue(name string, required bool) *Channel {
return c.GetOption(name, ChannelApplicationCommandOptionType, required).(*Channel)
}
func (c *ApplicationCommandInteractionData) AttachmentValue(name string, required bool) *Attachment {
return c.GetOption(name, AttachmentApplicationCommandOptionType, required).(*Attachment)
}
// MentionableValue MentionableValue Returns Member, User or Role
func (c *ApplicationCommandInteractionData) MentionableValue(name string, required bool) interface{} {
return c.GetOption(name, MentionableApplicationCommandOptionType, required)
}
func (c *ApplicationCommandInteractionData) RoleValue(name string, required bool) *Role {
return c.GetOption(name, UserApplicationCommandOptionType, required).(*Role)
}
func (c *ApplicationCommandInteractionData) SubCommand() ApplicationCommandOption {
option := c.Options[0]
if option.Type != SubCommandApplicationCommandOptionType {
panic("Could not find SubCommand")
}
return option
}
func (c *ApplicationCommandInteractionData) SubCommandGroup() ApplicationCommandOption {
option := c.Options[0]
if option.Type != SubCommandApplicationCommandOptionType {
panic("Could not find SubCommandGroup")
}
return option
}
func (c *ApplicationCommandInteractionData) GetOption(name string, Type ApplicationCommandOptionType, required bool) interface{} {
for _, option := range c.Options {
if option.Name == name && option.Type == Type {
return option.Value
}
}
if required {
panic("Could not find any option of type " + Type.String())
}
return nil
}
func (t ApplicationCommandOptionType) String() string {
switch t {
case IntApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Integer)"
}
case NumberApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Float64)"
}
case BoolApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Boolean)"
}
case UserApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(User)"
}
case RoleApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Role)"
}
case AttachmentApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Attachment)"
}
case ChannelApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Channel)"
}
case MentionableApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(Mentionable)"
}
case SubCommandApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(SubCommand)"
}
case SubCommandGroupApplicationCommandOptionType:
{
return "ApplicationCommandOptionType(SubCommandGroup)"
}
default:
{
return "ApplicationCommandOptionType(String)"
}
}
}
// Builders
// SelectMenuComponentBuilder
func NewSelectMenuComponentBuilder() *SelectMenuComponent {
return &SelectMenuComponent{Type: SelectMenuComponentType}
}
func (s *SelectMenuComponent) AddOption(option *ComponentOption) *SelectMenuComponent {
s.Options = append(s.Options, option)
return s
}
func (s *SelectMenuComponent) SetOptions(options ...*ComponentOption) *SelectMenuComponent {
s.Options = options
return s
}
func (s *SelectMenuComponent) SetPlaceholder(placeholder string) *SelectMenuComponent {
s.Placeholder = placeholder
return s
}
func (s *SelectMenuComponent) SetMinValues(MinValues *int) *SelectMenuComponent {
s.MinValues = MinValues
return s
}
func (s *SelectMenuComponent) SetMaxValues(MaxValues *int) *SelectMenuComponent {
s.MaxValues = MaxValues
return s
}
func (s *SelectMenuComponent) IsDisabled(disabled bool) *SelectMenuComponent {
s.Disabled = disabled
return s
}
func (s *SelectMenuComponent) SetCustomID(customID string) *SelectMenuComponent {
s.CustomID = customID
return s
}
// ApplicationCommandOptionBuilder
func ApplicationCommandOptionBuilder() *ApplicationCommandOption {
return &ApplicationCommandOption{}
}
func (o *ApplicationCommandOption) SetType(Type ApplicationCommandOptionType) *ApplicationCommandOption {
o.Type = Type
return o
}
func (o *ApplicationCommandOption) SetName(name string) *ApplicationCommandOption {
o.Name = name
return o
}
func (o *ApplicationCommandOption) SetDescription(description string) *ApplicationCommandOption {
o.Description = description
return o
}
func (o *ApplicationCommandOption) AddOption(ApplicationCommandOption ApplicationCommandOption) *ApplicationCommandOption {
o.Options = append(o.Options, ApplicationCommandOption)
return o
}
func (o *ApplicationCommandOption) SetOptions(options ...ApplicationCommandOption) *ApplicationCommandOption {
o.Options = options
return o
}
func (o *ApplicationCommandOption) AddChoice(choice ApplicationCommandOptionChoice) *ApplicationCommandOption {
o.Choices = append(o.Choices, choice)
return o
}
func (o *ApplicationCommandOption) SetChoices(choices ...ApplicationCommandOptionChoice) *ApplicationCommandOption {
o.Choices = choices
return o
}
func (o *ApplicationCommandOption) IsRequired(required bool) *ApplicationCommandOption {
o.Required = required
return o
}
func (o *ApplicationCommandOption) SetMinValue(MinValue float64) *ApplicationCommandOption {
o.MinValue = MinValue
return o
}
func (o *ApplicationCommandOption) SetMaxValue(MaxValue *float64) *ApplicationCommandOption {
o.MaxValue = MaxValue
return o
}
// TextInputComponentBuilder
func NewTextInputComponentBuilder() *TextInputComponent {
return &TextInputComponent{Type: InputTextComponentType}
}
func (t *TextInputComponent) SetCustomID(customID string) *TextInputComponent {
t.CustomID = customID
return t
}
func (t *TextInputComponent) SetStyle(style TextStyle) *TextInputComponent {
t.Style = style
return t
}
func (t *TextInputComponent) SetLabel(label string) *TextInputComponent {
t.Label = label
return t
}
func (t *TextInputComponent) SetMinLength(MinLength *int) *TextInputComponent {
t.MinLength = MinLength
return t
}
func (t *TextInputComponent) SetMaxLength(MaxLength *int) *TextInputComponent {
t.MaxLength = MaxLength
return t
}
func (t *TextInputComponent) IsRequired(required bool) *TextInputComponent {
t.Required = required
return t
}
func (t *TextInputComponent) SetPlaceholder(placeholder string) *TextInputComponent {
t.Placeholder = placeholder
return t
}
// ButtonComponentBuilder
func NewButtonComponentBuilder() *ButtonComponent {
return &ButtonComponent{Type: ButtonComponentType}
}
func (b *ButtonComponent) SetStyle(style ButtonStyle) *ButtonComponent {
b.Style = style
return b
}
func (b *ButtonComponent) SetLabel(label string) *ButtonComponent {
b.Label = label
return b
}
func (b *ButtonComponent) SetEmoji(emoji *Emoji) *ButtonComponent {
b.Emoji = emoji
return b
}
func (b *ButtonComponent) SetCustomID(customID string) *ButtonComponent {
b.CustomID = customID
return b
}
func (b *ButtonComponent) SetURL(URL string) *ButtonComponent {
b.URL = URL
return b
}
func (b *ButtonComponent) IsDisabled(disabled bool) *ButtonComponent {
b.Disabled = disabled
return b
}
// ActionRowComponentBuilder
func NewActionRowComponentBuilder() *ActionRowComponent {
return &ActionRowComponent{Type: ActionRowComponentType}
}
func (a *ActionRowComponent) AddComponent(component AnyComponent) *ActionRowComponent {
a.Components = append(a.Components, component)
return a
}
func (a *ActionRowComponent) SetComponents(components ...AnyComponent) *ActionRowComponent {
a.Components = components
return a
}
// ApplicationCommandOptionChoiceBuilder
func NewApplicationCommandOptionChoiceBuilder() *ApplicationCommandOptionChoice {
return &ApplicationCommandOptionChoice{}
}
func (c *ApplicationCommandOptionChoice) SetName(name string) *ApplicationCommandOptionChoice {
c.Name = name
return c
}
func (c *ApplicationCommandOptionChoice) SetValue(value interface{}) *ApplicationCommandOptionChoice {
c.Value = value
return c
}
func (c *ApplicationCommandOptionChoice) SetNameLocalizations(NameLocalizations Dictionary) *ApplicationCommandOptionChoice {
c.NameLocalizations = NameLocalizations
return c
}
// ApplicationCommandBuilder
func NewCommandBuilder() *ApplicationCommand {
return &ApplicationCommand{}
}
func (c *ApplicationCommand) SetType(Type ApplicationCommandType) *ApplicationCommand {
c.Type = &Type
return c
}
func (c *ApplicationCommand) SetName(name string) *ApplicationCommand {
c.Name = name
return c
}
func (c *ApplicationCommand) SetDescription(description string) *ApplicationCommand {
c.Description = description
return c
}
func (c *ApplicationCommand) AddOption(option ApplicationCommandOption) *ApplicationCommand {
c.Options = append(c.Options, option)
return c
}
func (c *ApplicationCommand) SetOptions(options ...ApplicationCommandOption) *ApplicationCommand {
c.Options = options
return c
}
func (c *ApplicationCommand) AllowDM(allow bool) *ApplicationCommand {
c.AllowUseInDMs = &allow
return c
}
func (c *ApplicationCommand) SetDefaultPermissions(bits *permissions.PermissionBit) *ApplicationCommand {
c.DefaultPermissions = bits
return c
}
func (c *ApplicationCommand) SetNameLocalizations(NameLocalizations Dictionary) *ApplicationCommand {
c.NameLocalizations = NameLocalizations
return c
}
func (c *ApplicationCommand) SetDescriptionLocalizations(DescriptionLocalizations Dictionary) *ApplicationCommand {
c.DescriptionLocalizations = DescriptionLocalizations
return c
}
func ResolveInteraction(rawInteraction *APIInteraction) Interaction {
if rawInteraction.Type == PingInteraction {
return Interaction{Type: rawInteraction.Type}
}
interaction := &Interaction{
ID: Snowflake(rawInteraction.ID),
ApplicationID: Snowflake(rawInteraction.ApplicationID),
Type: rawInteraction.Type,
GuildID: Snowflake(rawInteraction.GuildID),
ChannelID: Snowflake(rawInteraction.ChannelID),
}
if interaction.GuildID.String() != "" {
interaction.Member = ResolveMember(rawInteraction.Member)
interaction.User = ResolveUser(rawInteraction.Member.User)
} else {
interaction.User = ResolveUser(rawInteraction.User)
}
marshaledData, err := json.Marshal(rawInteraction.Data)
if err != nil {
panic(err)
}
switch interaction.Type {
case MessageComponentInteraction:
{
var data ComponentInteractionData
err = json.Unmarshal(marshaledData, &data)
if err != nil {
panic(err)
}
interaction.Data = data
}
case ModalSubmitInteraction:
{
var data ModalSubmitInteractionData
err = json.Unmarshal(marshaledData, &data)
if err != nil {
panic(err)
}
interaction.Data = data
}
case ApplicationCommandInteraction:
{
var data ApplicationCommandInteractionData
err = json.Unmarshal(marshaledData, &data)
if err != nil {
panic(err)
}
interaction.Data = data
}
}
return *interaction
}