-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom welcome messages for when users join the server #33
base: corgi
Are you sure you want to change the base?
Conversation
use commands::mod_group::MOD_GROUP; | ||
|
||
const CHANNEL__GENERAL: u64 = 601625579791581249; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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__GENERAL
for 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
serde
andrand
crates 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_mention
andafter_mention
is helpful to keep a strict format of what we the message to look like. But I'm open to suggestions.