serenity-rs / poise

Discord bot command framework for serenity, with advanced features like edit tracking and flexible argument parsing
MIT License
624 stars 111 forks source link

feature request: pass function names into poise::Command struct from generated macro #194

Closed tazz4843 closed 1 year ago

tazz4843 commented 1 year ago

I'm working on translating all commands in my bot. Given I have several subcommands with the same name, I want a unique way to refer to each one. I personally have guaranteed that each function is named uniquely, and this would be the perfect unique string to use in translations instead of poise::Command::name which doesn't appear to be globally unique across all commands. Let me know if you'd like more of an explanation. Thanks!

kangalio commented 1 year ago

So, Command would gain a new field pub source_code_name: String (name up for debate) which is populated with the name of the Rust function which was annotated with #[poise::command]?

tazz4843 commented 1 year ago

Yeah pretty much

kangalio commented 1 year ago

Sure that can be added

On a side note, have you considered using Command.qualified_name as a globally unique identifier for commands?

tazz4843 commented 1 year ago

That's not populated (at least not uniquely) until after the framework starts isn't it? I do translations before the framework touches anything.

kangalio commented 1 year ago

That is true. You can manually call set_qualified_names, though

Still, source_code_name makes sense to add

kangalio commented 1 year ago

There's also Command.identifying_name (A string to identify this particular command within a list of commands.). What do you think of that @tazz4843 ?

tazz4843 commented 1 year ago

I... completely missed that. That works fine for me, but if you want to continue implementing this you can leave this issue open.