fix: was still using the username in some palces instead of ID

This commit is contained in:
silver 2023-09-28 18:25:03 +01:00
parent 70690f712e
commit 058fe2538a

View file

@ -38,7 +38,7 @@ pub(crate) mod link {
db_pending_clear_expired(&db).await; db_pending_clear_expired(&db).await;
if get_verify_from_db(&db, &command.user.name).await.is_some() { if get_verify_from_db(&db, &command.user.id).await.is_some() {
return "Linking already in process, please check email.".to_string(); return "Linking already in process, please check email.".to_string();
} }
@ -205,7 +205,7 @@ pub(crate) mod link {
.ok() .ok()
} }
pub async fn get_verify_from_db(db: &Pool<Sqlite>, user: &str) -> Option<WolvesVerify> { pub async fn get_verify_from_db(db: &Pool<Sqlite>, user: &UserId) -> Option<WolvesVerify> {
sqlx::query_as::<_, WolvesVerify>( sqlx::query_as::<_, WolvesVerify>(
r#" r#"
SELECT * SELECT *
@ -213,7 +213,7 @@ pub(crate) mod link {
WHERE discord = ? WHERE discord = ?
"#, "#,
) )
.bind(user) .bind(*user.as_u64() as i64)
.fetch_one(db) .fetch_one(db)
.await .await
.ok() .ok()
@ -250,7 +250,7 @@ pub(crate) mod verify {
let db = db_lock.read().await; let db = db_lock.read().await;
// check if user has used /link // check if user has used /link
let details = if let Some(x) = get_verify_from_db(&db, &command.user.name).await { let details = if let Some(x) = get_verify_from_db(&db, &command.user.id).await {
x x
} else { } else {
return "Please use /link first".to_string(); return "Please use /link first".to_string();