Skip to content

Commit

Permalink
[Feature]: Verification for JIIT students. (#14)
Browse files Browse the repository at this point in the history
* [Feature]: Email verification system

* Minor fix

* Assign role according to batch.

* [Improvement]: Handle 128 Guys' and Faculty email addresses.

* Minor Change.

* Create role if doesn't exist + refactor

Co-authored-by: Hemant <[email protected]>
  • Loading branch information
utkarsh261 and hemant2132 authored Jan 8, 2021
1 parent 7b098bd commit 4cabea1
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 133 deletions.
13 changes: 10 additions & 3 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { join } = require("path");

require("dotenv").config();

const { join } = require("path");
const Discord = require("discord.js");
const getFiles = require("./getFiles");
const remind = require("./remind");
const addRole = require("./utils/addRole");
const verify = require("./verify");

const bot = new Discord.Client();
bot.commands = new Discord.Collection();
Expand All @@ -22,10 +23,11 @@ bot.on("guildMemberAdd", (member) => {
.setColor("#176ffc")
.setTitle(`Yay! ${name} you made it to KPH discord Server `)
.setDescription(
`I am your friendly bot written in Javascript, Feel free to tell us more about yourself.`
`I am your friendly bot written in Javascript, Feel free to tell us more about yourself.\n *If* you wish to be identified as JIITian, send !verify in #general :D.`
)
.setFooter("Use !help command to know more about me ");
channel.send(welcomeEmbed);
verify(bot, member);
});

bot.on("ready", async () => {
Expand All @@ -46,6 +48,11 @@ bot.on("message", (message) => {
const args = message.content.trim().split(/\r\n|\r|\n| +/);
const command = args.shift().toLowerCase();

if (command === "!verify") {
verify(bot, message.author);
return;
}

// If a command is not present , log the default message
if (!bot.commands.has(command)) {
if (command[0] === "!") bot.commands.get("!invalid").execute(message, args);
Expand Down
11 changes: 6 additions & 5 deletions commands/events/addEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ const eventObj = {

// A function for checking if the date or time has been already passed or not
function checkSchedule(args) {

const decidedDay = args[1];
const decidedTime = args[3];
const curDay = new Date().toLocaleDateString(undefined, {timeZone: "Asia/Kolkata"});
const curDay = new Date().toLocaleDateString(undefined, {
timeZone: "Asia/Kolkata",
});
const curTime = new Date().toLocaleTimeString("en-US", {
hour12: false,
hour: "numeric",
Expand All @@ -41,7 +42,6 @@ function checkSchedule(args) {
}

return true;

}

const compute = (args) => {
Expand Down Expand Up @@ -77,7 +77,8 @@ module.exports = {
name: "!addevent",
permission: "*",
description: "Add an event",
usage: " ```!addevent\n\nFormat:\ndate: DD/MM/YYYY\ntime: HH:MM (24 hr)\ntitle: ...\nvenue: ...```",
usage:
" ```!addevent\n\nFormat:\ndate: DD/MM/YYYY\ntime: HH:MM (24 hr)\ntitle: ...\nvenue: ...```",
execute: async (message, args) => {
if (!message.member.hasPermission("ADMINISTRATOR")) {
message.channel.send("You do not have permission to run this command.");
Expand Down Expand Up @@ -120,4 +121,4 @@ module.exports = {

message.channel.send(str);
},
};
};
Loading

0 comments on commit 4cabea1

Please sign in to comment.