feat: made database changes to handle the extra server data

This commit is contained in:
silver 2024-09-17 20:55:23 +01:00
parent 5f4e46bb51
commit d3a975a1d1
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
2 changed files with 17 additions and 1 deletions

View file

@ -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;

View file

@ -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<RoleId>,
// TODO: this should not be option
pub role_current: Option<RoleId>,
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<Self, Error> {
@ -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")?,
})
}
}