1
0
Fork 0
mirror of https://github.com/JonnyBro/JaBa.git synced 2024-12-23 03:43:03 +05:00
JaBa/commands/Economy/divorce.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-09-19 23:58:06 +05:00
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
2022-08-09 23:48:33 +05:00
const BaseCommand = require("../../base/BaseCommand");
class Divorce extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
2022-08-09 23:48:33 +05:00
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("divorce")
.setDescription(client.translate("economy/divorce:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"),
})
2024-09-19 23:58:06 +05:00
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
2024-09-14 19:52:56 +05:00
.setContexts([InteractionContextType.Guild]),
2022-08-09 23:48:33 +05:00
dirname: __dirname,
ownerOnly: false,
2022-08-09 23:48:33 +05:00
});
}
2022-08-09 23:48:33 +05:00
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
2022-08-09 23:48:33 +05:00
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
2024-02-09 23:26:57 +05:00
async execute(client, interaction) {
const userData = interaction.data.user;
2022-08-09 23:48:33 +05:00
2024-02-09 23:26:57 +05:00
if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover);
2024-02-09 23:26:57 +05:00
userData.lover = null;
await userData.save();
2022-08-09 23:48:33 +05:00
const oldLover = await client.getUserData(user.id);
2022-08-09 23:48:33 +05:00
oldLover.lover = null;
2022-08-09 23:48:33 +05:00
await oldLover.save();
interaction.success("economy/divorce:DIVORCED", {
user: user.toString(),
2022-08-09 23:48:33 +05:00
});
2024-02-09 23:26:57 +05:00
try {
user.send({
content: interaction.translate("economy/divorce:DIVORCED_U", {
user: interaction.member.toString(),
}),
});
} catch (e) { /**/ }
2022-08-09 23:48:33 +05:00
}
}
2023-07-05 00:58:06 +05:00
module.exports = Divorce;