1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import {
BotCommand,
ButtonPaginator,
chunk,
clientSendAndPermCheck,
colors,
emojis,
Reminder,
timestamp,
type CommandMessage,
type SlashMessage
} from '#lib';
import assert from 'assert/strict';
import { PermissionFlagsBits, type APIEmbed } from 'discord.js';
import { Op } from 'sequelize';
assert(Op);
export default class RemindersCommand extends BotCommand {
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) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks]),
userPermissions: []
});
}
public override async exec(message: CommandMessage | SlashMessage) {
const reminders = await Reminder.findAll({ where: { user: message.author.id, expires: { [Op.gt]: new Date() } } });
if (!reminders.length) return message.util.send(`${emojis.error} You don't have any reminders set.`);
const formattedReminders = reminders.map((reminder) => `${timestamp(reminder.expires, 't')} - ${reminder.content}`);
const chunked = chunk(formattedReminders, 15);
const embeds: APIEmbed[] = chunked.map((chunk) => ({
title: `Reminders`,
description: chunk.join('\n'),
color: colors.default
}));
return await ButtonPaginator.send(message, embeds);
}
}
|