1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 17:23:00 +00:00

Fixed subcommand bug where argv[0] is invalid

This commit is contained in:
diamondburned (Forefront) 2020-01-25 14:15:42 -08:00
parent 39e6188787
commit 9d5164be65

View file

@ -224,21 +224,24 @@ func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
}
}
// Create a zero value instance of this
// Create a zero value instance of this:
v := reflect.New(cmd.Arguments[0].Type)
// Call the manual parse method
// Pop out the subcommand name:
args = args[1:]
// Call the manual parse method:
ret := cmd.Arguments[0].manual.Func.Call([]reflect.Value{
v, reflect.ValueOf(args),
})
// Check the method returns for error
// Check the method returns for error:
if err := errorReturns(ret); err != nil {
// TODO: maybe wrap this?
return err
}
// Add the pointer to the argument into argv
// Add the pointer to the argument into argv:
argv = append(argv, v)
goto Call
}