aboutsummaryrefslogtreecommitdiff
path: root/src/commands/pony.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/pony.rs')
-rw-r--r--src/commands/pony.rs48
1 files changed, 29 insertions, 19 deletions
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::<PonyResponse>()
+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::<PonyResponse>()
+ .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(())
}