Command handler register overhaul#1414
Conversation
773b633 to
59ea77d
Compare
59ea77d to
9a78cb4
Compare
|
@valzargaming re this comment: Right now, there seems an issue with registering a command with subcommands in one go, like so: $discord->listenCommand(['command', 'subcommand1', 'subcommand2', /* ... */], execute(...), autocomplete(...));Registering a single command and adding subcommands via the method on the $registeredCommand = $discord->listenCommand('command', execute(...), autocomplete(...));
foreach(['subcommand1', 'subcommand2', /* ... */] as $subcommand){
$registeredCommand->addSubCommand($subcommand, execute(...), autocomplete(...));
}Then apparently there's this case too, as mentioned in the other issue: $discord->listenCommand(['command', 'subcommand1'], execute(...), autocomplete(...));
$discord->listenCommand(['command', 'subcommand2'], execute(...), autocomplete(...));
/* ... */Further I can see it being used somehow like this: $discord->listenCommand(['command', ['subcommandgroup1', 'subcommand1'], ['subcommandgroup2', 'subcommand1'], /* ... */], execute(...), autocomplete(...));All in all I think that's too much complexity and error prone behaviour to handle (I don't even know yet where and how subcommand groups are handled). The method should offer stricter parameters, and/or additional methods that properly handle a single task in a concise way should be added. This way it should be possible to call the method repeatedly without throwing and handle the internals without confusion: $discord->listenCommand(name: 'command', callback: execute(...), autocomplete_callback: autocomplete(...));
$discord->listenCommand('command', 'subcommandgroup1', ['subcommand1', /* ... */], execute(...), autocomplete(...));
$discord->listenCommand('command', 'subcommandgroup2', ['subcommand1', /* ... */], execute(...), autocomplete(...)); |
|
@Log1x, whenever you get the chance, what are your thoughts on this? I know Laracord abstracts a lot of this logic, and I think changing things as they are would break the existing framework. |
As per the conversation in #1413.