parent
f11fdb4dde
commit
8760f4440a
7 changed files with 43 additions and 219 deletions
61
src/lib.rs
61
src/lib.rs
|
@ -126,41 +126,40 @@ pub struct ServerMembersWolves {
|
|||
pub id_wolves: String,
|
||||
pub expiry: String,
|
||||
pub email: String,
|
||||
pub discord: Option<String>,
|
||||
pub discord: Option<UserId>,
|
||||
pub minecraft: Option<String>,
|
||||
}
|
||||
impl<'r> FromRow<'r, SqliteRow> for ServerMembersWolves {
|
||||
fn from_row(row: &'r SqliteRow) -> Result<Self, Error> {
|
||||
let server_tmp: i64 = row.try_get("server")?;
|
||||
let server = GuildId::from(server_tmp as u64);
|
||||
|
||||
let discord = match row.try_get("discord") {
|
||||
Ok(x) => {
|
||||
let tmp: i64 = x;
|
||||
Some(UserId::from(tmp as u64))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
server,
|
||||
id_wolves: row.try_get("id_wolves")?,
|
||||
expiry: row.try_get("expiry")?,
|
||||
email: row.try_get("email")?,
|
||||
discord: row.try_get("discord")?,
|
||||
discord,
|
||||
minecraft: row.try_get("minecraft")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, sqlx::FromRow)]
|
||||
pub struct Wolves {
|
||||
pub id_wolves: String,
|
||||
pub email: String,
|
||||
pub discord: Option<String>,
|
||||
pub minecraft: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Wolves2 {
|
||||
pub struct Wolves {
|
||||
pub id_wolves: String,
|
||||
pub email: String,
|
||||
pub discord: Option<UserId>,
|
||||
pub minecraft: Option<String>,
|
||||
}
|
||||
impl<'r> FromRow<'r, SqliteRow> for Wolves2 {
|
||||
impl<'r> FromRow<'r, SqliteRow> for Wolves {
|
||||
fn from_row(row: &'r SqliteRow) -> Result<Self, Error> {
|
||||
let discord = match row.try_get("discord") {
|
||||
Ok(x) => {
|
||||
|
@ -179,13 +178,26 @@ impl<'r> FromRow<'r, SqliteRow> for Wolves2 {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, sqlx::FromRow)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct WolvesVerify {
|
||||
pub email: String,
|
||||
pub discord: String,
|
||||
pub discord: UserId,
|
||||
pub auth_code: String,
|
||||
pub date_expiry: String,
|
||||
}
|
||||
impl<'r> FromRow<'r, SqliteRow> for WolvesVerify {
|
||||
fn from_row(row: &'r SqliteRow) -> Result<Self, Error> {
|
||||
let user_tmp: i64 = row.try_get("discord")?;
|
||||
let discord = UserId::from(user_tmp as u64);
|
||||
|
||||
Ok(Self {
|
||||
email: row.try_get("email")?,
|
||||
discord,
|
||||
auth_code: row.try_get("auth_code")?,
|
||||
date_expiry: row.try_get("date_expiry")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Servers {
|
||||
|
@ -240,17 +252,6 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS wolves (
|
||||
id_wolves text PRIMARY KEY,
|
||||
email text not null,
|
||||
discord text,
|
||||
minecraft text
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS wolves2 (
|
||||
id_wolves text PRIMARY KEY,
|
||||
email text not null,
|
||||
discord integer,
|
||||
|
@ -264,10 +265,10 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
|||
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS wolves_verify (
|
||||
discord text PRIMARY KEY,
|
||||
email text not null,
|
||||
auth_code text not null,
|
||||
date_expiry text not null
|
||||
discord integer PRIMARY KEY,
|
||||
email text not null,
|
||||
auth_code text not null,
|
||||
date_expiry text not null
|
||||
)",
|
||||
)
|
||||
.execute(&pool)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue