diff options
Diffstat (limited to 'src/commands/utilities/reminders.ts')
-rw-r--r-- | src/commands/utilities/reminders.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts new file mode 100644 index 0000000..7180aa9 --- /dev/null +++ b/src/commands/utilities/reminders.ts @@ -0,0 +1,33 @@ +import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib'; +import { MessageEmbedOptions } from 'discord.js'; +import { Op } from 'sequelize'; + +export default class RemindersCommand extends BushCommand { + public constructor() { + super('reminders', { + aliases: ['reminders', 'view-reminders', 'list-reminders'], + category: 'utilities', + description: 'List all your current reminders.', + usage: ['reminder'], + examples: ['reminders'], + slash: true, + clientPermissions: (m) => util.clientSendAndPermCheck(m, 'EMBED_LINKS'), + userPermissions: [] + }); + } + + public override async exec(message: BushMessage | BushSlashMessage) { + const reminders = await Reminder.findAll({ where: { user: message.author.id, expires: { [Op.gt]: new Date() } } }); + if (!reminders.length) return message.util.send(`${util.emojis.error} You don't have any reminders set.`); + + const formattedReminders = reminders.map((reminder) => `${util.timestamp(reminder.expires, 't')} - ${reminder.content}`); + + const chunked = util.chunk(formattedReminders, 15); + const embeds: MessageEmbedOptions[] = chunked.map((chunk) => ({ + title: `Reminders`, + description: chunk.join('\n'), + color: util.colors.default + })); + return await ButtonPaginator.send(message, embeds); + } +} |