Added some better error messages

+ Clippy + fmt
This commit is contained in:
Joey Hines 2023-01-06 18:01:07 -07:00
parent 6693cb4f98
commit e343c97306
Signed by: joeyahines
GPG Key ID: 995E531F7A569DDB
4 changed files with 25 additions and 5 deletions

View File

@ -8,7 +8,6 @@ use serenity::model::channel::Message;
pub struct ADMIN;
#[command]
#[owners_only]
#[only_in(guilds)]
async fn reload(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let mut data = ctx.data.write().await;

View File

@ -345,9 +345,23 @@ async fn bet(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
msg.reply(&ctx.http, "Race not in progress").await?;
}
let racer = args.parse::<EmojiIdentifier>()?;
let racer = match args.parse::<EmojiIdentifier>() {
Ok(emoji) => emoji,
Err(e) => {
msg.reply(&ctx.http, format!("Invalid emoji: {}", e))
.await?;
return Ok(());
}
};
args.advance();
let amount = args.parse::<u32>()?;
let amount = match args.parse::<u32>() {
Ok(amount) => amount,
Err(err) => {
msg.reply(&ctx.http, format!("Invalid bet amount: {}", err))
.await?;
return Ok(());
}
};
let send = race_msg_channel.send.lock().await;

View File

@ -60,7 +60,14 @@ async fn gift(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
args.advance();
let amount = args.parse::<u32>()?;
let amount = match args.parse::<u32>() {
Ok(amount) => amount,
Err(err) => {
msg.reply(&ctx.http, format!("Invalid coin amount: {}", err))
.await?;
return Ok(());
}
};
let mut data = ctx.data.write().await;
let global_data = data.get_mut::<GlobalData>().unwrap();

View File

@ -83,7 +83,7 @@ async fn motivation(ctx: &Context, msg: &Message, _args: Args) -> CommandResult
let mut text_color_wand = PixelWand::new();
text_color_wand.set_color("white")?;
text_wand.set_fill_color(&text_color_wand);
text_wand.set_font_size(0.07*(wand.get_image_width() as f64));
text_wand.set_font_size(0.07 * (wand.get_image_width() as f64));
text_wand.set_text_alignment(magick_rust::bindings::AlignType_CenterAlign);
wand.annotate_image(&text_wand, text_pos_x, text_pos_y, 0.0, &motivation)?;
wand.write_image_blob("png")?