fixed birthday check, removed console.logs
This commit is contained in:
parent
087dec40ed
commit
ec7193815a
2 changed files with 20 additions and 19 deletions
|
@ -134,12 +134,11 @@ async function addBirthday(options) {
|
|||
|
||||
async function checkBirthday(interaction) {
|
||||
const currDay = new Date().getDate();
|
||||
const currMonth = new Date().getMonth();
|
||||
const currMonth = new Date().getMonth() + 1;
|
||||
|
||||
|
||||
const query = bModel.find({});
|
||||
const result = await query.exec();
|
||||
console.log(result);
|
||||
|
||||
let closestD;
|
||||
let closestM;
|
||||
|
@ -152,33 +151,34 @@ async function checkBirthday(interaction) {
|
|||
const userId = result[i].id;
|
||||
const nick = result[i].nickname;
|
||||
if ((currMonth == birthMonth && currDay <= birthDay) || currMonth < birthMonth) {
|
||||
if (isFirst) {
|
||||
closestD = birthDay;
|
||||
closestM = birthMonth;
|
||||
isFirst = false;
|
||||
}
|
||||
if (!isFirst && (closestD == birthDay && closestM == birthMonth)) {
|
||||
if (isInGuild(guildMembers, userId)) {
|
||||
if (await isInGuild(guildMembers, userId)) {
|
||||
if (isFirst) {
|
||||
closestD = birthDay;
|
||||
closestM = birthMonth;
|
||||
isFirst = false;
|
||||
}
|
||||
if (!isFirst && (closestD == birthDay && closestM == birthMonth)) {
|
||||
closest.push(`<@${userId}> ${nick}`);
|
||||
}
|
||||
else {
|
||||
const probably = getProbably();
|
||||
const personList = closest.join('\n');
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`Closest birthday is ${closestD}. ${closestM}.`)
|
||||
.setDescription(`${personList} \n will celebrate ${probably}`)
|
||||
.setColor(help.randomColor());
|
||||
.setTitle(`Closest birthday is ${closestD}. ${closestM}.`)
|
||||
.setDescription(`${personList} \n will celebrate... ${probably}`)
|
||||
.setColor(help.randomColor());
|
||||
return embed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closest != []) {
|
||||
|
||||
if (closest.length > 0) {
|
||||
const probably = getProbably();
|
||||
const personList = closest.join('\n');
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`Closest birthday is ${closestD}. ${closestM}.`)
|
||||
.setDescription(`${personList} \n will celebrate ${probably}`)
|
||||
.setDescription(`${personList} \n will celebrate... ${probably}`)
|
||||
.setColor(help.randomColor());
|
||||
return embed;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ async function checkBirthday(interaction) {
|
|||
const probably = getProbably();
|
||||
closest.join('\n');
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`Closest birthday is ${birthDay}. ${birthMonth}.`)
|
||||
.setTitle(`Closest birthday is ${closestD}. ${closestM}.`)
|
||||
.setDescription(`${closest} \n will celebrate ${probably}`)
|
||||
.setColor(help.randomColor());
|
||||
return embed;
|
||||
|
@ -303,7 +303,7 @@ function getProbably() {
|
|||
case 2:
|
||||
return 'or will they?';
|
||||
case 3:
|
||||
return '\n I still love you the same don\'t worry';
|
||||
return '\n You may be older, but I still love you the same don\'t worry';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -339,7 +339,10 @@ async function checkMonth(month) {
|
|||
}
|
||||
|
||||
async function isInGuild(guildMembers, userId) {
|
||||
if ((await guildMembers.fetch()).find(user => user.id == userId) == undefined) {
|
||||
try {
|
||||
await guildMembers.fetch(userId);
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
2
main.js
2
main.js
|
@ -186,8 +186,6 @@ async function pingEvent() {
|
|||
|
||||
query = eModel.find({ guild: 'global', day: currentDay, month: currentMonth });
|
||||
const globalEventList = await query.exec();
|
||||
|
||||
console.log(birthdayList, globalEventList);
|
||||
const guildIds = [];
|
||||
const sysChannelIds = [];
|
||||
client.guilds.cache.forEach(element => {
|
||||
|
|
Loading…
Reference in a new issue