2022-08-09 23:48:33 +05:00
|
|
|
const { SlashCommandBuilder } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Birthdate extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("birthdate")
|
|
|
|
.setDescription(client.translate("economy/birthdate:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("economy/birthdate:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("economy/birthdate:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-08-26 00:21:26 +05:00
|
|
|
.addIntegerOption(option => option.setName("day")
|
|
|
|
.setDescription(client.translate("economy/birthdate:DAY"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("economy/birthdate:DAY", null, "uk-UA"),
|
|
|
|
"ru": client.translate("economy/birthdate:DAY", null, "ru-RU"),
|
|
|
|
})
|
2022-08-26 00:21:26 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addIntegerOption(option => option.setName("month")
|
|
|
|
.setDescription(client.translate("economy/birthdate:MONTH"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("economy/birthdate:MONTH", null, "uk-UA"),
|
|
|
|
"ru": client.translate("economy/birthdate:MONTH", null, "ru-RU"),
|
|
|
|
})
|
2022-08-26 00:21:26 +05:00
|
|
|
.setRequired(true)
|
2023-03-26 18:31:19 +05:00
|
|
|
.setChoices(
|
2023-06-15 19:46:27 +05:00
|
|
|
{ name: client.translate("economy/birthdate:JANUARY"), value: 1 },
|
|
|
|
{ name: client.translate("economy/birthdate:FEBRUARY"), value: 2 },
|
|
|
|
{ name: client.translate("economy/birthdate:MARCH"), value: 3 },
|
|
|
|
{ name: client.translate("economy/birthdate:APRIL"), value: 4 },
|
|
|
|
{ name: client.translate("economy/birthdate:MAY"), value: 5 },
|
|
|
|
{ name: client.translate("economy/birthdate:JUNE"), value: 6 },
|
|
|
|
{ name: client.translate("economy/birthdate:JULY"), value: 7 },
|
|
|
|
{ name: client.translate("economy/birthdate:AUGUST"), value: 8 },
|
|
|
|
{ name: client.translate("economy/birthdate:SEPTEMBER"), value: 9 },
|
|
|
|
{ name: client.translate("economy/birthdate:OCTOBER"), value: 10 },
|
|
|
|
{ name: client.translate("economy/birthdate:NOVEMBER"), value: 11 },
|
|
|
|
{ name: client.translate("economy/birthdate:DECEMBER"), value: 12 },
|
2022-08-26 00:21:26 +05:00
|
|
|
))
|
|
|
|
.addIntegerOption(option => option.setName("year")
|
|
|
|
.setDescription(client.translate("economy/birthdate:YEAR"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("economy/birthdate:YEAR", null, "uk-UA"),
|
|
|
|
"ru": client.translate("economy/birthdate:YEAR", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true)),
|
2022-08-09 23:48:33 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-09 23:48:33 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
* @param {Object} data
|
|
|
|
*/
|
|
|
|
async execute(client, interaction, data) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const day = interaction.options.getInteger("day"),
|
|
|
|
month = interaction.options.getInteger("month"),
|
2023-06-15 19:46:27 +05:00
|
|
|
year = interaction.options.getInteger("year"),
|
|
|
|
d = new Date(year, month - 1, day);
|
2022-08-09 23:48:33 +05:00
|
|
|
|
|
|
|
if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE");
|
|
|
|
if (d.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH");
|
|
|
|
if (d.getTime() < (Date.now() - 2.523e+12)) return interaction.error("economy/birthdate:DATE_TOO_LOW");
|
|
|
|
|
|
|
|
data.userData.birthdate = d;
|
2023-07-03 19:30:47 +05:00
|
|
|
data.userData.markModified("birthdate");
|
2022-08-09 23:48:33 +05:00
|
|
|
await data.userData.save();
|
|
|
|
|
|
|
|
interaction.success("economy/birthdate:SUCCESS", {
|
2023-05-30 15:28:41 +05:00
|
|
|
date: client.functions.printDate(client, d),
|
2022-08-09 23:48:33 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Birthdate;
|