2022-08-04 19:26:17 +05:00
|
|
|
const { SlashCommandBuilder } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand"),
|
2022-09-16 19:11:28 +05:00
|
|
|
ms = require("ms"),
|
|
|
|
moment = require("moment");
|
2022-08-04 19:26:17 +05:00
|
|
|
|
|
|
|
class Remindme extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("remindme")
|
|
|
|
.setDescription(client.translate("general/remindme:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("general/remindme:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("general/remindme:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(true)
|
2022-08-04 19:26:17 +05:00
|
|
|
.addStringOption(option => option.setName("time")
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescription(client.translate("general/remindme:TIME"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("general/remindme:TIME", null, "uk-UA"),
|
|
|
|
"ru": client.translate("general/remindme:TIME", null, "ru-RU"),
|
|
|
|
})
|
2022-08-04 19:26:17 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addStringOption(option => option.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:MESSAGE", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:MESSAGE", null, "ru-RU"),
|
|
|
|
})
|
2022-08-04 19:26:17 +05:00
|
|
|
.setRequired(true)),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction, data) {
|
2022-09-16 19:11:28 +05:00
|
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
const time = interaction.options.getString("time");
|
|
|
|
const message = interaction.options.getString("message");
|
|
|
|
const dateNow = Date.now();
|
|
|
|
if (!data.userData.reminds) data.userData.reminds = [];
|
|
|
|
|
|
|
|
const rData = {
|
|
|
|
message: message,
|
|
|
|
createdAt: dateNow,
|
2022-12-15 21:02:38 +05:00
|
|
|
sendAt: dateNow + ms(time),
|
2022-08-04 19:26:17 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
data.userData.reminds.push(rData);
|
|
|
|
data.userData.markModified("reminds");
|
|
|
|
data.userData.save();
|
2022-08-13 19:29:13 +05:00
|
|
|
client.databaseCache.usersReminds.set(interaction.member.id, data.userData);
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2022-09-16 19:11:28 +05:00
|
|
|
interaction.success("general/remindme:SAVED", {
|
|
|
|
message,
|
2023-06-27 21:19:55 +05:00
|
|
|
time: moment(rData.sendAt).locale(data.guildData.language).format("dddd, Do MMMM YYYY, HH:mm:ss"),
|
2022-09-16 19:11:28 +05:00
|
|
|
}, { edit: true });
|
2022-08-04 19:26:17 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Remindme;
|