diff --git a/.gitignore b/.gitignore index 5c11875..dff0a92 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ /data/rustbot.sqlite .env .idea/ -.sqlx/ *.DS_Store diff --git a/.sqlx/query-02b02936f05a565c8a1d4b80a78c6710c6788957f157695f810dc430244e24e7.json b/.sqlx/query-02b02936f05a565c8a1d4b80a78c6710c6788957f157695f810dc430244e24e7.json new file mode 100644 index 0000000..83badf1 --- /dev/null +++ b/.sqlx/query-02b02936f05a565c8a1d4b80a78c6710c6788957f157695f810dc430244e24e7.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT plus_two_received FROM user WHERE user_id = ?", + "describe": { + "columns": [ + { + "name": "plus_two_received", + "ordinal": 0, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "02b02936f05a565c8a1d4b80a78c6710c6788957f157695f810dc430244e24e7" +} diff --git a/.sqlx/query-16453996a2ad833268f570dbac5099e80faed1b48e3113dfcaf82d09caa0b087.json b/.sqlx/query-16453996a2ad833268f570dbac5099e80faed1b48e3113dfcaf82d09caa0b087.json new file mode 100644 index 0000000..6b989f6 --- /dev/null +++ b/.sqlx/query-16453996a2ad833268f570dbac5099e80faed1b48e3113dfcaf82d09caa0b087.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET plus_two_given = plus_two_given + ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "16453996a2ad833268f570dbac5099e80faed1b48e3113dfcaf82d09caa0b087" +} diff --git a/.sqlx/query-2df39cb715d42b26606fbe7bf29c9a0624a6fd2038e3477e69991962ae0e7464.json b/.sqlx/query-2df39cb715d42b26606fbe7bf29c9a0624a6fd2038e3477e69991962ae0e7464.json new file mode 100644 index 0000000..48b5b3b --- /dev/null +++ b/.sqlx/query-2df39cb715d42b26606fbe7bf29c9a0624a6fd2038e3477e69991962ae0e7464.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET plus_two_received = plus_two_received + ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "2df39cb715d42b26606fbe7bf29c9a0624a6fd2038e3477e69991962ae0e7464" +} diff --git a/.sqlx/query-349cd739d9c30acfe61655686eef327f448d8abac8a5b5e2c218f01951cda2f1.json b/.sqlx/query-349cd739d9c30acfe61655686eef327f448d8abac8a5b5e2c218f01951cda2f1.json new file mode 100644 index 0000000..b8fd791 --- /dev/null +++ b/.sqlx/query-349cd739d9c30acfe61655686eef327f448d8abac8a5b5e2c218f01951cda2f1.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT score FROM user WHERE user_id = ?", + "describe": { + "columns": [ + { + "name": "score", + "ordinal": 0, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "349cd739d9c30acfe61655686eef327f448d8abac8a5b5e2c218f01951cda2f1" +} diff --git a/.sqlx/query-3e165b438e3a126b5ccad1d38c5baf1ef7b1a72d677d3eb9a83eb97ff35e23fb.json b/.sqlx/query-3e165b438e3a126b5ccad1d38c5baf1ef7b1a72d677d3eb9a83eb97ff35e23fb.json new file mode 100644 index 0000000..179fe25 --- /dev/null +++ b/.sqlx/query-3e165b438e3a126b5ccad1d38c5baf1ef7b1a72d677d3eb9a83eb97ff35e23fb.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE shop_items SET current_amount = 1 WHERE short_name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "3e165b438e3a126b5ccad1d38c5baf1ef7b1a72d677d3eb9a83eb97ff35e23fb" +} diff --git a/.sqlx/query-3fd2196627f453f139864a0812bbcd41cac7397e280e305c9f303dc02592209d.json b/.sqlx/query-3fd2196627f453f139864a0812bbcd41cac7397e280e305c9f303dc02592209d.json new file mode 100644 index 0000000..1e6e94d --- /dev/null +++ b/.sqlx/query-3fd2196627f453f139864a0812bbcd41cac7397e280e305c9f303dc02592209d.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT OR IGNORE INTO ge_aliases (alias, item) VALUES (?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "3fd2196627f453f139864a0812bbcd41cac7397e280e305c9f303dc02592209d" +} diff --git a/.sqlx/query-449ae091833791eb191457979a995d3ed6b558d9f8b80b31b303ad5721e9b064.json b/.sqlx/query-449ae091833791eb191457979a995d3ed6b558d9f8b80b31b303ad5721e9b064.json new file mode 100644 index 0000000..c80b51e --- /dev/null +++ b/.sqlx/query-449ae091833791eb191457979a995d3ed6b558d9f8b80b31b303ad5721e9b064.json @@ -0,0 +1,26 @@ +{ + "db_name": "SQLite", + "query": "SELECT user_name, score FROM user WHERE user_id = ?", + "describe": { + "columns": [ + { + "name": "user_name", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "score", + "ordinal": 1, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + true + ] + }, + "hash": "449ae091833791eb191457979a995d3ed6b558d9f8b80b31b303ad5721e9b064" +} diff --git a/.sqlx/query-6ad5b89803138cf4cdb784b4194317dad8dda521b983d202a2e7a464eb8a9026.json b/.sqlx/query-6ad5b89803138cf4cdb784b4194317dad8dda521b983d202a2e7a464eb8a9026.json new file mode 100644 index 0000000..2aec3e2 --- /dev/null +++ b/.sqlx/query-6ad5b89803138cf4cdb784b4194317dad8dda521b983d202a2e7a464eb8a9026.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET score = score + ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "6ad5b89803138cf4cdb784b4194317dad8dda521b983d202a2e7a464eb8a9026" +} diff --git a/.sqlx/query-878f8620bcaf06b35c928a945806702779dea42630b8cb4c7c6157eda6e923f0.json b/.sqlx/query-878f8620bcaf06b35c928a945806702779dea42630b8cb4c7c6157eda6e923f0.json new file mode 100644 index 0000000..2daac6a --- /dev/null +++ b/.sqlx/query-878f8620bcaf06b35c928a945806702779dea42630b8cb4c7c6157eda6e923f0.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT message_id FROM judgedPosts WHERE message_id = ?", + "describe": { + "columns": [ + { + "name": "message_id", + "ordinal": 0, + "type_info": "Text" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "878f8620bcaf06b35c928a945806702779dea42630b8cb4c7c6157eda6e923f0" +} diff --git a/.sqlx/query-8cbe619e073b5508f84fe654befeac87f24fe90d0c94f3add045a583c28d686c.json b/.sqlx/query-8cbe619e073b5508f84fe654befeac87f24fe90d0c94f3add045a583c28d686c.json new file mode 100644 index 0000000..f3f5551 --- /dev/null +++ b/.sqlx/query-8cbe619e073b5508f84fe654befeac87f24fe90d0c94f3add045a583c28d686c.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE shop_items SET current_amount = current_amount + ?, total_amount = total_amount + ? WHERE short_name = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "8cbe619e073b5508f84fe654befeac87f24fe90d0c94f3add045a583c28d686c" +} diff --git a/.sqlx/query-8f40f154b38e03810d1b97382a32e568693445d1b74a3120b50a9f5bb94d6be4.json b/.sqlx/query-8f40f154b38e03810d1b97382a32e568693445d1b74a3120b50a9f5bb94d6be4.json new file mode 100644 index 0000000..026899c --- /dev/null +++ b/.sqlx/query-8f40f154b38e03810d1b97382a32e568693445d1b74a3120b50a9f5bb94d6be4.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET minus_two_received = minus_two_received + ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "8f40f154b38e03810d1b97382a32e568693445d1b74a3120b50a9f5bb94d6be4" +} diff --git a/.sqlx/query-91901703f281c3a55502396f47aa240b592d58e9e4eb0448e0f4367e68672066.json b/.sqlx/query-91901703f281c3a55502396f47aa240b592d58e9e4eb0448e0f4367e68672066.json new file mode 100644 index 0000000..3adb0d3 --- /dev/null +++ b/.sqlx/query-91901703f281c3a55502396f47aa240b592d58e9e4eb0448e0f4367e68672066.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET minus_two_given = minus_two_given + ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "91901703f281c3a55502396f47aa240b592d58e9e4eb0448e0f4367e68672066" +} diff --git a/.sqlx/query-94039289bc9ee8e3604f1a70db1a1aa151803cb3d2cedf65478d9347453a2e9e.json b/.sqlx/query-94039289bc9ee8e3604f1a70db1a1aa151803cb3d2cedf65478d9347453a2e9e.json new file mode 100644 index 0000000..0823c2f --- /dev/null +++ b/.sqlx/query-94039289bc9ee8e3604f1a70db1a1aa151803cb3d2cedf65478d9347453a2e9e.json @@ -0,0 +1,26 @@ +{ + "db_name": "SQLite", + "query": "SELECT user_name, score FROM user ORDER BY score DESC LIMIT ?", + "describe": { + "columns": [ + { + "name": "user_name", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "score", + "ordinal": 1, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + true + ] + }, + "hash": "94039289bc9ee8e3604f1a70db1a1aa151803cb3d2cedf65478d9347453a2e9e" +} diff --git a/.sqlx/query-a78c4321860d633e59e99a39d77b14d7a42fc2fd2571aaea4c3042883cb80d67.json b/.sqlx/query-a78c4321860d633e59e99a39d77b14d7a42fc2fd2571aaea4c3042883cb80d67.json new file mode 100644 index 0000000..4562e0b --- /dev/null +++ b/.sqlx/query-a78c4321860d633e59e99a39d77b14d7a42fc2fd2571aaea4c3042883cb80d67.json @@ -0,0 +1,56 @@ +{ + "db_name": "SQLite", + "query": "SELECT * FROM shop_items WHERE short_name = ?", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Integer" + }, + { + "name": "item_name", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "short_name", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "price", + "ordinal": 3, + "type_info": "Integer" + }, + { + "name": "description", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "current_amount", + "ordinal": 5, + "type_info": "Integer" + }, + { + "name": "total_amount", + "ordinal": 6, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false + ] + }, + "hash": "a78c4321860d633e59e99a39d77b14d7a42fc2fd2571aaea4c3042883cb80d67" +} diff --git a/.sqlx/query-b535aac4d65b3c0165f940bd9ee193c9a3f9de441bdf5c0ff7de17479431a780.json b/.sqlx/query-b535aac4d65b3c0165f940bd9ee193c9a3f9de441bdf5c0ff7de17479431a780.json new file mode 100644 index 0000000..31fdec3 --- /dev/null +++ b/.sqlx/query-b535aac4d65b3c0165f940bd9ee193c9a3f9de441bdf5c0ff7de17479431a780.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE user SET plus_two_received = plus_two_received - ? WHERE user_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "b535aac4d65b3c0165f940bd9ee193c9a3f9de441bdf5c0ff7de17479431a780" +} diff --git a/.sqlx/query-c129e4d8340df5491232bc8943594d3087868da5b783a171ae53fadbe114b289.json b/.sqlx/query-c129e4d8340df5491232bc8943594d3087868da5b783a171ae53fadbe114b289.json new file mode 100644 index 0000000..58c26f7 --- /dev/null +++ b/.sqlx/query-c129e4d8340df5491232bc8943594d3087868da5b783a171ae53fadbe114b289.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT current_amount FROM shop_items WHERE short_name = ?", + "describe": { + "columns": [ + { + "name": "current_amount", + "ordinal": 0, + "type_info": "Integer" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "c129e4d8340df5491232bc8943594d3087868da5b783a171ae53fadbe114b289" +} diff --git a/.sqlx/query-d7e52f310680e3f6147b6d0671ded220c494360ab42c82c54c2292f5074d54a3.json b/.sqlx/query-d7e52f310680e3f6147b6d0671ded220c494360ab42c82c54c2292f5074d54a3.json new file mode 100644 index 0000000..a46f04c --- /dev/null +++ b/.sqlx/query-d7e52f310680e3f6147b6d0671ded220c494360ab42c82c54c2292f5074d54a3.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "SELECT item FROM ge_aliases WHERE alias = ?", + "describe": { + "columns": [ + { + "name": "item", + "ordinal": 0, + "type_info": "Text" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + true + ] + }, + "hash": "d7e52f310680e3f6147b6d0671ded220c494360ab42c82c54c2292f5074d54a3" +} diff --git a/.sqlx/query-dc417686b1a8715ae80f5f3f9461dd876127cbfc6e448b08a808b68115497088.json b/.sqlx/query-dc417686b1a8715ae80f5f3f9461dd876127cbfc6e448b08a808b68115497088.json new file mode 100644 index 0000000..8ca918c --- /dev/null +++ b/.sqlx/query-dc417686b1a8715ae80f5f3f9461dd876127cbfc6e448b08a808b68115497088.json @@ -0,0 +1,38 @@ +{ + "db_name": "SQLite", + "query": "SELECT item_name, price, short_name, description FROM shop_items ORDER BY price DESC", + "describe": { + "columns": [ + { + "name": "item_name", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "price", + "ordinal": 1, + "type_info": "Integer" + }, + { + "name": "short_name", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "description", + "ordinal": 3, + "type_info": "Text" + } + ], + "parameters": { + "Right": 0 + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "dc417686b1a8715ae80f5f3f9461dd876127cbfc6e448b08a808b68115497088" +} diff --git a/.sqlx/query-e0843f92771870ca1425f0b6a8d98362eaf43017a0600a93eb8a7976415a147c.json b/.sqlx/query-e0843f92771870ca1425f0b6a8d98362eaf43017a0600a93eb8a7976415a147c.json new file mode 100644 index 0000000..0e6b33f --- /dev/null +++ b/.sqlx/query-e0843f92771870ca1425f0b6a8d98362eaf43017a0600a93eb8a7976415a147c.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO tradeLogs (message_id, from_user, receiving_user, amount ) VALUES (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "e0843f92771870ca1425f0b6a8d98362eaf43017a0600a93eb8a7976415a147c" +} diff --git a/.sqlx/query-e8a6ad34e1ced01cb1f0bd640b02d6959cd60e2353596710e9cf2d1e4f87190b.json b/.sqlx/query-e8a6ad34e1ced01cb1f0bd640b02d6959cd60e2353596710e9cf2d1e4f87190b.json new file mode 100644 index 0000000..60d9cd8 --- /dev/null +++ b/.sqlx/query-e8a6ad34e1ced01cb1f0bd640b02d6959cd60e2353596710e9cf2d1e4f87190b.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO judgedPosts (message_id, message_owner, command_caller, result) VALUES (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + }, + "hash": "e8a6ad34e1ced01cb1f0bd640b02d6959cd60e2353596710e9cf2d1e4f87190b" +} diff --git a/.sqlx/query-fb0c750fbb1efe3975f022926016d3ab0ac0734fe0e73152c427f0a8b3a8c8db.json b/.sqlx/query-fb0c750fbb1efe3975f022926016d3ab0ac0734fe0e73152c427f0a8b3a8c8db.json new file mode 100644 index 0000000..ffbf064 --- /dev/null +++ b/.sqlx/query-fb0c750fbb1efe3975f022926016d3ab0ac0734fe0e73152c427f0a8b3a8c8db.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT OR IGNORE INTO user (user_id, user_name, score, plus_two_given, plus_two_received, minus_two_given, minus_two_received) VALUES (?, ?, ?, ?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 7 + }, + "nullable": [] + }, + "hash": "fb0c750fbb1efe3975f022926016d3ab0ac0734fe0e73152c427f0a8b3a8c8db" +} diff --git a/README.md b/README.md index 5b356bf..4452f8b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![Build Docker and Deploy](https://github.com/TimHillier/RustBot/actions/workflows/docker-build-push.yml/badge.svg)](https://github.com/TimHillier/RustBot/actions/workflows/docker-build-push.yml) +[![Build](https://github.com/TimHillier/RustBot/actions/workflows/docker-build-push.yml/badge.svg)](https://github.com/TimHillier/RustBot/actions/workflows/docker-build-push.yml) +[![Formating](https://github.com/TimHillier/RustBot/actions/workflows/rust-cs-fmt.yml/badge.svg)](https://github.com/TimHillier/RustBot/actions/workflows/rust-cs-fmt.yml) # RustBot @@ -85,3 +86,8 @@ To skip hooks for a single commit (not recommended): ```bash git commit --no-verify ``` + +### Add and Run Migrations +```bash +cargo sqlx migrate run --database-url sqlite:data/rustbot.sqlite --source data/migrations +``` \ No newline at end of file diff --git a/data/migrations/20251213010623_ge-alias-table.sql b/data/migrations/20251213010623_ge-alias-table.sql new file mode 100644 index 0000000..4c87586 --- /dev/null +++ b/data/migrations/20251213010623_ge-alias-table.sql @@ -0,0 +1,9 @@ +-- Add migration script here + +CREATE TABLE ge_aliases ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + alias TEXT, + item TEXT, + UNIQUE(alias, item) +); + diff --git a/src/commands/ping.rs b/src/commands/admin.rs similarity index 66% rename from src/commands/ping.rs rename to src/commands/admin.rs index 62fffe0..df179ca 100644 --- a/src/commands/ping.rs +++ b/src/commands/admin.rs @@ -15,3 +15,11 @@ pub async fn ping( ctx.send(reply).await?; Ok(()) } + +/// Returns the version of the bot. +#[poise::command(prefix_command, required_permissions = "ADMINISTRATOR")] +pub async fn version(ctx: Context<'_>) -> Result<(), Error> { + let response = format!("The bot is running version {}", env!("CARGO_PKG_VERSION")); + ctx.reply(response).await?; + Ok(()) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index a0da376..7248421 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,6 +1,6 @@ +pub mod admin; pub mod help; pub mod judge; -pub mod ping; pub mod runescape; pub mod score; pub mod shop; diff --git a/src/commands/runescape.rs b/src/commands/runescape.rs index c80f6f3..370d71a 100644 --- a/src/commands/runescape.rs +++ b/src/commands/runescape.rs @@ -1,4 +1,5 @@ use crate::bot_types::{_Context as Context, Error}; +use crate::bot_utils::connect_to_database; use crate::runescape_utils::rs_client::{RSClient, RSPrice, TimeStampValue}; use chrono::DateTime; use poise::serenity_prelude as serenity; @@ -13,8 +14,19 @@ pub async fn grand_exchange( ctx: Context<'_>, #[description = "The name of the item you want to look up"] #[rest] - item: String, + mut item: String, ) -> Result<(), Error> { + 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().await?; let item_name_formatted = response .item @@ -94,6 +106,61 @@ pub async fn grand_exchange_history( Ok(()) } +#[poise::command(prefix_command, aliases("ge-alias", "gealias", "gea"))] +pub async fn ge_set_alias( + ctx: Context<'_>, + #[description = "The alias you want to set"] alias: String, + #[description = "The item you want to set the alias for"] + #[rest] + item: String, +) -> Result<(), Error> { + let database = connect_to_database().await; + + sqlx::query!( + "INSERT OR IGNORE INTO ge_aliases (alias, item) VALUES (?, ?)", + alias, + item + ) + .execute(&database) + .await + .expect("Couldn't set GE alias."); + + ctx.reply(format!("GE alias `{}` for `{}` set.", alias, item)) + .await?; + + Ok(()) +} + +#[poise::command( + prefix_command, + aliases("ge-lookup-alias", "lookup", "?", "alias", "what") +)] +pub async fn lookup_alias( + ctx: Context<'_>, + #[description = "The alias you want to look up"] alias: String, +) -> Result<(), Error> { + let database = connect_to_database().await; + + let result = sqlx::query!("SELECT item FROM ge_aliases WHERE alias = ?", alias,) + .fetch_optional(&database) + .await + .expect("Couldn't find GE alias."); + + if let Some(result) = result { + ctx.reply(format!( + "GE alias `{}` is `{}`.", + alias, + result.item.unwrap() + )) + .await?; + } else { + ctx.reply(format!("GE alias `{}` not found.", alias)) + .await?; + } + + Ok(()) +} + pub fn generate_chart_data(history: Vec, time_length: u16, item_name: String) -> String { let recent_history: Vec<&RSPrice> = history .iter() diff --git a/src/main.rs b/src/main.rs index 389d07b..9074453 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,9 +5,9 @@ mod emoji; mod runescape_utils; // Commands; +use crate::commands::admin::*; use crate::commands::help::*; use crate::commands::judge::*; -use crate::commands::ping::*; use crate::commands::runescape::*; use crate::commands::score::*; use crate::commands::shop::*; @@ -195,6 +195,7 @@ async fn main() { .options(poise::FrameworkOptions { commands: vec![ ping(), + version(), judge(), score(), top(), @@ -207,6 +208,8 @@ async fn main() { help(), grand_exchange(), grand_exchange_history(), + ge_set_alias(), + lookup_alias(), ], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("!".into()),