mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
just fetch a birthdays channel, ignore cache
This commit is contained in:
parent
fb8b1d8496
commit
74e97e9ccc
1 changed files with 61 additions and 73 deletions
|
@ -8,19 +8,14 @@ module.exports.init = async client => {
|
|||
const cronjob = new CronJob("0 5 * * *", async function () {
|
||||
client.guilds.cache.forEach(async guild => {
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
let channel;
|
||||
const channel = guildData.plugins.birthdays ? await client.channels.fetch(guildData.plugins.birthdays) : null;
|
||||
|
||||
try {
|
||||
channel = guildData.plugins.birthdays ? client.channels.cache.get(guildData.plugins.birthdays) || (await client.channels.fetch(guildData.plugins.birthdays)) : null;
|
||||
} catch (e) { /* Nothing */ }
|
||||
|
||||
if (guildData.plugins.birthdays && client.channels.cache.get(guildData.plugins.birthdays)) {
|
||||
if (guildData.plugins.birthdays && channel) {
|
||||
const date = new Date(),
|
||||
currentDay = date.getDate(),
|
||||
currentMonth = date.getMonth() + 1,
|
||||
currentYear = date.getFullYear();
|
||||
|
||||
if (channel) {
|
||||
client.usersData.find({ birthdate: { $gt: 1 } }).then(async users => {
|
||||
for (const user of users) {
|
||||
if (!guild.members.cache.find(m => m.id === user.id)) return;
|
||||
|
@ -57,7 +52,6 @@ module.exports.init = async client => {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
null,
|
||||
|
@ -74,19 +68,14 @@ module.exports.init = async client => {
|
|||
module.exports.run = async client => {
|
||||
client.guilds.cache.forEach(async guild => {
|
||||
const guildData = await client.getGuildData(guild.id);
|
||||
let channel;
|
||||
const channel = guildData.plugins.birthdays ? await client.channels.fetch(guildData.plugins.birthdays) : null;
|
||||
|
||||
try {
|
||||
channel = guildData.plugins.birthdays ? client.channels.cache.get(guildData.plugins.birthdays) || (await client.channels.fetch(guildData.plugins.birthdays)) : null;
|
||||
} catch (e) { /* Nothing */ }
|
||||
|
||||
if (guildData.plugins.birthdays) {
|
||||
if (guildData.plugins.birthdays && channel) {
|
||||
const date = new Date(),
|
||||
currentDay = date.getDate(),
|
||||
currentMonth = date.getMonth() + 1,
|
||||
currentYear = date.getFullYear();
|
||||
|
||||
if (channel) {
|
||||
client.usersData.find({ birthdate: { $gt: 1 } }).then(async users => {
|
||||
for (const user of users) {
|
||||
if (!guild.members.cache.find(m => m.id === user.id)) return;
|
||||
|
@ -123,6 +112,5 @@ module.exports.run = async client => {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue