Skip to content

User roles #89

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

Merged
merged 2 commits into from
Nov 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bot/controllers/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = () => {
if (validDomains.includes(emailDomain)) {
const codeLength = 6;
const code = generateCode(codeLength);
util.log('code', code);
// TODO: Set `time` prop to 600000 (10min)
const collector = message.channel.createMessageCollector(
m => m.content.includes(code),
Expand All @@ -53,11 +54,20 @@ module.exports = () => {
if (data === null) {
// no existing record found
models.Member.create({
discorduser: m.author.username,
discorduser: m.author.id,
email,
uuid: uuidv4(),
verified: 1,
}).then(util.log).catch(util.error);
});
// maping guild roles to find the crew role id
const guild = message.guild.roles.map(channel => channel);
Object.keys(guild).forEach((el) => {
if (guild[el].name === 'crew') {
m.member.addRole(guild[el].id);
} else {
util.log('the moredator has to create the crew role');
}
});
message.reply(verifyUser);
} else {
// existing record found
Expand Down