poise
poise copied to clipboard
Support Result as parameter type
question
I'm curious about how does the the auto converter in commands arguments work, for example:
#[poise::command(prefix_command,)]
pub async fn delmsg(
ctx: Context<'_>,
#[description = "Message to be deleted"] message: Option<Message>,
) -> Result<(), Error> {...}
message: Option<Message>
is really impressive that can deal with both Message ID and Message Link,
but I didn't find such methods in the doc
feature request
It start from a issue of the converter mentioned above, when the bot receive some unconvertable input (like inaccessible or invalid Message ID),
It will directly call ctx.say
to handle the error, which came from
poise::SlashArgError::Parse { error, input } => {
poise::FrameworkError::ArgumentParse {
ctx: ctx.into(),
error,
input: Some(input),
}
}
, I tried to look into the source but I'm not good enough to understand them
So I wonder, like we can wrap type in Option
to make it optional, is it possible to add such feature that wrap with Result
so we can handle the potential convert error in command?