forked from Skynet/discord-bot
Compare commits
11 commits
main
...
new-member
Author | SHA1 | Date | |
---|---|---|---|
|
5f4e46bb51 | ||
28b911c468 | |||
e7caf148dd | |||
befced76f8 | |||
421864e151 | |||
557dcb9f8c | |||
b75fa39bcf | |||
986d2f19c9 | |||
cfb5d95be4 | |||
7ed20108fb | |||
c63945bb86 |
2 changed files with 30 additions and 1 deletions
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "1.80"
|
||||
channel = "1.80"
|
||||
|
|
29
src/main.rs
29
src/main.rs
|
@ -7,6 +7,8 @@ use serenity::{
|
|||
application::{command::Command, interaction::Interaction},
|
||||
gateway::{GatewayIntents, Ready},
|
||||
guild,
|
||||
prelude::Activity,
|
||||
user::OnlineStatus,
|
||||
},
|
||||
Client,
|
||||
};
|
||||
|
@ -49,11 +51,38 @@ impl EventHandler for Handler {
|
|||
if let Err(e) = new_member.add_roles(&ctx, &roles).await {
|
||||
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) {
|
||||
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| {
|
||||
commands
|
||||
|
|
Loading…
Reference in a new issue