From b75fa39bcfafe4f655d70f8022be61175490f065 Mon Sep 17 00:00:00 2001 From: Daragh Downes Date: Mon, 16 Sep 2024 20:14:45 +0100 Subject: [PATCH] feat: change channel id based on server --- src/main.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ea8d3b0..c1bdc45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,11 +49,27 @@ impl EventHandler for Handler { if let Err(e) = new_member.add_roles(&ctx, &roles).await { println!("{:?}", e); } - } else if let Some(name) = new_member.guild_id.name(&ctx) { + } else if let Some(server_name) = new_member.guild_id.name(&ctx) { + let ulwolves_link = ""; + let mut bot_channel = String::new(); + + if let Ok(channels) = new_member.guild_id.channels(&ctx).await { + if let Some(channel) = channels.values().find(|c| c.name == "bot-commands") { + bot_channel = channel.id.to_string(); + } + } + let bot_channel_message = match bot_channel.is_empty() { + true => format!("go to the bot channel"), + false => format!("go to https://discord.com/{}/{}", new_member.guild_id, bot_channel), + }; + let msg = format!( - "Welcome to the {} server! \n\ - Sign up on ulwolves and go to #bot_commands and do /link_wolves to get full access", - name + "Welcome {} to the {} server! \n\ + Sign up on [UL Wolves]({}) and {} and use ``/link_wolves`` to get full access", + new_member.display_name(), + server_name, + ulwolves_link, + bot_channel_message ); if let Err(err) = new_member.user.direct_message(&ctx, |m| m.content(&msg)).await {