diff --git a/Cargo.lock b/Cargo.lock index 31e5975..222bc97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "RustBot" -version = "0.5.1" +version = "0.5.2" dependencies = [ "chrono", "poise", diff --git a/Cargo.toml b/Cargo.toml index d08b5dc..11ecb8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "RustBot" -version = "0.5.1" +version = "0.5.2" authors = ["Tim Hillier tim.r.hillier@gmail.com"] edition = "2024" diff --git a/src/commands/runescape.rs b/src/commands/runescape.rs index 4833218..a38c5a6 100644 --- a/src/commands/runescape.rs +++ b/src/commands/runescape.rs @@ -65,9 +65,20 @@ pub async fn grand_exchange_history( ctx: Context<'_>, #[description = "The name of the item you want to look up"] #[rest] - item: String, // make this optional so that if they just do !hs then it just does the last item. + mut item: String, // make this optional so that if they just do !hs then it just does the last item. ) -> Result<(), Error> { let time_length = 10; + let database = connect_to_database().await; + let alias = sqlx::query!("SELECT item FROM ge_aliases WHERE alias = ?", item) + .fetch_optional(&database) + .await?; + + if let Some(alias) = alias + && alias.item.is_some() + { + item = alias.item.unwrap(); + } + let response = RSClient::new().item_name(item).get_price_history().await?; let item_name_formatted = response .item