diff --git a/structures/AvatarChanger.js b/structures/AvatarChanger.js index 2add817a..b459ed08 100644 --- a/structures/AvatarChanger.js +++ b/structures/AvatarChanger.js @@ -7,7 +7,6 @@ module.exports = class AvatarChanger { Object.defineProperty(this, 'client', { value: client }); this.isWearingHat = false; - this.holiday = null; } async editAvatar(hat) { @@ -44,14 +43,12 @@ module.exports = class AvatarChanger { const today = new Date(); const holiday = this.isHoliday(today); if (holiday && !this.holiday) { - this.holiday = holiday; let { hat } = holiday; if (Array.isArray(hat)) hat = hat[Math.floor(Math.random() * hat.length)]; this.setAvatar(hat) .then(() => this.client.logger.info(`[AVATAR] Updated avatar to ${hat}!`)) .catch(err => this.client.logger.error(`[AVATAR] Failed to update avatar.\n${err.stack}`)); } else if (this.isWearingHat) { - this.holiday = null; this.setAvatar() .then(() => this.client.logger.info('[AVATAR] Reset avatar to default.')) .catch(err => this.client.logger.error(`[AVATAR] Failed to update avatar.\n${err.stack}`)); @@ -60,6 +57,11 @@ module.exports = class AvatarChanger { }, msUntilNext); } + get holiday() { + const today = new Date(); + return this.isHoliday(today) || null; + } + isHoliday(day) { for (const holiday of holidayList) { if (day.getUTCMonth() !== holiday.month - 1) continue;