I am slowly learning javascript in my spare time and I haven't quite gotten to this yet. But a friend asked me to make a simple bot, one that private messages every new user that joins the server, asks them which color they would like their username to be and adds them to the role they reply with. The roles on the server have no permission significance. It is purely a color for the username (the discord server is a DeviantArt-based community chat).
In the below excerpt, it works just fine, until the user replies with a color "blue" and the reply of "Please choose a color or be sure you typed the color exactly as shown." is sent instead of adding the user to the right role and replying with what the color is. I am fairly certain that the issue with with this part:
user.addTo(server.roles.get("name", `${collected.first().content}`));
newmsg.channel.send(`Your name is now: **${collected.first().content}** Thank you and enjoy the server!`)
I am just unsure with what I am missing or how it should be structured to make it work. The colors listed do show up in lowercase in the roles area and the roles exist.
bot.on('guildMemberAdd', member => {
member.send("Welcome to RebornWings! Please select a color for your username! **Choices: orange-red, red, blue, blue-green, or purple** Please type exactly how they appear in the list of choices.")
.then((newmsg) => { //Now newmsg is the message you sent
newmsg.channel.awaitMessages(response => response.content, {
max: 1,
time: 300000,
errors: ['time'],
}).then((collected) => {
user.addTo(server.roles.get("name", `${collected.first().content}`))
newmsg.channel.send(`Your name is now: **${collected.first().content}** Thank you and enjoy the server!`)
}).catch(() => {
newmsg.channel.send('Please choose a color or be sure you typed the color exactly as shown.');
});
});
});
bot.login(config.token);
I think I am fairly close to having it from experimenting with things, just not sure what piece I am missing.
Thanks in advance for the help while I am slowly learning on my own.