fmt: fmt and clippy
This commit is contained in:
parent
11240914ac
commit
f3ef03a418
3 changed files with 49 additions and 54 deletions
|
@ -51,30 +51,28 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let bot_channel_id = if let CommandDataOptionValue::Channel(channel) = command
|
let bot_channel_id = if let CommandDataOptionValue::Channel(channel) = command
|
||||||
.data
|
.data
|
||||||
.options
|
.options
|
||||||
.get(3)
|
.get(3)
|
||||||
.expect("Expected channel option")
|
.expect("Expected channel option")
|
||||||
.resolved
|
.resolved
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Expected channel object")
|
.expect("Expected channel object")
|
||||||
{
|
{
|
||||||
channel.id.to_owned()
|
channel.id.to_owned()
|
||||||
} else {
|
} else {
|
||||||
return "Please provide a valid channel for ``Bot Channel``".to_string();
|
return "Please provide a valid channel for ``Bot Channel``".to_string();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let server_name = if let CommandDataOptionValue::String(name) = command
|
let server_name = if let CommandDataOptionValue::String(name) = command
|
||||||
.data
|
.data
|
||||||
.options
|
.options
|
||||||
.get(4)
|
.get(4)
|
||||||
.expect("Expected Server Name option")
|
.expect("Expected Server Name option")
|
||||||
.resolved
|
.resolved
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Expected Server Name object")
|
.expect("Expected Server Name object")
|
||||||
{
|
{
|
||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,13 +80,13 @@ pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> Stri
|
||||||
};
|
};
|
||||||
|
|
||||||
let wolves_link = if let CommandDataOptionValue::String(wolves) = command
|
let wolves_link = if let CommandDataOptionValue::String(wolves) = command
|
||||||
.data
|
.data
|
||||||
.options
|
.options
|
||||||
.get(5)
|
.get(5)
|
||||||
.expect("Expected Wolves Link option")
|
.expect("Expected Wolves Link option")
|
||||||
.resolved
|
.resolved
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Expected Server Name object")
|
.expect("Expected Server Name object")
|
||||||
{
|
{
|
||||||
wolves
|
wolves
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,27 +147,27 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
|
||||||
.kind(CommandOptionType::Role)
|
.kind(CommandOptionType::Role)
|
||||||
.required(false)
|
.required(false)
|
||||||
})
|
})
|
||||||
.create_option(|option| {
|
.create_option(|option| {
|
||||||
option
|
option
|
||||||
.name("bot_channel")
|
.name("bot_channel")
|
||||||
.description("Safe space for folks to use the bot commands.")
|
.description("Safe space for folks to use the bot commands.")
|
||||||
.kind(CommandOptionType::Channel)
|
.kind(CommandOptionType::Channel)
|
||||||
.required(true)
|
.required(true)
|
||||||
})
|
})
|
||||||
.create_option(|option| {
|
.create_option(|option| {
|
||||||
option
|
option
|
||||||
.name("server_name")
|
.name("server_name")
|
||||||
.description("Name of the Discord Server.")
|
.description("Name of the Discord Server.")
|
||||||
.kind(CommandOptionType::String)
|
.kind(CommandOptionType::String)
|
||||||
.required(true)
|
.required(true)
|
||||||
})
|
})
|
||||||
.create_option(|option| {
|
.create_option(|option| {
|
||||||
option
|
option
|
||||||
.name("wolves_link")
|
.name("wolves_link")
|
||||||
.description("Link to the Club/Society on UL Wolves.")
|
.description("Link to the Club/Society on UL Wolves.")
|
||||||
.kind(CommandOptionType::String)
|
.kind(CommandOptionType::String)
|
||||||
.required(true)
|
.required(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Result<Option<Servers>, Error> {
|
async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Result<Option<Servers>, Error> {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use serenity::{
|
use serenity::{
|
||||||
model::{
|
model::{
|
||||||
guild,
|
guild,
|
||||||
id::{GuildId, RoleId, ChannelId},
|
id::{ChannelId, GuildId, RoleId},
|
||||||
},
|
},
|
||||||
prelude::TypeMapKey,
|
prelude::TypeMapKey,
|
||||||
};
|
};
|
||||||
|
@ -255,7 +255,7 @@ impl<'r> FromRow<'r, SqliteRow> for Servers {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
let tmp: i64 = x;
|
let tmp: i64 = x;
|
||||||
RoleId::from(tmp as u64)
|
RoleId::from(tmp as u64)
|
||||||
}
|
}
|
||||||
_ => RoleId::from(0u64),
|
_ => RoleId::from(0u64),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -409,13 +409,11 @@ pub mod set_roles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if !member.roles.contains(role_current) {
|
if !member.roles.contains(role_current) {
|
||||||
roles_set[1] += 1;
|
roles_set[1] += 1;
|
||||||
roles.push(role_current.to_owned());
|
roles.push(role_current.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if let Err(e) = member.add_roles(ctx, &roles).await {
|
if let Err(e) = member.add_roles(ctx, &roles).await {
|
||||||
println!("{:?}", e);
|
println!("{:?}", e);
|
||||||
}
|
}
|
||||||
|
@ -428,7 +426,6 @@ pub mod set_roles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if member.roles.contains(role_current) {
|
if member.roles.contains(role_current) {
|
||||||
roles_set[2] += 1;
|
roles_set[2] += 1;
|
||||||
// if theya re not a current member and have the role then remove it
|
// if theya re not a current member and have the role then remove it
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -55,11 +55,11 @@ impl EventHandler for Handler {
|
||||||
Welcome {} to the {} server!
|
Welcome {} to the {} server!
|
||||||
Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use ``/link_wolves`` to get full access.
|
Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use ``/link_wolves`` to get full access.
|
||||||
"#,
|
"#,
|
||||||
new_member.display_name(),
|
new_member.display_name(),
|
||||||
&config.server_name,
|
&config.server_name,
|
||||||
&config.wolves_link,
|
&config.wolves_link,
|
||||||
&config.server,
|
&config.server,
|
||||||
&config.bot_channel_id
|
&config.bot_channel_id
|
||||||
);
|
);
|
||||||
// let msg = format!(
|
// let msg = format!(
|
||||||
// "Welcome {} to the {} server! \n\
|
// "Welcome {} to the {} server! \n\
|
||||||
|
|
Loading…
Reference in a new issue