From d10bf7ede64fca7dd3b0b6175701414aade11c02 Mon Sep 17 00:00:00 2001 From: jude Date: Wed, 14 Oct 2020 16:08:26 +0100 Subject: [PATCH] insert events on deleting a reminder --- README.md | 2 +- src/commands/reminder_cmds.rs | 13 ++++++++++++- src/models.rs | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e1de61a..0852fbf 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You'll need rustc and cargo for compilation. To run, you'll need Python 3 still Reminder Bot can be built by running `cargo build --release` in the top level directory. ### Setting up Python -Reminder Bot by default looks for a venv within it's working directory to run Python out of. To set up a venv, install `python-venv` and run `python -m venv venv`. Then, run `source venv/bin/activate` to activate the venv, and do `pip install dateparser` to install the required library +Reminder Bot by default looks for a venv within it's working directory to run Python out of. To set up a venv, install `python3-venv` and run `python3 -m venv venv`. Then, run `source venv/bin/activate` to activate the venv, and do `pip install dateparser` to install the required library ### Environment Variables Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory. diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index f673bb0..226ab5c 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -605,7 +605,18 @@ DELETE FROM reminders WHERE FIND_IN_SET(id, ?) .await .unwrap(); - // TODO add deletion events to event list + if let Some(guild_id) = msg.guild_id { + let _ = sqlx::query!( + " +INSERT INTO events (event_name, bulk_count, guild_id, user_id) VALUES ('delete', ?, ?, ?) + ", + count_row.count, + guild_id.as_u64(), + user_data.id + ) + .execute(&pool) + .await; + } let content = user_data.response(&pool, "del/count").await.replacen( "{}", diff --git a/src/models.rs b/src/models.rs index dbf7e78..032d54c 100644 --- a/src/models.rs +++ b/src/models.rs @@ -169,7 +169,7 @@ UPDATE channels SET name = ?, nudge = ?, blacklisted = ?, webhook_id = ?, webhoo } pub struct UserData { - id: u32, + pub id: u32, pub user: u64, pub name: String, pub dm_channel: u32,