-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
452e1be
commit 34d305f
Showing
1 changed file
with
29 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |