mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 08:14:47 +02:00
Allow deleting reminders
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class DeleteReminderCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'delete-reminder',
|
||||
aliases: ['delete-remind', 'delete-timer', 'del-reminder', 'del-remind', 'del-timer'],
|
||||
group: 'remind',
|
||||
memberName: 'remind',
|
||||
description: 'Deletes your reminder.'
|
||||
});
|
||||
}
|
||||
|
||||
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 timer set in this channel.');
|
||||
await this.client.timers.deleteTimer(msg.channel.id, msg.author.id);
|
||||
return msg.say('🕰️ Your timer has been deleted.');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const moment = require('moment');
|
||||
const { shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class RemindCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'remind',
|
||||
aliases: ['timer', 'remind-me'],
|
||||
group: 'remind',
|
||||
memberName: 'remind',
|
||||
description: 'Sets a reminder.',
|
||||
args: [
|
||||
{
|
||||
key: 'time',
|
||||
prompt: 'What do you want me to remind you about, and in how long?',
|
||||
type: 'sherlock'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
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.');
|
||||
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);
|
||||
return msg.say(`🕰️ Okay, I will remind you **"${title}"** ${display}.`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user