-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable dynamic command names #2
Comments
It'd be an interesting thing to have - I am, however, not too sure how I'd make an API like that look. Do you have any examples of how you'd like to use it, or how you'd hook into the various parameters of the defined commands? Spitballing, I think my first go at it would start by abstracting out information about the structure of a command into a separate container, and having that container be mutable at group registration time (probably via some fluent API, allowing runtime modification/overriding of fallback attributes). Maybe something like this? serviceCollection.AddCommandGroup<MyGroup>
(
g => g
.WithCommand(MyGroup.MyCommand)
.WithNamedParameter
(
// unsure of how to access parameters here - by name, index, or either/both? //
longName: "my-parameter",
shortName: 'p'
)
) I know Discord.NET has something like this, but I'm not familiar with that portion of their API. |
The start of the Discord.Net implementation is The usage for the metadata that Remora.Commands has similar to // ModuleBuilder is the type
commandService.CreateModuleAsync(group, (ModuleBuilder b) => b.AddCommand(command, ExecuteCommandFunc, CreateCommandFunc);
void CreateCommandFunc(CommandBuilder builder)
{
builder.AddAliases("b", "c")
.AddParameter(name, type, CreateParameterFunc);
}
void CreateParameterFunc(ParameterBuilder builder)
{
builder.TypeReader = myTypeReader;
} A similar pattern could be used if you wanted to do something similar to Discord.Net. |
Right, I see, so it creates groups without involving declaring a class at all. That's interesting - it's a lot more involved than I first considered. |
Correct, it basically allows the user to construct the equivalent of the CommandNode / GroupNode via an API. |
Being capable of defining the group or command name at runtime would be nice.
This would allow applications to use an external source (EG: a configuration file) to define the structure of commands.
The text was updated successfully, but these errors were encountered: