diff --git a/assets/json/holiday-list.json b/assets/json/holiday-list.json index e01316df..7de086cf 100644 --- a/assets/json/holiday-list.json +++ b/assets/json/holiday-list.json @@ -3,54 +3,57 @@ "name": "New Year's Day", "hat": "birthday", "month": 1, - "day": 1 + "day": 1, + "activity": "Happy New Year!" }, { "name": "Xiao's Birthday", "hat": "birthday", "month": 2, - "day": 6 + "day": 6, + "activity": "Today's my birthday!" }, { "name": "Pokémon Day", "hat": "ash", "month": 2, - "day": 27 + "day": 27, + "activity": "Happy Pokémon Day!" }, { "name": "Christmas", "hat": "christmas", "month": 12, - "day": 25 + "startDay": 21, + "endDay": 26, + "activity": "Merry Christmas!" }, { "name": "Halloween", "hat": ["witch", "pirate", "devil"], "month": 10, - "day": 31 + "day": 31, + "activity": "Boo! Happy Halloween!" }, { "name": "Talk Like a Pirate Day", "hat": "pirate", "month": 9, - "day": 19 + "day": 19, + "activity": "Arr, it be Talk Like a Pirate Day!" }, { "name": "April Fools Day", "hat": "disguise", "month": 4, - "day": 1 + "day": 1, + "activity": "April Fools!" }, { "name": "St. Patrick's Day", "hat": "leprechaun", "month": 3, - "day": 17 - }, - { - "name": "test", - "hat": "dunce", - "month": 2, - "day": 17 + "day": 17, + "activity": "Make sure you wear green today!" } ] diff --git a/package.json b/package.json index 6562a3bc..dd704e19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "159.4.0", + "version": "159.4.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Activity.js b/structures/Activity.js index 9591ff1a..9ca4e7ef 100644 --- a/structures/Activity.js +++ b/structures/Activity.js @@ -81,5 +81,9 @@ module.exports = [ text: client => `${formatNumber(client.registry.totalUses)} command uses`, emoji: '🤖', type: ActivityType.Custom + }, + { + text: client => client.avatarChanger.holiday ? client.avatarChanger.holiday.activity : 'Just a normal day...', + type: ActivityType.Custom } ]; diff --git a/structures/AvatarChanger.js b/structures/AvatarChanger.js index 918d6b30..6d8bfb81 100644 --- a/structures/AvatarChanger.js +++ b/structures/AvatarChanger.js @@ -7,6 +7,7 @@ module.exports = class AvatarChanger { Object.defineProperty(this, 'client', { value: client }); this.isWearingHat = false; + this.holiday = null; } async editAvatar(hat) { @@ -42,13 +43,15 @@ module.exports = class AvatarChanger { setTimeout(() => { const today = new Date(); const holiday = this.isHoliday(today); - if (holiday) { + 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}`)); @@ -59,11 +62,16 @@ module.exports = class AvatarChanger { isHoliday(day) { for (const holiday of holidayList) { - if (day.getUTCDate() === holiday.day && day.getUTCMonth() === holiday.month - 1) return holiday; + if (day.getUTCMonth() !== holiday.month - 1) continue; + if (day.getUTCDate() >= holiday.startDay && day.getUTCDate() <= holiday.endDay) return holiday; + if (day.getUTCDate() === holiday.day) return holiday; } if (this.isThanksgiving(day)) { return { - hat: 'pilgrim' + name: 'Thanksgiving', + hat: 'pilgrim', + month: day.getUTCMonth(), + day: day.getUTCDate() }; } return false;