Fix cmds.rs printlns to output usernames

This commit is contained in:
Aadi Desai 2023-09-27 14:13:11 +01:00
parent 980dcae811
commit d5039796cc
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM

View file

@ -35,7 +35,7 @@ pub(crate) async fn setup(
text: Option<String>, text: Option<String>,
} }
println!("Cmd: ({}) setup", ctx.author().name); println!("Cmd: ({}) setup {}", ctx.author().name, channel.name());
if let Some(Setup { if let Some(Setup {
message, message,
@ -89,7 +89,11 @@ pub(crate) async fn delete_member(
id: serenity::Member, id: serenity::Member,
remove_roles: Option<bool>, remove_roles: Option<bool>,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!("Cmd: ({}) delete_member {id}", ctx.author().name); println!(
"Cmd: ({}) delete_member {}",
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(); let mut m = id.clone();
@ -164,7 +168,11 @@ pub(crate) async fn get_member(_ctx: ACtx<'_>) -> Result<(), Error> {
/// Get member info by Discord ID /// Get member info by Discord ID
#[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> {
println!("Cmd: ({}) get_member_by_id {id}", ctx.author().name); println!(
"Cmd: ({}) get_member_by_id {}",
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```"))
@ -252,8 +260,9 @@ pub(crate) async fn add_member(
fresher: bool, fresher: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!( println!(
"Cmd: ({}) add_member {id}, {shortcode}, {realname}, {nickname}", "Cmd: ({}) add_member {}, {shortcode}, {realname}, {nickname}",
ctx.author().name, ctx.author().name,
id.user.name,
); );
db::insert_member( db::insert_member(
&ctx.data().db, &ctx.data().db,
@ -284,8 +293,9 @@ pub(crate) async fn insert_member_from_pending(
fresher: bool, fresher: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!( println!(
"Cmd: ({}) insert_member_from_pending {id}", "Cmd: ({}) insert_member_from_pending {}",
ctx.author().name 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
@ -306,8 +316,9 @@ pub(crate) async fn insert_member_from_manual(
id: serenity::Member, id: serenity::Member,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!( println!(
"Cmd: ({}) insert_member_from_manual {id}", "Cmd: ({}) insert_member_from_manual {}",
ctx.author().name 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(()) => {
@ -399,7 +410,11 @@ pub(crate) async fn edit_member_fresher(
id: serenity::Member, id: serenity::Member,
fresher: bool, fresher: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!("Cmd: ({}) edit_member_fresher {fresher}", ctx.author().name); println!(
"Cmd: ({}) edit_member_fresher {} {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?;
@ -437,7 +452,11 @@ pub(crate) async fn count_pending(ctx: ACtx<'_>) -> Result<(), Error> {
/// Delete pending member info by Discord ID /// Delete pending member info by Discord ID
#[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> {
println!("Cmd: ({}) delete_pending {id}", ctx.author().name); println!(
"Cmd: ({}) delete_pending {}",
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?
@ -493,7 +512,7 @@ pub(crate) async fn get_all_pending(ctx: ACtx<'_>) -> Result<(), Error> {
/// Get pending member info by Discord ID /// Get pending member info by Discord ID
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub(crate) async fn get_pending(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> { pub(crate) async fn get_pending(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
println!("Cmd: ({}) get_pending {id}", ctx.author().name); println!("Cmd: ({}) get_pending {}", ctx.author().name, id.user.name);
match db::get_pending_by_id(&ctx.data().db, id.user.id.into()).await? { match db::get_pending_by_id(&ctx.data().db, id.user.id.into()).await? {
Some(p) => { Some(p) => {
ctx.say(format!("Pending info for {id}:\n```rust\n{p:#?}\n```")) ctx.say(format!("Pending info for {id}:\n```rust\n{p:#?}\n```"))
@ -513,8 +532,9 @@ pub(crate) async fn add_pending(
realname: String, realname: String,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!( println!(
"Cmd: ({}) add_pending {id}, {shortcode}, {realname}", "Cmd: ({}) add_pending {}, {shortcode}, {realname}",
ctx.author().name ctx.author().name,
id.user.name,
); );
db::insert_pending( db::insert_pending(
&ctx.data().db, &ctx.data().db,
@ -570,7 +590,11 @@ pub(crate) async fn count_manual(ctx: ACtx<'_>) -> Result<(), Error> {
/// Delete manual member info by Discord ID /// Delete manual member info by Discord ID
#[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> {
println!("Cmd: ({}) delete_manual {id}", ctx.author().name); println!(
"Cmd: ({}) delete_manual {}",
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?
@ -626,7 +650,7 @@ pub(crate) async fn get_all_manual(ctx: ACtx<'_>) -> Result<(), Error> {
/// Get manual member info by Discord ID /// Get manual member info by Discord ID
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub(crate) async fn get_manual(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> { pub(crate) async fn get_manual(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
println!("Cmd: ({}) get_manual {id}", ctx.author().name); println!("Cmd: ({}) get_manual {}", ctx.author().name, id.user.name);
match db::get_manual_by_id(&ctx.data().db, id.user.id.into()).await? { match db::get_manual_by_id(&ctx.data().db, id.user.id.into()).await? {
Some(m) => { Some(m) => {
ctx.say(format!("Manual info for {id}:\n```rust\n{m:#?}\n```")) ctx.say(format!("Manual info for {id}:\n```rust\n{m:#?}\n```"))
@ -648,8 +672,9 @@ pub(crate) async fn add_manual(
fresher: bool, fresher: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
println!( println!(
"Cmd: ({}) add_manual {id}, {shortcode}, {realname}, {nickname}", "Cmd: ({}) add_manual {}, {shortcode}, {realname}, {nickname}",
ctx.author().name ctx.author().name,
id.user.name,
); );
db::insert_manual( db::insert_manual(
&ctx.data().db, &ctx.data().db,
@ -706,7 +731,7 @@ pub(crate) async fn whois(_ctx: ACtx<'_>) -> Result<(), Error> {
/// (Public) Get member info by Discord ID /// (Public) Get member info by Discord ID
#[poise::command(slash_command, rename = "id")] #[poise::command(slash_command, rename = "id")]
pub(crate) async fn whois_by_id(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> { pub(crate) async fn whois_by_id(ctx: ACtx<'_>, id: serenity::Member) -> Result<(), Error> {
println!("Cmd: ({}) whois_by_id {id}", ctx.author().name); println!("Cmd: ({}) whois_by_id {}", 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.send(|c| c.content(format!("{id}: {}", m.nickname)).ephemeral(true)) ctx.send(|c| c.content(format!("{id}: {}", m.nickname)).ephemeral(true))