JaBa/commands/General/remindme.js

45 lines
1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
ms = require("ms");
class Remindme extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "remindme",
dirname: __dirname,
enabled: true,
guildOnly: false,
2021-12-26 19:29:37 +05:00
aliases: ["reminder"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const time = args[0];
if (!time || isNaN(ms(time))) return message.error("misc:INVALID_TIME");
const msg = args.slice(1).join(" ");
if (!msg) return message.error("general/remindme:MISSING_MESSAGE");
const rData = {
message: msg,
createdAt: Date.now(),
2021-12-26 19:29:37 +05:00
sendAt: Date.now() + ms(time)
2021-12-10 21:39:54 +05:00
};
if (!data.userData.reminds) data.userData.reminds = [];
data.userData.reminds.push(rData);
data.userData.markModified("reminds");
data.userData.save();
this.client.databaseCache.usersReminds.set(message.author.id, data.userData);
message.success("general/remindme:SAVED");
}
};
module.exports = Remindme;