mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
reminder rework
This commit is contained in:
parent
f33ff35e4b
commit
57b4acc540
6 changed files with 49 additions and 27 deletions
|
@ -45,7 +45,7 @@ class Afk extends BaseCommand {
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction, data) {
|
async execute(client, interaction, data) {
|
||||||
interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
const reason = interaction.options.getString("message");
|
const reason = interaction.options.getString("message");
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { SlashCommandBuilder } = require("discord.js");
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||||
const BaseCommand = require("../../base/BaseCommand"),
|
const BaseCommand = require("../../base/BaseCommand"),
|
||||||
ms = require("ms"),
|
ms = require("ms"),
|
||||||
moment = require("moment");
|
moment = require("moment");
|
||||||
|
@ -60,15 +60,13 @@ class Remindme extends BaseCommand {
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
if (!data.userData.reminds) data.userData.reminds = [];
|
if (!data.userData.reminds) data.userData.reminds = [];
|
||||||
// TODO: rework this shit
|
|
||||||
const time = interaction.options.getString("time"),
|
const dateNow = Date.now();
|
||||||
message = interaction.options.getString("message"),
|
|
||||||
dateNow = Date.now();
|
|
||||||
|
|
||||||
const reminderData = {
|
const reminderData = {
|
||||||
message: message,
|
message: interaction.options.getString("message"),
|
||||||
createdAt: dateNow,
|
createdAt: dateNow,
|
||||||
sendAt: dateNow + ms(time),
|
sendAt: dateNow + ms(interaction.options.getString("time")),
|
||||||
};
|
};
|
||||||
|
|
||||||
data.userData.reminds.push(reminderData);
|
data.userData.reminds.push(reminderData);
|
||||||
|
@ -78,10 +76,26 @@ class Remindme extends BaseCommand {
|
||||||
|
|
||||||
client.databaseCache.usersReminds.set(interaction.user.id, data.userData);
|
client.databaseCache.usersReminds.set(interaction.user.id, data.userData);
|
||||||
|
|
||||||
interaction.success("general/remindme:SAVED", {
|
const embed = new EmbedBuilder()
|
||||||
message,
|
.setAuthor({
|
||||||
time: moment(reminderData.sendAt).locale(interaction.getLocale()).format("Do MMMM YYYY, HH:mm:ss"),
|
name: interaction.translate("general/remindme:EMBED_SAVED"),
|
||||||
}, { edit: true });
|
})
|
||||||
|
.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],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,19 @@ module.exports.init = function (client) {
|
||||||
mustSent.forEach(r => {
|
mustSent.forEach(r => {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.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([
|
.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"),
|
name: client.translate("common:MESSAGE"),
|
||||||
value: r.message,
|
value: r.message,
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"USAGE": "[time] [message]",
|
"USAGE": "[time] [message]",
|
||||||
"EXAMPLES": "remindme time:12h message:Use the command 'work'\nremindme time:5m message:Get the chicken from the freezer!",
|
"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)",
|
"TIME": "Time (e.g., 10s, 5m, 2h, 1d, 3w)",
|
||||||
"SAVED": "Reminder `{{message}}` saved for **{{time}}**",
|
"EMBED_SAVED": "Remind saved!",
|
||||||
"TITLE": "Reminder from JaBa",
|
"EMBED_TIME": "Reminder was set to",
|
||||||
"CREATED": "Reminder created: **{{time}}**"
|
"EMBED_TITLE": "Remind",
|
||||||
|
"EMBED_CREATED": "Created"
|
||||||
}
|
}
|
|
@ -3,7 +3,8 @@
|
||||||
"USAGE": "[time] [message]",
|
"USAGE": "[time] [message]",
|
||||||
"EXAMPLES": "remindme time:12h message:Использовать команду work\nremindme time:5m message:Достать курицу из морозилки!",
|
"EXAMPLES": "remindme time:12h message:Использовать команду work\nremindme time:5m message:Достать курицу из морозилки!",
|
||||||
"TIME": "Время (Например: 10s, 5m, 2h, 1d, 3w)",
|
"TIME": "Время (Например: 10s, 5m, 2h, 1d, 3w)",
|
||||||
"SAVED": "Напоминание `{{message}}` сохранено на **{{time}}**",
|
"EMBED_SAVED": "Напоминание сохранено!",
|
||||||
"TITLE": "Напоминание от JaBa",
|
"EMBED_TIME": "Сохранено на",
|
||||||
"CREATED": "Напоминание создано: **{{time}}**"
|
"EMBED_TITLE": "Напоминание",
|
||||||
|
"EMBED_CREATED": "Создано"
|
||||||
}
|
}
|
|
@ -3,7 +3,8 @@
|
||||||
"USAGE": "[time] [message]",
|
"USAGE": "[time] [message]",
|
||||||
"EXAMPLES": "remindme time:12h message:Використовувати команду work\nremindme time:5m message:Дістати курку з морозилки",
|
"EXAMPLES": "remindme time:12h message:Використовувати команду work\nremindme time:5m message:Дістати курку з морозилки",
|
||||||
"TIME": "Час (Наприклад: 10s, 5m, 2h, 1d, 3w)",
|
"TIME": "Час (Наприклад: 10s, 5m, 2h, 1d, 3w)",
|
||||||
"SAVED": "Нагадування `{{message}}` збережено на **{{time}}**",
|
"EMBED_SAVED": "Нагадування збережено!",
|
||||||
"TITLE": "Нагадування від JaBa",
|
"EMBED_TIME": "Створено на",
|
||||||
"CREATED": "Нагадування створено: **{{time}}**"
|
"EMBED_TITLE": "Нагадування",
|
||||||
|
"EMBED_CREATED": "Створено"
|
||||||
}
|
}
|
Loading…
Reference in a new issue