From eb41fede91d072693b279f908976d2ebc2ba1ca3 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Sun, 16 Jan 2022 00:02:56 -0500 Subject: format --- src/commands/pony.rs | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src/commands/pony.rs') diff --git a/src/commands/pony.rs b/src/commands/pony.rs index 75b4238..b908ca4 100644 --- a/src/commands/pony.rs +++ b/src/commands/pony.rs @@ -39,8 +39,10 @@ pub struct PonyRepresentation { /// Retrieves a random SFW pony image #[poise::command(slash_command, prefix_command)] pub async fn randpony(ctx: Context<'_>) -> Result<(), Error> { - let mut response_msg = ctx.say("Fetching a random pony image, please wait!").await?; - + let mut response_msg = ctx + .say("Fetching a random pony image, please wait!") + .await?; + let client = reqwest::Client::new(); let res = reqwest::get("https://theponyapi.com/api/v1/pony/random") .await? @@ -65,11 +67,12 @@ pub async fn randpony(ctx: Context<'_>) -> Result<(), Error> { e }); m - }).await?; - }, + }) + .await?; + } Err(e) => { ctx.say("Error editing message").await?; - }, + } }; Ok(()) @@ -82,18 +85,25 @@ pub async fn randpony(ctx: Context<'_>) -> Result<(), Error> { /// Example: /// ~tpony twilight sparkle,fluttershy #[poise::command(slash_command, prefix_command)] -pub async fn tpony(ctx: Context<'_>, - #[description = "List of tags"] - #[rest] - tags: String, - ) -> Result<(), Error> { - let mut response_msg = ctx.say(format!("Fetching pony image based on tags: {:?}", tags.clone())).await?; - - let res = reqwest::get(format!("https://theponyapi.com/api/v1/pony/random?q={}", tags).as_str()) - .await? - .json::() +pub async fn tpony( + ctx: Context<'_>, + #[description = "List of tags"] + #[rest] + tags: String, +) -> Result<(), Error> { + let mut response_msg = ctx + .say(format!( + "Fetching pony image based on tags: {:?}", + tags.clone() + )) .await?; + let res = + reqwest::get(format!("https://theponyapi.com/api/v1/pony/random?q={}", tags).as_str()) + .await? + .json::() + .await?; + match response_msg.unwrap().message().await { Ok(mut msg) => { msg.edit(&ctx.discord(), |m| { @@ -112,14 +122,14 @@ pub async fn tpony(ctx: Context<'_>, e }); m - }).await?; - }, + }) + .await?; + } Err(e) => { ctx.say("Error editing message").await?; - }, + } }; - Ok(()) } -- cgit v1.2.3