mirror of
https://github.com/supleed2/nanobot.git
synced 2024-12-22 22:25:51 +00:00
Tidy: unnecessary clones, extra commas
This commit is contained in:
parent
c9061e3e34
commit
04d3cead63
|
@ -77,7 +77,7 @@ pub(crate) async fn edit_member_fresher(
|
||||||
id: serenity::Member,
|
id: serenity::Member,
|
||||||
fresher: bool,
|
fresher: bool,
|
||||||
) -> Result<(), Error> {
|
) -> 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? {
|
if db::edit_member_fresher(&ctx.data().db, id.user.id.into(), fresher).await? {
|
||||||
ctx.say(format!("{id} Fresher status updated to {fresher}"))
|
ctx.say(format!("{id} Fresher status updated to {fresher}"))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub(crate) async fn count_manual(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn delete_manual(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
|
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? {
|
if db::delete_manual_by_id(&ctx.data().db, id.user.id.into()).await? {
|
||||||
ctx.say(format!("Successfully deleted manual member info for {id}"))
|
ctx.say(format!("Successfully deleted manual member info for {id}"))
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -18,15 +18,14 @@ pub(crate) async fn count_members(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn delete_member(
|
pub(crate) async fn delete_member(
|
||||||
ctx: ACtx<'_>,
|
ctx: ACtx<'_>,
|
||||||
id: serenity::Member,
|
mut id: serenity::Member,
|
||||||
remove_roles: Option<bool>,
|
remove_roles: Option<bool>,
|
||||||
) -> Result<(), Error> {
|
) -> 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 db::delete_member_by_id(&ctx.data().db, id.user.id.into()).await? {
|
||||||
if remove_roles.unwrap_or(true) {
|
if remove_roles.unwrap_or(true) {
|
||||||
let mut m = id.clone();
|
crate::verify::remove_role(ctx.serenity_context(), &mut id, ctx.data().member).await?;
|
||||||
crate::verify::remove_role(ctx.serenity_context(), &mut m, ctx.data().member).await?;
|
crate::verify::remove_role(ctx.serenity_context(), &mut id, ctx.data().fresher).await?;
|
||||||
crate::verify::remove_role(ctx.serenity_context(), &mut m, ctx.data().fresher).await?;
|
|
||||||
}
|
}
|
||||||
ctx.say(format!("Successfully deleted member info for {id}"))
|
ctx.say(format!("Successfully deleted member info for {id}"))
|
||||||
.await?
|
.await?
|
||||||
|
@ -99,7 +98,7 @@ pub(crate) async fn get_member(_ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
#[poise::command(slash_command, rename = "id")]
|
#[poise::command(slash_command, rename = "id")]
|
||||||
pub(crate) async fn get_member_by_id(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
|
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? {
|
match db::get_member_by_id(&ctx.data().db, id.user.id.into()).await? {
|
||||||
Some(m) => {
|
Some(m) => {
|
||||||
ctx.say(format!("Member info for {id}:\n```rust\n{m:#?}\n```"))
|
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?
|
.await?
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
ctx.say(format!("No entry found for nickname {nickname}",))
|
ctx.say(format!("No entry found for nickname {nickname}"))
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -163,7 +162,7 @@ pub(crate) async fn get_member_by_realname(ctx: ACtx<'_>, realname: String) -> R
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
ctx.say(format!("No entry found for realname {realname}",))
|
ctx.say(format!("No entry found for realname {realname}"))
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -175,7 +174,7 @@ pub(crate) async fn get_member_by_realname(ctx: ACtx<'_>, realname: String) -> R
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn add_member(
|
pub(crate) async fn add_member(
|
||||||
ctx: ACtx<'_>,
|
ctx: ACtx<'_>,
|
||||||
id: serenity::Member,
|
mut id: serenity::Member,
|
||||||
shortcode: String,
|
shortcode: String,
|
||||||
nickname: String,
|
nickname: String,
|
||||||
realname: String,
|
realname: String,
|
||||||
|
@ -197,10 +196,9 @@ pub(crate) async fn add_member(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let mut m = id.clone();
|
crate::verify::apply_role(ctx.serenity_context(), &mut id, ctx.data().member).await?;
|
||||||
crate::verify::apply_role(ctx.serenity_context(), &mut m, ctx.data().member).await?;
|
|
||||||
if fresher {
|
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?;
|
ctx.say(format!("Member added: {id}")).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -215,7 +213,7 @@ pub(crate) async fn insert_member_from_pending(
|
||||||
nickname: String,
|
nickname: String,
|
||||||
fresher: bool,
|
fresher: bool,
|
||||||
) -> Result<(), Error> {
|
) -> 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)
|
match db::insert_member_from_pending(&ctx.data().db, id.user.id.into(), &nickname, fresher)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
@ -235,7 +233,7 @@ pub(crate) async fn insert_member_from_manual(
|
||||||
ctx: ACtx<'_>,
|
ctx: ACtx<'_>,
|
||||||
id: serenity::Member,
|
id: serenity::Member,
|
||||||
) -> Result<(), Error> {
|
) -> 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 {
|
match db::insert_member_from_manual(&ctx.data().db, id.user.id.into()).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
ctx.say(format!("Member moved from manual to members table: {id}"))
|
ctx.say(format!("Member moved from manual to members table: {id}"))
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub(crate) async fn count_pending(ctx: ACtx<'_>) -> Result<(), Error> {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn delete_pending(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
|
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? {
|
if db::delete_pending_by_id(&ctx.data().db, id.user.id.into()).await? {
|
||||||
ctx.say(format!("Successfully deleted pending member info for {id}"))
|
ctx.say(format!("Successfully deleted pending member info for {id}"))
|
||||||
.await?
|
.await?
|
||||||
|
|
Loading…
Reference in a new issue