Skip to content
Snippets Groups Projects
Commit 7b8b417a authored by Ash's avatar Ash Committed by tec
Browse files

Better way of doing random nickname

parent 2790347c
Branches
Tags
No related merge requests found
...@@ -40,6 +40,15 @@ pub fn new_member(ctx: &Context, mut new_member: Member) { ...@@ -40,6 +40,15 @@ pub fn new_member(ctx: &Context, mut new_member: Member) {
}; };
} }
pub const RANDOM_NICKNAMES: &[&str] = &[
"The Big Cheese",
"The One and Only",
"The Exalted One",
"not to be trusted",
"The Scoundrel",
"A big fish in a small pond",
];
pub struct Commands; pub struct Commands;
impl Commands { impl Commands {
pub fn register(ctx: Context, msg: Message, account_name: &str) { pub fn register(ctx: Context, msg: Message, account_name: &str) {
...@@ -74,18 +83,10 @@ impl Commands { ...@@ -74,18 +83,10 @@ impl Commands {
e!( e!(
"Unable to edit nickname: {:?}", "Unable to edit nickname: {:?}",
member.edit(&ctx.http, |m| { member.edit(&ctx.http, |m| {
let mut rng = rand::thread_rng();
m.nickname(format!( m.nickname(format!(
"{}, {}", "{}, {}",
name, name,
[ RANDOM_NICKNAMES.choose(&mut rand::thread_rng())
"The Big Cheese",
"The One and Only",
"The Exalted One",
"not to be trusted",
"The Scoundrel",
"A big fish in a small pond",
][rng.gen_range(0, 5)]
)); ));
m m
}) })
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment