mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-11-22 04:23:39 +00:00
cmdroute: Further deprecate Handle{Command,Autocompletion}
These functions now call HandleInteraction directly, which then calls internal functions. For incorrect uses, this change is breaking.
This commit is contained in:
parent
4d2f793418
commit
bc3439b8ff
|
|
@ -128,9 +128,9 @@ func (r *Router) With(mws ...Middleware) *Router {
|
||||||
func (r *Router) HandleInteraction(ev *discord.InteractionEvent) *api.InteractionResponse {
|
func (r *Router) HandleInteraction(ev *discord.InteractionEvent) *api.InteractionResponse {
|
||||||
switch data := ev.Data.(type) {
|
switch data := ev.Data.(type) {
|
||||||
case *discord.CommandInteraction:
|
case *discord.CommandInteraction:
|
||||||
return r.HandleCommand(ev, data)
|
return r.handleCommand(ev, data)
|
||||||
case *discord.AutocompleteInteraction:
|
case *discord.AutocompleteInteraction:
|
||||||
return r.HandleAutocompletion(ev, data)
|
return r.handleAutocompletion(ev, data)
|
||||||
case discord.ComponentInteraction:
|
case discord.ComponentInteraction:
|
||||||
return r.handleComponent(ev, data)
|
return r.handleComponent(ev, data)
|
||||||
default:
|
default:
|
||||||
|
|
@ -138,6 +138,23 @@ func (r *Router) HandleInteraction(ev *discord.InteractionEvent) *api.Interactio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HandleCommand implements CommandHandler. It applies middlewares onto the
|
||||||
|
// handler to be executed.
|
||||||
|
//
|
||||||
|
// Deprecated: This function should not be used directly. Use [HandleInteraction]
|
||||||
|
// instead. This function now calls HandleInteraction internally.
|
||||||
|
func (r *Router) HandleCommand(ev *discord.InteractionEvent, data *discord.CommandInteraction) *api.InteractionResponse {
|
||||||
|
return r.HandleInteraction(ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleAutocompletion handles an autocompletion event.
|
||||||
|
//
|
||||||
|
// Deprecated: This function should not be used directly. Use [HandleInteraction]
|
||||||
|
// instead. This function now calls HandleInteraction internally.
|
||||||
|
func (r *Router) HandleAutocompletion(ev *discord.InteractionEvent, data *discord.AutocompleteInteraction) *api.InteractionResponse {
|
||||||
|
return r.HandleInteraction(ev)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Router) callHandler(ev *discord.InteractionEvent, fn InteractionHandlerFunc) *api.InteractionResponse {
|
func (r *Router) callHandler(ev *discord.InteractionEvent, fn InteractionHandlerFunc) *api.InteractionResponse {
|
||||||
h := InteractionHandler(fn)
|
h := InteractionHandler(fn)
|
||||||
|
|
||||||
|
|
@ -154,12 +171,7 @@ func (r *Router) callHandler(ev *discord.InteractionEvent, fn InteractionHandler
|
||||||
return h.HandleInteraction(context.Background(), ev)
|
return h.HandleInteraction(context.Background(), ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleCommand implements CommandHandler. It applies middlewares onto the
|
func (r *Router) handleCommand(ev *discord.InteractionEvent, data *discord.CommandInteraction) *api.InteractionResponse {
|
||||||
// handler to be executed.
|
|
||||||
//
|
|
||||||
// Deprecated: This function should not be used directly. Use HandleInteraction
|
|
||||||
// instead.
|
|
||||||
func (r *Router) HandleCommand(ev *discord.InteractionEvent, data *discord.CommandInteraction) *api.InteractionResponse {
|
|
||||||
cmdType := discord.SubcommandOptionType
|
cmdType := discord.SubcommandOptionType
|
||||||
if cmdIsGroup(data) {
|
if cmdIsGroup(data) {
|
||||||
cmdType = discord.SubcommandGroupOptionType
|
cmdType = discord.SubcommandGroupOptionType
|
||||||
|
|
@ -278,11 +290,7 @@ func (r *Router) AddAutocompleterFunc(name string, f AutocompleterFunc) {
|
||||||
r.AddAutocompleter(name, f)
|
r.AddAutocompleter(name, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleAutocompletion handles an autocompletion event.
|
func (r *Router) handleAutocompletion(ev *discord.InteractionEvent, data *discord.AutocompleteInteraction) *api.InteractionResponse {
|
||||||
//
|
|
||||||
// Deprecated: This function should not be used directly. Use HandleInteraction
|
|
||||||
// instead.
|
|
||||||
func (r *Router) HandleAutocompletion(ev *discord.InteractionEvent, data *discord.AutocompleteInteraction) *api.InteractionResponse {
|
|
||||||
cmdType := discord.SubcommandOptionType
|
cmdType := discord.SubcommandOptionType
|
||||||
if autocompIsGroup(data) {
|
if autocompIsGroup(data) {
|
||||||
cmdType = discord.SubcommandGroupOptionType
|
cmdType = discord.SubcommandGroupOptionType
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue