Skip to content

Commit d90cc25

Browse files
TimHillierTIm Hillier
andauthored
Can now use aliases for history. (#20)
Co-authored-by: TIm Hillier <thillier@acrocommerce.com>
1 parent 49ef06f commit d90cc25

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "RustBot"
3-
version = "0.5.1"
3+
version = "0.5.2"
44
authors = ["Tim Hillier tim.r.hillier@gmail.com"]
55
edition = "2024"
66

src/commands/runescape.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,20 @@ pub async fn grand_exchange_history(
6565
ctx: Context<'_>,
6666
#[description = "The name of the item you want to look up"]
6767
#[rest]
68-
item: String, // make this optional so that if they just do !hs then it just does the last item.
68+
mut item: String, // make this optional so that if they just do !hs then it just does the last item.
6969
) -> Result<(), Error> {
7070
let time_length = 10;
71+
let database = connect_to_database().await;
72+
let alias = sqlx::query!("SELECT item FROM ge_aliases WHERE alias = ?", item)
73+
.fetch_optional(&database)
74+
.await?;
75+
76+
if let Some(alias) = alias
77+
&& alias.item.is_some()
78+
{
79+
item = alias.item.unwrap();
80+
}
81+
7182
let response = RSClient::new().item_name(item).get_price_history().await?;
7283
let item_name_formatted = response
7384
.item

0 commit comments

Comments
 (0)