reminder rework

This commit is contained in:
Jonny_Bro (Nikita) 2024-01-27 16:31:34 +05:00
parent f33ff35e4b
commit 57b4acc540
No known key found for this signature in database
GPG key ID: 391C19BE62D36B33
6 changed files with 49 additions and 27 deletions

View file

@ -45,7 +45,7 @@ class Afk extends BaseCommand {
* @param {Object} data
*/
async execute(client, interaction, data) {
interaction.deferReply({ ephemeral: true });
await interaction.deferReply({ ephemeral: true });
const reason = interaction.options.getString("message");

View file

@ -1,4 +1,4 @@
const { SlashCommandBuilder } = require("discord.js");
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
ms = require("ms"),
moment = require("moment");
@ -60,15 +60,13 @@ class Remindme extends BaseCommand {
await interaction.deferReply({ ephemeral: true });
if (!data.userData.reminds) data.userData.reminds = [];
// TODO: rework this shit
const time = interaction.options.getString("time"),
message = interaction.options.getString("message"),
dateNow = Date.now();
const dateNow = Date.now();
const reminderData = {
message: message,
message: interaction.options.getString("message"),
createdAt: dateNow,
sendAt: dateNow + ms(time),
sendAt: dateNow + ms(interaction.options.getString("time")),
};
data.userData.reminds.push(reminderData);
@ -78,10 +76,26 @@ class Remindme extends BaseCommand {
client.databaseCache.usersReminds.set(interaction.user.id, data.userData);
interaction.success("general/remindme:SAVED", {
message,
time: moment(reminderData.sendAt).locale(interaction.getLocale()).format("Do MMMM YYYY, HH:mm:ss"),
}, { edit: true });
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("general/remindme:EMBED_SAVED"),
})
.addFields([
{
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,
},
])
.setColor(client.config.embed.color)
.setFooter(client.config.embed.footer);
interaction.editReply({
embeds: [embed],
});
}
}

View file

@ -27,14 +27,19 @@ module.exports.init = function (client) {
mustSent.forEach(r => {
const embed = new EmbedBuilder()
.setAuthor({
name: client.translate("general/remindme:TITLE"),
name: client.translate("general/remindme:EMBED_TITLE"),
})
.setDescription(
client.translate("general/remindme:CREATED", {
time: moment(r.createdAt).locale(client.defaultLanguage).format("dddd, Do MMMM YYYY, HH:mm:ss"),
}),
)
.addFields([
{
name: client.translate("general/remindme:EMBED_CREATED"),
value: moment(r.createdAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"),
inline: true,
},
{
name: client.translate("general/remindme:EMBED_TIME"),
value: moment(r.sendAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"),
inline: true,
},
{
name: client.translate("common:MESSAGE"),
value: r.message,

View file

@ -3,7 +3,8 @@
"USAGE": "[time] [message]",
"EXAMPLES": "remindme time:12h message:Use the command 'work'\nremindme time:5m message:Get the chicken from the freezer!",
"TIME": "Time (e.g., 10s, 5m, 2h, 1d, 3w)",
"SAVED": "Reminder `{{message}}` saved for **{{time}}**",
"TITLE": "Reminder from JaBa",
"CREATED": "Reminder created: **{{time}}**"
"EMBED_SAVED": "Remind saved!",
"EMBED_TIME": "Reminder was set to",
"EMBED_TITLE": "Remind",
"EMBED_CREATED": "Created"
}

View file

@ -3,7 +3,8 @@
"USAGE": "[time] [message]",
"EXAMPLES": "remindme time:12h message:Использовать команду work\nremindme time:5m message:Достать курицу из морозилки!",
"TIME": "Время (Например: 10s, 5m, 2h, 1d, 3w)",
"SAVED": "Напоминание `{{message}}` сохранено на **{{time}}**",
"TITLE": "Напоминание от JaBa",
"CREATED": "Напоминание создано: **{{time}}**"
"EMBED_SAVED": "Напоминание сохранено!",
"EMBED_TIME": "Сохранено на",
"EMBED_TITLE": "Напоминание",
"EMBED_CREATED": "Создано"
}

View file

@ -3,7 +3,8 @@
"USAGE": "[time] [message]",
"EXAMPLES": "remindme time:12h message:Використовувати команду work\nremindme time:5m message:Дістати курку з морозилки",
"TIME": "Час (Наприклад: 10s, 5m, 2h, 1d, 3w)",
"SAVED": "Нагадування `{{message}}` збережено на **{{time}}**",
"TITLE": "Нагадування від JaBa",
"CREATED": "Нагадування створено: **{{time}}**"
"EMBED_SAVED": "Нагадування збережено!",
"EMBED_TIME": "Створено на",
"EMBED_TITLE": "Нагадування",
"EMBED_CREATED": "Створено"
}