poise
poise copied to clipboard
feature request: converters with poise context
Currently, we can only use serenity::Context in ArgumentConvert, PopArgument and SlashArgument, because all these traits are imported from serenity. But what if we want to make a string-to-command converter? We are unable to use the ctx.framework() method in any way to get the command. The only solution would be to export the commands variable from other file, which is not a good solution.
Now the trait looks like this:
#[async_trait]
pub trait ArgumentConvert: Sized {
type Err;
async fn convert(
ctx: &Context /* <- serenity::client::context::Context, NOT poise::Context<'_, Data, Error> */,
guild_id: Option<GuildId>,
channel_id: Option<ChannelId>,
s: &str,
) -> Result<Self, Self::Err>;
}
How about creating a custom implementation, with Poise context support? It would be very helpful.
I attempted something similar before, I think it could be made to work.
For motivation purposes and curiosity - what would you need a string-to-command converter for?
I attempted something similar before, I think it could be made to work.
For motivation purposes and curiosity - what would you need a string-to-command converter for?
for e.g. custom help command, you can simply pass Command as a parameter. I know you can pass String and then get command by its name/aliases/etc. but this would be simpler.
Yeah, that's the only use I can think of either.
You can see my attempt from two years ago here in this todo card and this commit