Skip to content

Commit

Permalink
hardcoded modal helper
Browse files Browse the repository at this point in the history
  • Loading branch information
szerookii committed Apr 25, 2024
1 parent 43c5060 commit 6e36418
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions goscord/discord/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,44 @@ func (d *ModalSubmitData) UnmarshalJSON(data []byte) error {
return nil
}

func (m ModalSubmitData) Component(customId string) MessageComponent {
for _, c := range m.Components {
switch cc := c.(type) {
case *ActionRows:
for _, ac := range cc.Components {
switch ac.(type) {
case *TextInput:
if ac.(*TextInput).CustomId == customId {
return ac
}
case *Button:
if ac.(*Button).CustomId == customId {
return ac
}
case *SelectMenu:
if ac.(*SelectMenu).CustomId == customId {
return ac
}
}
}
case *TextInput:
if c.(*TextInput).CustomId == customId {
return c
}
case *Button:
if c.(*Button).CustomId == customId {
return c
}
case *SelectMenu:
if c.(*SelectMenu).CustomId == customId {
return c
}
}
}

return nil
}

type ResolvedData struct {
Users []*User `json:"users,omitempty"`
Members []*GuildMember `json:"members,omitempty"`
Expand Down

0 comments on commit 6e36418

Please sign in to comment.