aboutsummaryrefslogtreecommitdiff
path: root/src/commands/pony.rs
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-01-16 00:02:56 -0500
committerCara Salter <cara@devcara.com>2022-01-16 00:02:56 -0500
commiteb41fede91d072693b279f908976d2ebc2ba1ca3 (patch)
tree81154fe49330b429e66fff098653fc636747717c /src/commands/pony.rs
parent16921c23ff7186381a16ca0b03c521d56ee4eb21 (diff)
downloadglitch-ng-eb41fede91d072693b279f908976d2ebc2ba1ca3.tar.gz
glitch-ng-eb41fede91d072693b279f908976d2ebc2ba1ca3.zip
format
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(())
}