Tidy: unnecessary clones, extra commas

This commit is contained in:
Aadi Desai 2023-12-06 23:55:15 +00:00
parent c9061e3e34
commit 04d3cead63
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
4 changed files with 15 additions and 17 deletions

View file

@ -77,7 +77,7 @@ pub(crate) async fn edit_member_fresher(
id: serenity::Member,
fresher: bool,
) -> Result<(), Error> {
tracing::info!("{} {} {fresher}", ctx.author().name, id.user.name,);
tracing::info!("{} {} {fresher}", ctx.author().name, id.user.name);
if db::edit_member_fresher(&ctx.data().db, id.user.id.into(), fresher).await? {
ctx.say(format!("{id} Fresher status updated to {fresher}"))
.await?;

View file

@ -17,7 +17,7 @@ pub(crate) async fn count_manual(ctx: ACtx<'_>) -> Result<(), Error> {
#[tracing::instrument(skip_all)]
#[poise::command(slash_command)]
pub(crate) async fn delete_manual(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
if db::delete_manual_by_id(&ctx.data().db, id.user.id.into()).await? {
ctx.say(format!("Successfully deleted manual member info for {id}"))
.await?

View file

@ -18,15 +18,14 @@ pub(crate) async fn count_members(ctx: ACtx<'_>) -> Result<(), Error> {
#[poise::command(slash_command)]
pub(crate) async fn delete_member(
ctx: ACtx<'_>,
id: serenity::Member,
mut id: serenity::Member,
remove_roles: Option<bool>,
) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
if db::delete_member_by_id(&ctx.data().db, id.user.id.into()).await? {
if remove_roles.unwrap_or(true) {
let mut m = id.clone();
crate::verify::remove_role(ctx.serenity_context(), &mut m, ctx.data().member).await?;
crate::verify::remove_role(ctx.serenity_context(), &mut m, ctx.data().fresher).await?;
crate::verify::remove_role(ctx.serenity_context(), &mut id, ctx.data().member).await?;
crate::verify::remove_role(ctx.serenity_context(), &mut id, ctx.data().fresher).await?;
}
ctx.say(format!("Successfully deleted member info for {id}"))
.await?
@ -99,7 +98,7 @@ pub(crate) async fn get_member(_ctx: ACtx<'_>) -> Result<(), Error> {
#[tracing::instrument(skip_all)]
#[poise::command(slash_command, rename = "id")]
pub(crate) async fn get_member_by_id(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
match db::get_member_by_id(&ctx.data().db, id.user.id.into()).await? {
Some(m) => {
ctx.say(format!("Member info for {id}:\n```rust\n{m:#?}\n```"))
@ -143,7 +142,7 @@ pub(crate) async fn get_member_by_nickname(ctx: ACtx<'_>, nickname: String) -> R
.await?
}
None => {
ctx.say(format!("No entry found for nickname {nickname}",))
ctx.say(format!("No entry found for nickname {nickname}"))
.await?
}
};
@ -163,7 +162,7 @@ pub(crate) async fn get_member_by_realname(ctx: ACtx<'_>, realname: String) -> R
.await?
}
None => {
ctx.say(format!("No entry found for realname {realname}",))
ctx.say(format!("No entry found for realname {realname}"))
.await?
}
};
@ -175,7 +174,7 @@ pub(crate) async fn get_member_by_realname(ctx: ACtx<'_>, realname: String) -> R
#[poise::command(slash_command)]
pub(crate) async fn add_member(
ctx: ACtx<'_>,
id: serenity::Member,
mut id: serenity::Member,
shortcode: String,
nickname: String,
realname: String,
@ -197,10 +196,9 @@ pub(crate) async fn add_member(
},
)
.await?;
let mut m = id.clone();
crate::verify::apply_role(ctx.serenity_context(), &mut m, ctx.data().member).await?;
crate::verify::apply_role(ctx.serenity_context(), &mut id, ctx.data().member).await?;
if fresher {
crate::verify::apply_role(ctx.serenity_context(), &mut m, ctx.data().fresher).await?;
crate::verify::apply_role(ctx.serenity_context(), &mut id, ctx.data().fresher).await?;
}
ctx.say(format!("Member added: {id}")).await?;
Ok(())
@ -215,7 +213,7 @@ pub(crate) async fn insert_member_from_pending(
nickname: String,
fresher: bool,
) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
match db::insert_member_from_pending(&ctx.data().db, id.user.id.into(), &nickname, fresher)
.await
{
@ -235,7 +233,7 @@ pub(crate) async fn insert_member_from_manual(
ctx: ACtx<'_>,
id: serenity::Member,
) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
match db::insert_member_from_manual(&ctx.data().db, id.user.id.into()).await {
Ok(_) => {
ctx.say(format!("Member moved from manual to members table: {id}"))

View file

@ -17,7 +17,7 @@ pub(crate) async fn count_pending(ctx: ACtx<'_>) -> Result<(), Error> {
#[tracing::instrument(skip_all)]
#[poise::command(slash_command)]
pub(crate) async fn delete_pending(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,);
tracing::info!("{} {}", ctx.author().name, id.user.name);
if db::delete_pending_by_id(&ctx.data().db, id.user.id.into()).await? {
ctx.say(format!("Successfully deleted pending member info for {id}"))
.await?