forked from Skynet/discord-bot
feat: now store the roles and channel ids in teh database
This commit is contained in:
parent
6a5f651ba2
commit
555e38ee26
3 changed files with 209 additions and 83 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue