Add custom welcome messages for when users join the server#33
Add custom welcome messages for when users join the server#33
Conversation
| mod welcome_message; | ||
| use commands::mod_group::MOD_GROUP; | ||
|
|
||
| const CHANNEL__GENERAL: u64 = 601625579791581249; |
There was a problem hiding this comment.
I wasn't sure how we felt about adding another channel_id. I felt like searching by name was a bit too much for the problem since this will always be the same unless we specifically want to move it.
There was a problem hiding this comment.
as long as we don't delete and recreate I think the ids are fine. The other option is to put them in env vars
| let channel = ChannelId(CHANNEL__GENERAL); | ||
|
|
||
| if let Err(err_msg) = channel.send_message(&ctx.http, |msg| { | ||
| msg.content(welcome_message::get_welcome_message(&new_member)); |
There was a problem hiding this comment.
I felt good about moving all the logic of how this message is created into the module. At first it was all here and now through an iterative approach it is all hidden away.
In other news, we need it to be msg.content because of what .send_message expects
| let rand_msg = match welcome_messages.choose(&mut rand::thread_rng()) { | ||
| Some(welcome_message) => welcome_message.clone(), | ||
| None => { | ||
| error!(err = "No welcome message was found from the file"); | ||
| WelcomeMessage { | ||
| before_mention: String::from("Welcome to the server, "), | ||
| after_mention: String::from(".") | ||
| } | ||
| }, | ||
| }; |
There was a problem hiding this comment.
If anyone has any suggestions to making these both borrowed values or owned (I'm not sure if this can be done without cloning here), I'm all for it!
My intention here is even if our list was empty (which might be better for us to do as a failure if the file's contents for some reason wasn't parseable), we'd always still be able to send a message.
| @@ -0,0 +1,6 @@ | |||
| [ | |||
There was a problem hiding this comment.
A way for any folks to contribute to the bot!
|
Do we want to handle boost messages as part of this or just add them in later? In #25 it seemed like moving/disabling server default welcome messages meant that boost messages wouldn't be public anymore. |
|
Yeah that's a good callout @mdarrik, I can make that part of the work here. I am not sure what custom messages we could share but I think exposing them wouldn't hurt! |
|
I think I looked into it before. We should be able to tap into the messages and look for the |
We can now have custom welcome messages! The bot would send the message and it would continue to @mention them in whatever channel we want (designated by
CHANNEL__GENERALfor now).This photo is an example of what it would look like (though I've taken that particular example out.

We had to add some
serdeandrandcrates so we can have a random selection from a file. This was also to make it easier for folks to contribute to the list. I think the specific language ofbefore_mentionandafter_mentionis helpful to keep a strict format of what we the message to look like. But I'm open to suggestions.