Skip to content
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

Open
wants to merge 5 commits into
base: corgi
Choose a base branch
from

Conversation

maxcell
Copy link
Contributor

@maxcell maxcell commented Oct 7, 2020

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.
image

We had to add some serde and rand 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 of before_mention and after_mention is helpful to keep a strict format of what we the message to look like. But I'm open to suggestions.

@maxcell maxcell linked an issue Oct 7, 2020 that may be closed by this pull request
use commands::mod_group::MOD_GROUP;

const CHANNEL__GENERAL: u64 = 601625579791581249;
Copy link
Contributor Author

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.

Copy link
Contributor

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));
Copy link
Contributor Author

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

Comment on lines +31 to +40
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(".")
}
},
};
Copy link
Contributor Author

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 @@
[
Copy link
Contributor Author

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!

@mdarrik
Copy link
Contributor

mdarrik commented Oct 7, 2020

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.

@maxcell
Copy link
Contributor Author

maxcell commented Oct 7, 2020

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!

@mdarrik
Copy link
Contributor

mdarrik commented Oct 7, 2020

I think I looked into it before. We should be able to tap into the messages and look for the MessageType enum to be NitroBoost. It should be sort of similar to the spotify message handling in the "listening-party" channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create welcome message to users that join the Discord
3 participants