From 75ff7342b1e4e3735d662ed00302675eb760e3fe Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 23 Aug 2022 13:42:29 -0700 Subject: [PATCH] api: Add InteractionHandlerFunc --- api/webhook/interactionserver.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/webhook/interactionserver.go b/api/webhook/interactionserver.go index 38ed908..ce86732 100644 --- a/api/webhook/interactionserver.go +++ b/api/webhook/interactionserver.go @@ -44,6 +44,15 @@ type InteractionHandler interface { HandleInteraction(*discord.InteractionEvent) *api.InteractionResponse } +// InteractionHandlerFunc is a function type that implements the interface. +type InteractionHandlerFunc func(*discord.InteractionEvent) *api.InteractionResponse + +var _ InteractionHandler = InteractionHandlerFunc(nil) + +func (f InteractionHandlerFunc) HandleInteraction(ev *discord.InteractionEvent) *api.InteractionResponse { + return f(ev) +} + type alwaysDeferInteraction struct { f func(*discord.InteractionEvent) flags discord.MessageFlags