From d3a975a1d197018dfaf664848601bcdf7d1523bf Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Tue, 17 Sep 2024 20:55:23 +0100 Subject: [PATCH] feat: made database changes to handle the extra server data --- db/migrations/5_welcome-message.sql | 5 +++++ src/lib.rs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrations/5_welcome-message.sql diff --git a/db/migrations/5_welcome-message.sql b/db/migrations/5_welcome-message.sql new file mode 100644 index 0000000..15a139c --- /dev/null +++ b/db/migrations/5_welcome-message.sql @@ -0,0 +1,5 @@ +-- temp table to allow folks to verify by committee email. +-- delete the col in teh server table +ALTER TABLE servers ADD COLUMN bot_channel_id integer DEFAULT 0; +ALTER TABLE servers ADD COLUMN server_name text NOT NULL; +ALTER TABLE servers ADD COLUMN wolves_link text NOT NULL; \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index c0d980a..90529e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use serenity::{ model::{ guild, - id::{GuildId, RoleId}, + id::{GuildId, RoleId, ChannelId}, }, prelude::TypeMapKey, }; @@ -228,9 +228,14 @@ pub struct Servers { pub server: GuildId, pub wolves_api: String, pub role_past: Option, + // TODO: this should not be option pub role_current: Option, pub member_past: i64, pub member_current: i64, + pub bot_channel_id: ChannelId, + // these can be removed in teh future with an API update + pub server_name: String, + pub wolves_link: String, } impl<'r> FromRow<'r, SqliteRow> for Servers { fn from_row(row: &'r SqliteRow) -> Result { @@ -259,6 +264,9 @@ impl<'r> FromRow<'r, SqliteRow> for Servers { _ => None, }; + let bot_channel_tmp: i64 = row.try_get("bot_channel_id")?; + let bot_channel_id = ChannelId::from(bot_channel_tmp as u64); + Ok(Self { server, wolves_api: row.try_get("wolves_api")?, @@ -266,6 +274,9 @@ impl<'r> FromRow<'r, SqliteRow> for Servers { role_current, member_past: row.try_get("member_past")?, member_current: row.try_get("member_current")?, + bot_channel_id, + server_name: row.try_get("server_name")?, + wolves_link: row.try_get("wolves_link")?, }) } }