2022-07-31 17:08:00 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand"),
|
|
|
|
md5 = require("md5");
|
|
|
|
|
|
|
|
class Lovecalc extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("lovecalc")
|
|
|
|
.setDescription(client.translate("fun/lovecalc:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("fun/lovecalc:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-07-31 17:08:00 +05:00
|
|
|
.addUserOption(option =>
|
|
|
|
option.setName("first_member")
|
|
|
|
.setDescription(client.translate("common:USER"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:USER", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:USER", null, "ru-RU"),
|
|
|
|
})
|
2022-07-31 17:08:00 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addUserOption(option =>
|
|
|
|
option.setName("second_member")
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescription(client.translate("common:USER"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:USER", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:USER", null, "ru-RU"),
|
|
|
|
})),
|
2022-07-31 17:08:00 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-07-31 17:08:00 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
2022-08-01 20:06:09 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-07-31 17:08:00 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const firstMember = interaction.options.getMember("first_member"),
|
|
|
|
secondMember = interaction.options.getMember("second_member") || interaction.member;
|
2022-07-31 17:08:00 +05:00
|
|
|
|
2023-01-09 01:39:13 +05:00
|
|
|
const members = [firstMember, secondMember].sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10)),
|
|
|
|
hash = md5(`${members[0].id}${members[1].user.username}${members[0].user.username}${members[1].id}`);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
|
|
|
const string = hash
|
|
|
|
.split("")
|
|
|
|
.filter(e => !isNaN(e))
|
|
|
|
.join("");
|
2023-06-15 19:46:27 +05:00
|
|
|
const percent = parseInt(string.slice(0, 2), 10);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
2022-12-15 21:02:38 +05:00
|
|
|
name: `❤️ ${interaction.translate("fun/lovecalc:DESCRIPTION")}`,
|
2022-07-31 17:08:00 +05:00
|
|
|
})
|
|
|
|
.setDescription(interaction.translate("fun/lovecalc:CONTENT", {
|
|
|
|
percent,
|
2023-05-31 19:57:57 +05:00
|
|
|
firstMember: firstMember.user.toString(),
|
|
|
|
secondMember: secondMember.user.toString(),
|
2022-07-31 17:08:00 +05:00
|
|
|
}))
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
2022-12-15 21:02:38 +05:00
|
|
|
text: client.config.embed.footer,
|
2022-07-31 17:08:00 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
interaction.reply({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-07-31 17:08:00 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Lovecalc;
|