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-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA") })
|
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-03-26 18:31:19 +05:00
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("common:USER", null, "uk-UA") })
|
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"))
|
|
|
|
.setDescriptionLocalizations({ "uk": client.translate("common:USER", null, "uk-UA") })),
|
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("");
|
|
|
|
const percent = parseInt(string.substr(0, 2), 10);
|
|
|
|
|
|
|
|
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 14:58:41 +05:00
|
|
|
firstMember: firstMember.user.tag,
|
|
|
|
secondMember: secondMember.user.tag,
|
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;
|