From 2f6d035efe5655166f9e2d71733dd942dac4ffbf Mon Sep 17 00:00:00 2001 From: jude Date: Wed, 14 Feb 2024 19:44:53 +0000 Subject: [PATCH] Rename table references --- src/commands/autocomplete.rs | 11 ++++++----- src/commands/command_macro/delete.rs | 4 ++-- src/commands/command_macro/record.rs | 4 ++-- src/models/command_macro.rs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/commands/autocomplete.rs b/src/commands/autocomplete.rs index 721d781..bfffffe 100644 --- a/src/commands/autocomplete.rs +++ b/src/commands/autocomplete.rs @@ -21,11 +21,12 @@ pub async fn timezone_autocomplete(ctx: Context<'_>, partial: &str) -> Vec, partial: &str) -> Vec { sqlx::query!( " -SELECT name -FROM macro -WHERE - guild_id = (SELECT id FROM guilds WHERE guild = ?) - AND name LIKE CONCAT(?, '%')", + SELECT name + FROM command_macro + WHERE + guild_id = (SELECT id FROM guilds WHERE guild = ?) + AND name LIKE CONCAT(?, '%') + ", ctx.guild_id().unwrap().get(), partial, ) diff --git a/src/commands/command_macro/delete.rs b/src/commands/command_macro/delete.rs index 80c73de..e89029d 100644 --- a/src/commands/command_macro/delete.rs +++ b/src/commands/command_macro/delete.rs @@ -18,7 +18,7 @@ pub async fn delete_macro( match sqlx::query!( " SELECT m.id - FROM macro m + FROM command_macro m INNER JOIN guilds ON guilds.guild = m.guild_id WHERE guild = ? @@ -31,7 +31,7 @@ pub async fn delete_macro( .await { Ok(row) => { - sqlx::query!("DELETE FROM macro WHERE id = ?", row.id) + sqlx::query!("DELETE FROM command_macro WHERE id = ?", row.id) .execute(&ctx.data().database) .await .unwrap(); diff --git a/src/commands/command_macro/record.rs b/src/commands/command_macro/record.rs index a40bb60..22369e4 100644 --- a/src/commands/command_macro/record.rs +++ b/src/commands/command_macro/record.rs @@ -34,7 +34,7 @@ pub async fn record_macro( let row = sqlx::query!( " SELECT 1 as _e - FROM macro + FROM command_macro WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?) AND name = ? ", @@ -131,7 +131,7 @@ pub async fn finish_macro(ctx: Context<'_>) -> Result<(), Error> { let json = serde_json::to_string(&command_macro.commands).unwrap(); sqlx::query!( - "INSERT INTO macro (guild_id, name, description, commands) VALUES ((SELECT id FROM guilds WHERE guild = ?), ?, ?, ?)", + "INSERT INTO command_macro (guild_id, name, description, commands) VALUES ((SELECT id FROM guilds WHERE guild = ?), ?, ?, ?)", command_macro.guild_id.get(), command_macro.name, command_macro.description, diff --git a/src/models/command_macro.rs b/src/models/command_macro.rs index 506bebb..08b0bbb 100644 --- a/src/models/command_macro.rs +++ b/src/models/command_macro.rs @@ -55,7 +55,7 @@ pub async fn guild_command_macro(ctx: &Context<'_>, name: &str) -> Option