Compare commits

...

11 commits

2 changed files with 30 additions and 1 deletions

View file

@ -1,2 +1,2 @@
[toolchain] [toolchain]
channel = "1.80" channel = "1.80"

View file

@ -7,6 +7,8 @@ use serenity::{
application::{command::Command, interaction::Interaction}, application::{command::Command, interaction::Interaction},
gateway::{GatewayIntents, Ready}, gateway::{GatewayIntents, Ready},
guild, guild,
prelude::Activity,
user::OnlineStatus,
}, },
Client, Client,
}; };
@ -49,11 +51,38 @@ impl EventHandler for Handler {
if let Err(e) = new_member.add_roles(&ctx, &roles).await { if let Err(e) = new_member.add_roles(&ctx, &roles).await {
println!("{:?}", e); println!("{:?}", e);
} }
} 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 => "go to the bot channel".to_string(),
false => format!("go to https://discord.com/channels/{}/{}", new_member.guild_id, bot_channel),
};
let msg = format!(
"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 {
dbg!(err);
}
} }
} }
async fn ready(&self, ctx: Context, ready: Ready) { async fn ready(&self, ctx: Context, ready: Ready) {
println!("[Main] {} is connected!", ready.user.name); println!("[Main] {} is connected!", ready.user.name);
ctx.set_presence(Some(Activity::playing("with humanity's fate")), OnlineStatus::Online).await;
match Command::set_global_application_commands(&ctx.http, |commands| { match Command::set_global_application_commands(&ctx.http, |commands| {
commands commands