mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-29 00:24:58 +05:00
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
const { SlashCommandBuilder } = require("discord.js");
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
class Divorce extends BaseCommand {
|
|
/**
|
|
*
|
|
* @param {import("../base/Client")} client
|
|
*/
|
|
constructor(client) {
|
|
super({
|
|
command: new SlashCommandBuilder()
|
|
.setName("divorce")
|
|
.setDescription(client.translate("economy/divorce:DESCRIPTION"))
|
|
.setDescriptionLocalizations({
|
|
uk: client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"),
|
|
ru: client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"),
|
|
})
|
|
.setDMPermission(false),
|
|
dirname: __dirname,
|
|
ownerOnly: false,
|
|
});
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {import("../../base/Client")} client
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
*/
|
|
async execute(client, interaction) {
|
|
const userData = interaction.data.user;
|
|
|
|
if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
|
|
const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover);
|
|
|
|
userData.lover = null;
|
|
|
|
userData.markModified("lover");
|
|
await userData.save();
|
|
|
|
const oldLover = await client.findOrCreateUser(user.id);
|
|
oldLover.lover = null;
|
|
|
|
oldLover.markModified("lover");
|
|
await oldLover.save();
|
|
|
|
interaction.success("economy/divorce:DIVORCED", {
|
|
user: user.toString(),
|
|
});
|
|
|
|
try {
|
|
user.send({
|
|
content: interaction.translate("economy/divorce:DIVORCED_U", {
|
|
user: interaction.member.toString(),
|
|
}),
|
|
});
|
|
} catch (e) { /**/ }
|
|
}
|
|
}
|
|
|
|
module.exports = Divorce;
|