Skip to content

Commit

Permalink
add: コンポーネントとモーダルにも追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
ikafly144 committed May 12, 2023
1 parent 4a252e5 commit 573b1d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handler/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ComponentHandler func(event *events.ComponentInteractionCreate) error
type Component struct {
Name string
Check Check[*events.ComponentInteractionCreate]
Checks map[string]Check[*events.ComponentInteractionCreate]
Handler map[string]ComponentHandler
}

Expand All @@ -36,6 +37,10 @@ func (h *Handler) handleComponent(event *events.ComponentInteractionCreate) {
return
}

if check, ok := component.Checks[componentName]; ok && !check(event) {
return
}

handler, ok := component.Handler[subName]
if !ok {
h.Logger.Debugf("不明なハンダラ %s", subName)
Expand Down
5 changes: 5 additions & 0 deletions handler/modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ModalHandler func(event *events.ModalSubmitInteractionCreate) error
type Modal struct {
Name string
Check Check[*events.ModalSubmitInteractionCreate]
Checks map[string]Check[*events.ModalSubmitInteractionCreate]
Handler map[string]ModalHandler
}

Expand All @@ -36,6 +37,10 @@ func (h *Handler) handleModal(event *events.ModalSubmitInteractionCreate) {
return
}

if check, ok := modal.Checks[modalName]; ok && !check(event) {
return
}

handler, ok := modal.Handler[subName]
if !ok {
h.Logger.Debugf("不明なハンダラ %s", subName)
Expand Down

0 comments on commit 573b1d0

Please sign in to comment.