feat: completed migration

Closes #4
This commit is contained in:
silver 2023-09-26 00:57:03 +01:00
parent f11fdb4dde
commit 8760f4440a
7 changed files with 43 additions and 219 deletions

View file

@ -6,7 +6,7 @@ use serenity::{
prelude::{command::CommandOptionType, interaction::application_command::CommandDataOptionValue},
},
};
use skynet_discord_bot::{DataBase, Servers, Wolves};
use skynet_discord_bot::{DataBase, Servers};
use sqlx::{Error, Pool, Sqlite};
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
@ -130,11 +130,11 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
})
}
async fn add_server(db: &Pool<Sqlite>, server: &Servers) -> Result<Option<Wolves>, Error> {
async fn add_server(db: &Pool<Sqlite>, server: &Servers) -> Result<Option<Servers>, Error> {
let role_past = server.role_past.map(|x| *x.as_u64() as i64);
let role_current = server.role_current.map(|x| *x.as_u64() as i64);
sqlx::query_as::<_, Wolves>(
sqlx::query_as::<_, Servers>(
"
INSERT OR REPLACE INTO servers (server, wolves_api, role_past, role_current)
VALUES (?1, ?2, ?3, ?4)