feat: now store the roles and channel ids in teh database

This commit is contained in:
silver 2025-02-27 01:19:40 +00:00
parent 6a5f651ba2
commit 555e38ee26
Signed by untrusted user: silver
GPG key ID: 36F93D61BAD3FD7D
3 changed files with 209 additions and 83 deletions

View file

@ -190,14 +190,28 @@ impl<'r> FromRow<'r, SqliteRow> for RoleAdder {
}
}
fn get_role_from_row(row: &SqliteRow, col: &str) -> RoleId {
match row.try_get(col) {
pub(crate) fn get_role_from_row(row: &SqliteRow, col: &str) -> RoleId {
let id = match row.try_get(col) {
Ok(x) => {
let tmp: i64 = x;
RoleId::new(tmp as u64)
tmp as u64
}
_ => RoleId::from(0u64),
}
_ => 0,
};
RoleId::from(id)
}
pub(crate) fn get_channel_from_row(row: &SqliteRow, col: &str) -> ChannelId {
let id = match row.try_get(col) {
Ok(x) => {
let tmp: i64 = x;
tmp as u64
}
_ => 0,
};
ChannelId::from(id)
}
pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {