Added Leaderboard to Quotes
This commit is contained in:
+36
-1
@@ -1,4 +1,5 @@
|
||||
const { Events, ActivityType } = require('discord.js')
|
||||
const { Events, ActivityType } = require('discord.js');
|
||||
const { mClient } = require('..');
|
||||
|
||||
module.exports = {
|
||||
name: Events.ClientReady,
|
||||
@@ -13,5 +14,39 @@ module.exports = {
|
||||
}],
|
||||
status: 'online'
|
||||
})
|
||||
|
||||
// if today is birthday
|
||||
function isToday(day, month) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const inputDate = new Date(currentYear, month - 1, day);
|
||||
const today = new Date();
|
||||
return (
|
||||
inputDate.getDate() === today.getDate() &&
|
||||
inputDate.getMonth() === today.getMonth() &&
|
||||
inputDate.getFullYear() === today.getFullYear()
|
||||
);
|
||||
}
|
||||
async function isBirthday() {
|
||||
const db = mClient.db(process.env.M_DB)
|
||||
const bdayColl = db.collection('birthdays')
|
||||
const allBirthdays = await bdayColl.find().toArray()
|
||||
for (let index = 0; index < allBirthdays.length; index++) {
|
||||
if (isToday(allBirthdays[index].day, allBirthdays[index].month)) {
|
||||
let guild = client.guilds.cache.get(process.env.D_GuildID)
|
||||
let member = guild.members.cache.get(allBirthdays[index].userID)
|
||||
client.emit('Birthday', member)
|
||||
} else {
|
||||
// remove any residual birthday roles
|
||||
try {
|
||||
let guild = client.guilds.cache.get(process.env.D_GuildID)
|
||||
let member = guild.members.cache.get(allBirthdays[index].userID)
|
||||
await member.roles.remove('702877228857557002')
|
||||
} catch (error) {
|
||||
console.error('Could not remove role', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
isBirthday()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user