Skip to content

Commit

Permalink
Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Apr 23, 2024
1 parent 452e1be commit 34d305f
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions src/commands/game_support.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
use log::info;
use reqwest::StatusCode;
use crate::{Context, Error};

#[poise::command(prefix_command, slash_command, aliases("gs"))]
pub async fn game_support(ctx: Context<'_>,
#[description = "Game Name"] game_name: Option<String>) -> Result<(), Error> {
// String containing default response
let mut message = String::from("https://docs.getwhisky.app/game-support/");
let mut message = String::from("https://whisky-app.github.io/whisky-book/game-support/");

match game_name {
Some(name) => {
message.push_str(&name);
let esc_name = name.trim().replace(" ", "-").to_lowercase();
message.push_str(&esc_name);

// TODO: Shuttle blocks us from making requests
// let resp = reqwest::get(site.clone()).await?;
//
// info!("{} returned code {}", site, resp.status());
//
// if resp.status() == StatusCode::OK {
//
// } else {
// ctx.reply("Hmm, seems that game isn't in our docs.").await?;
// }
let resp = reqwest::get(message.clone()).await?;

match resp.status() {
StatusCode::OK => {
ctx.reply(message).await?;
},
StatusCode::NOT_FOUND => {
ctx.reply("Hmm, seems that game isn't in our docs.").await?;
},
code => {
ctx.reply(format!("Hmm, seems I'm having trouble connecting to docs. ({code})"), ).await?;
}
}
},
None => {}
}

if let Context::Prefix(prefix) = ctx {
match prefix.msg.clone().referenced_message {
Some(parent) => {
parent.reply(&ctx, message).await?;
prefix.msg.delete(ctx).await?;
},
None => {
ctx.reply(message).await?;
}
}
} else {
ctx.reply(message).await?;
}
// if let Context::Prefix(prefix) = ctx {
// match prefix.msg.clone().referenced_message {
// Some(parent) => {
// parent.reply(&ctx, message).await?;
// prefix.msg.delete(ctx).await?;
// },
// None => {
// ctx.reply(message).await?;
// }
// }
// } else {
// ctx.reply(message).await?;
// }

Ok(())
}

0 comments on commit 34d305f

Please sign in to comment.