clippy fixes
This commit is contained in:
parent
7cce361c73
commit
e2649ce6ed
5 changed files with 53 additions and 48 deletions
46
src/main.rs
46
src/main.rs
|
|
@ -172,7 +172,7 @@ pub async fn roll(ctx: &Context, command: &CommandInteraction) -> anyhow::Result
|
|||
.map(|s| s.parse::<u64>().context("Seed could not be parsed. Make sure it is a 64 bit integer between 0 and 2^64-1."))
|
||||
.transpose()?;
|
||||
|
||||
let expression = parsing::parse(&formula).context("Dice formula could not be parsed.")?;
|
||||
let expression = parsing::parse(formula).context("Dice formula could not be parsed.")?;
|
||||
|
||||
let seed = fixed_seed.unwrap_or_else(|| rand::rng().next_u64());
|
||||
let mut rng = rand_xoshiro::Xoshiro256PlusPlus::seed_from_u64(seed);
|
||||
|
|
@ -255,27 +255,29 @@ pub async fn roll(ctx: &Context, command: &CommandInteraction) -> anyhow::Result
|
|||
Ok(())
|
||||
}
|
||||
|
||||
if let Ok(_) = inner(ctx, command).await {
|
||||
} else if let Err(err) = inner(ctx, command).await {
|
||||
warn!("Error encountered: {err:?}");
|
||||
command
|
||||
.create_response(
|
||||
&ctx.http,
|
||||
CreateInteractionResponse::Message(
|
||||
CreateInteractionResponseMessage::new()
|
||||
.components(vec![CreateComponent::Container(CreateContainer::new(
|
||||
vec![CreateContainerComponent::TextDisplay(
|
||||
CreateTextDisplay::new(err.to_string()),
|
||||
)],
|
||||
))])
|
||||
// flags needs to be called before ephemeral for correct ordering
|
||||
.flags(
|
||||
MessageFlags::IS_COMPONENTS_V2 | MessageFlags::SUPPRESS_NOTIFICATIONS,
|
||||
)
|
||||
.ephemeral(true),
|
||||
),
|
||||
)
|
||||
.await?
|
||||
match inner(ctx, command).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
warn!("Error encountered: {err:?}");
|
||||
command
|
||||
.create_response(
|
||||
&ctx.http,
|
||||
CreateInteractionResponse::Message(
|
||||
CreateInteractionResponseMessage::new()
|
||||
.components(vec![CreateComponent::Container(CreateContainer::new(
|
||||
vec![CreateContainerComponent::TextDisplay(
|
||||
CreateTextDisplay::new(err.to_string()),
|
||||
)],
|
||||
))])
|
||||
// flags needs to be called before ephemeral for correct ordering
|
||||
.flags(
|
||||
MessageFlags::IS_COMPONENTS_V2 | MessageFlags::SUPPRESS_NOTIFICATIONS,
|
||||
)
|
||||
.ephemeral(true),
|
||||
),
|
||||
)
|
||||
.await?
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue