2024-02-06 21:45:53 +05:00
|
|
|
const { SlashCommandBuilder } = require("discord.js");
|
2022-08-04 19:26:17 +05:00
|
|
|
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 {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("remindme")
|
|
|
|
.setDescription(client.translate("general/remindme:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("general/remindme:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("general/remindme:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(true)
|
2023-07-05 00:58:06 +05:00
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("time")
|
|
|
|
.setDescription(client.translate("general/remindme:TIME"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("general/remindme:TIME", null, "uk-UA"),
|
|
|
|
ru: client.translate("general/remindme:TIME", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
)
|
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:MESSAGE", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:MESSAGE", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
),
|
2022-08-04 19:26:17 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
* @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
|
|
|
if (!data.userData.reminds) data.userData.reminds = [];
|
2024-01-27 16:31:34 +05:00
|
|
|
|
|
|
|
const dateNow = Date.now();
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-01-23 16:11:10 +05:00
|
|
|
const reminderData = {
|
2024-01-27 16:31:34 +05:00
|
|
|
message: interaction.options.getString("message"),
|
2022-08-04 19:26:17 +05:00
|
|
|
createdAt: dateNow,
|
2024-01-27 16:31:34 +05:00
|
|
|
sendAt: dateNow + ms(interaction.options.getString("time")),
|
2022-08-04 19:26:17 +05:00
|
|
|
};
|
|
|
|
|
2024-01-23 16:11:10 +05:00
|
|
|
data.userData.reminds.push(reminderData);
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-30 21:45:10 +05:00
|
|
|
data.userData.markModified("reminds");
|
2023-10-17 08:33:41 +05:00
|
|
|
await data.userData.save();
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2023-10-09 17:08:19 +05:00
|
|
|
client.databaseCache.usersReminds.set(interaction.user.id, data.userData);
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
author: interaction.translate("general/remindme:EMBED_SAVED"),
|
|
|
|
fields: [
|
2024-01-27 16:31:34 +05:00
|
|
|
{
|
|
|
|
name: interaction.translate("general/remindme:EMBED_TIME"),
|
|
|
|
value: moment(reminderData.sendAt).locale(interaction.getLocale()).format("Do MMMM YYYY, HH:mm:ss"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:MESSAGE"),
|
|
|
|
value: reminderData.message,
|
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
],
|
|
|
|
});
|
2024-01-27 16:31:34 +05:00
|
|
|
|
|
|
|
interaction.editReply({
|
|
|
|
embeds: [embed],
|
|
|
|
});
|
2022-08-04 19:26:17 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Remindme;
|