mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Allow many same channel timers
This commit is contained in:
@@ -7,14 +7,16 @@ module.exports = class DeleteReminderCommand extends Command {
|
||||
aliases: ['delete-remind', 'delete-timer', 'del-reminder', 'del-remind', 'del-timer'],
|
||||
group: 'remind',
|
||||
memberName: 'delete-reminder',
|
||||
description: 'Deletes your reminder.'
|
||||
description: 'Deletes your reminder(s) set in this channel.'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
const exists = await this.client.timers.exists(msg.channel.id, msg.author.id);
|
||||
if (!exists) return msg.reply('🕰️ You do not have a reminder set in this channel.');
|
||||
await this.client.timers.deleteTimer(msg.channel.id, msg.author.id);
|
||||
return msg.say('🕰️ Your reminder has been deleted.');
|
||||
const found = this.client.timers.findAll(msg.channel.id, msg.author.id);
|
||||
if (!found.size) return msg.reply('🕰️ You do not have a reminder set in this channel.');
|
||||
for (const timer of found.values()) {
|
||||
await timer.delete();
|
||||
}
|
||||
return msg.say('🕰️ Your reminder(s) set in this channel have been deleted.');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,14 +21,12 @@ module.exports = class RemindCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { time }) {
|
||||
const exists = await this.client.timers.exists(msg.channel.id, msg.author.id);
|
||||
if (exists) return msg.reply('🕰️ Only one reminder can be set per channel per user.');
|
||||
const timeMs = time.startDate.getTime() - Date.now();
|
||||
if (timeMs > 0x7FFFFFFF) return msg.reply('🕰️ Reminders have a maximum length of ~24.84 days.');
|
||||
if (timeMs < 0) return msg.reply('🕰️ What do you expect me to do, time travel?');
|
||||
const display = moment().add(timeMs, 'ms').fromNow();
|
||||
const title = time.eventTitle ? shorten(time.eventTitle, 500) : 'something';
|
||||
await this.client.timers.setTimer(msg.channel.id, timeMs, msg.author.id, title);
|
||||
await this.client.timers.setTimer(null, msg.channel.id, timeMs, msg.author.id, title);
|
||||
return msg.say(`🕰️ Okay, I will remind you **"${title}"** ${display}.`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user