fmt: fmt and clippy
This commit is contained in:
parent
5c2502f726
commit
50d2923425
3 changed files with 29 additions and 26 deletions
|
@ -16,11 +16,10 @@ use serenity::{
|
||||||
use skynet_discord_bot::{random_string, Config, DataBase};
|
use skynet_discord_bot::{random_string, Config, DataBase};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
|
|
||||||
pub mod link {
|
pub mod link {
|
||||||
|
use super::*;
|
||||||
use serenity::model::id::GuildId;
|
use serenity::model::id::GuildId;
|
||||||
use skynet_discord_bot::Committee;
|
use skynet_discord_bot::Committee;
|
||||||
use super::*;
|
|
||||||
|
|
||||||
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
||||||
let committee_server = GuildId(1220150752656363520);
|
let committee_server = GuildId(1220150752656363520);
|
||||||
|
@ -35,15 +34,14 @@ pub mod link {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let option = command
|
let option = command
|
||||||
.data
|
.data
|
||||||
.options
|
.options
|
||||||
.first()
|
.first()
|
||||||
.expect("Expected email option")
|
.expect("Expected email option")
|
||||||
.resolved
|
.resolved
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Expected email object");
|
.expect("Expected email object");
|
||||||
|
|
||||||
let email = if let CommandDataOptionValue::String(email) = option {
|
let email = if let CommandDataOptionValue::String(email) = option {
|
||||||
email.trim()
|
email.trim()
|
||||||
|
@ -56,7 +54,6 @@ pub mod link {
|
||||||
return "Please use a @ulwolves.ie address you have access to.".to_string();
|
return "Please use a @ulwolves.ie address you have access to.".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let db_lock = {
|
let db_lock = {
|
||||||
let data_read = ctx.data.read().await;
|
let data_read = ctx.data.read().await;
|
||||||
data_read.get::<DataBase>().expect("Expected Databse in TypeMap.").clone()
|
data_read.get::<DataBase>().expect("Expected Databse in TypeMap.").clone()
|
||||||
|
@ -77,7 +74,6 @@ pub mod link {
|
||||||
return "Linking already in process, please check email.".to_string();
|
return "Linking already in process, please check email.".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// generate a auth key
|
// generate a auth key
|
||||||
let auth = random_string(20);
|
let auth = random_string(20);
|
||||||
match send_mail(&config, email, &auth, &command.user.name) {
|
match send_mail(&config, email, &auth, &command.user.name) {
|
||||||
|
@ -99,7 +95,13 @@ pub mod link {
|
||||||
command
|
command
|
||||||
.name("link_committee")
|
.name("link_committee")
|
||||||
.description("Verify you are a committee member")
|
.description("Verify you are a committee member")
|
||||||
.create_option(|option| option.name("email").description("UL Wolves Committee Email").kind(CommandOptionType::String).required(true))
|
.create_option(|option| {
|
||||||
|
option
|
||||||
|
.name("email")
|
||||||
|
.description("UL Wolves Committee Email")
|
||||||
|
.kind(CommandOptionType::String)
|
||||||
|
.required(true)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_server_member_discord(db: &Pool<Sqlite>, user: &UserId) -> Option<Committee> {
|
pub async fn get_server_member_discord(db: &Pool<Sqlite>, user: &UserId) -> Option<Committee> {
|
||||||
|
@ -206,11 +208,11 @@ pub mod link {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod verify {
|
pub mod verify {
|
||||||
use serenity::model::id::{GuildId, RoleId};
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::commands::committee::link::{get_verify_from_db};
|
use crate::commands::committee::link::get_verify_from_db;
|
||||||
|
use serenity::model::id::{GuildId, RoleId};
|
||||||
use serenity::model::user::User;
|
use serenity::model::user::User;
|
||||||
use skynet_discord_bot::{Committee};
|
use skynet_discord_bot::Committee;
|
||||||
use sqlx::Error;
|
use sqlx::Error;
|
||||||
|
|
||||||
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
||||||
|
@ -272,13 +274,16 @@ pub mod verify {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
|
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
|
||||||
command.name("verify_committee").description("Verify Wolves Committee Email").create_option(|option| {
|
command
|
||||||
option
|
.name("verify_committee")
|
||||||
.name("code")
|
.description("Verify Wolves Committee Email")
|
||||||
.description("Code from verification email")
|
.create_option(|option| {
|
||||||
.kind(CommandOptionType::String)
|
option
|
||||||
.required(true)
|
.name("code")
|
||||||
})
|
.description("Code from verification email")
|
||||||
|
.kind(CommandOptionType::String)
|
||||||
|
.required(true)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_discord(db: &Pool<Sqlite>, discord: &UserId) -> Result<Option<Committee>, Error> {
|
async fn set_discord(db: &Pool<Sqlite>, discord: &UserId) -> Result<Option<Committee>, Error> {
|
||||||
|
@ -303,5 +308,4 @@ pub mod verify {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub mod add_server;
|
pub mod add_server;
|
||||||
|
pub mod committee;
|
||||||
pub mod link_email;
|
pub mod link_email;
|
||||||
pub mod minecraft;
|
pub mod minecraft;
|
||||||
pub mod committee;
|
|
||||||
|
|
|
@ -218,7 +218,6 @@ impl<'r> FromRow<'r, SqliteRow> for WolvesVerify {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct Committee {
|
pub struct Committee {
|
||||||
pub email: String,
|
pub email: String,
|
||||||
|
|
Loading…
Reference in a new issue