mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Add activities to avatar changer
This commit is contained in:
@@ -3,54 +3,57 @@
|
|||||||
"name": "New Year's Day",
|
"name": "New Year's Day",
|
||||||
"hat": "birthday",
|
"hat": "birthday",
|
||||||
"month": 1,
|
"month": 1,
|
||||||
"day": 1
|
"day": 1,
|
||||||
|
"activity": "Happy New Year!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Xiao's Birthday",
|
"name": "Xiao's Birthday",
|
||||||
"hat": "birthday",
|
"hat": "birthday",
|
||||||
"month": 2,
|
"month": 2,
|
||||||
"day": 6
|
"day": 6,
|
||||||
|
"activity": "Today's my birthday!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Pokémon Day",
|
"name": "Pokémon Day",
|
||||||
"hat": "ash",
|
"hat": "ash",
|
||||||
"month": 2,
|
"month": 2,
|
||||||
"day": 27
|
"day": 27,
|
||||||
|
"activity": "Happy Pokémon Day!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Christmas",
|
"name": "Christmas",
|
||||||
"hat": "christmas",
|
"hat": "christmas",
|
||||||
"month": 12,
|
"month": 12,
|
||||||
"day": 25
|
"startDay": 21,
|
||||||
|
"endDay": 26,
|
||||||
|
"activity": "Merry Christmas!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Halloween",
|
"name": "Halloween",
|
||||||
"hat": ["witch", "pirate", "devil"],
|
"hat": ["witch", "pirate", "devil"],
|
||||||
"month": 10,
|
"month": 10,
|
||||||
"day": 31
|
"day": 31,
|
||||||
|
"activity": "Boo! Happy Halloween!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Talk Like a Pirate Day",
|
"name": "Talk Like a Pirate Day",
|
||||||
"hat": "pirate",
|
"hat": "pirate",
|
||||||
"month": 9,
|
"month": 9,
|
||||||
"day": 19
|
"day": 19,
|
||||||
|
"activity": "Arr, it be Talk Like a Pirate Day!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "April Fools Day",
|
"name": "April Fools Day",
|
||||||
"hat": "disguise",
|
"hat": "disguise",
|
||||||
"month": 4,
|
"month": 4,
|
||||||
"day": 1
|
"day": 1,
|
||||||
|
"activity": "April Fools!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "St. Patrick's Day",
|
"name": "St. Patrick's Day",
|
||||||
"hat": "leprechaun",
|
"hat": "leprechaun",
|
||||||
"month": 3,
|
"month": 3,
|
||||||
"day": 17
|
"day": 17,
|
||||||
},
|
"activity": "Make sure you wear green today!"
|
||||||
{
|
|
||||||
"name": "test",
|
|
||||||
"hat": "dunce",
|
|
||||||
"month": 2,
|
|
||||||
"day": 17
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "159.4.0",
|
"version": "159.4.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -81,5 +81,9 @@ module.exports = [
|
|||||||
text: client => `${formatNumber(client.registry.totalUses)} command uses`,
|
text: client => `${formatNumber(client.registry.totalUses)} command uses`,
|
||||||
emoji: '🤖',
|
emoji: '🤖',
|
||||||
type: ActivityType.Custom
|
type: ActivityType.Custom
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: client => client.avatarChanger.holiday ? client.avatarChanger.holiday.activity : 'Just a normal day...',
|
||||||
|
type: ActivityType.Custom
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ module.exports = class AvatarChanger {
|
|||||||
Object.defineProperty(this, 'client', { value: client });
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
this.isWearingHat = false;
|
this.isWearingHat = false;
|
||||||
|
this.holiday = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async editAvatar(hat) {
|
async editAvatar(hat) {
|
||||||
@@ -42,13 +43,15 @@ module.exports = class AvatarChanger {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const holiday = this.isHoliday(today);
|
const holiday = this.isHoliday(today);
|
||||||
if (holiday) {
|
if (holiday && !this.holiday) {
|
||||||
|
this.holiday = holiday;
|
||||||
let { hat } = holiday;
|
let { hat } = holiday;
|
||||||
if (Array.isArray(hat)) hat = hat[Math.floor(Math.random() * hat.length)];
|
if (Array.isArray(hat)) hat = hat[Math.floor(Math.random() * hat.length)];
|
||||||
this.setAvatar(hat)
|
this.setAvatar(hat)
|
||||||
.then(() => this.client.logger.info(`[AVATAR] Updated avatar to ${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}`));
|
.catch(err => this.client.logger.error(`[AVATAR] Failed to update avatar.\n${err.stack}`));
|
||||||
} else if (this.isWearingHat) {
|
} else if (this.isWearingHat) {
|
||||||
|
this.holiday = null;
|
||||||
this.setAvatar()
|
this.setAvatar()
|
||||||
.then(() => this.client.logger.info('[AVATAR] Reset avatar to default.'))
|
.then(() => this.client.logger.info('[AVATAR] Reset avatar to default.'))
|
||||||
.catch(err => this.client.logger.error(`[AVATAR] Failed to update avatar.\n${err.stack}`));
|
.catch(err => this.client.logger.error(`[AVATAR] Failed to update avatar.\n${err.stack}`));
|
||||||
@@ -59,11 +62,16 @@ module.exports = class AvatarChanger {
|
|||||||
|
|
||||||
isHoliday(day) {
|
isHoliday(day) {
|
||||||
for (const holiday of holidayList) {
|
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)) {
|
if (this.isThanksgiving(day)) {
|
||||||
return {
|
return {
|
||||||
hat: 'pilgrim'
|
name: 'Thanksgiving',
|
||||||
|
hat: 'pilgrim',
|
||||||
|
month: day.getUTCMonth(),
|
||||||
|
day: day.getUTCDate()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user