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"),
|
|
|
|
tictactoe = require("../../helpers/tictactoe");
|
|
|
|
|
|
|
|
class TicTacToe 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("tictactoe")
|
2023-06-06 22:48:46 +05:00
|
|
|
.setDescription(client.translate("fun/tictactoe:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("fun/tictactoe:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("fun/tictactoe:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-19 23:58:06 +05:00
|
|
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall])
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.Guild, InteractionContextType.PrivateChannel])
|
2023-07-05 00:58:06 +05:00
|
|
|
.addUserOption(option =>
|
|
|
|
option
|
|
|
|
.setName("user")
|
|
|
|
.setDescription(client.translate("common:USER"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:USER", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:USER", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true),
|
|
|
|
),
|
2022-08-09 23:48:33 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-09 23:48:33 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +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
|
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2024-09-19 23:58:06 +05:00
|
|
|
const winner = await tictactoe(interaction, {
|
2022-08-09 23:48:33 +05:00
|
|
|
resultBtn: true,
|
2024-09-19 23:58:06 +05:00
|
|
|
});
|
2022-08-09 23:48:33 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
const memberData = await client.getMemberData(winner.id, interaction.guildId);
|
|
|
|
memberData.money += 100;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
const info = {
|
|
|
|
user: interaction.translate("economy/transactions:TTT"),
|
|
|
|
amount: 100,
|
|
|
|
date: Date.now(),
|
|
|
|
type: "got",
|
|
|
|
};
|
2023-10-30 21:45:10 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
memberData.transactions.push(info);
|
2023-10-30 21:45:10 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
await memberData.save();
|
2022-08-09 23:48:33 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = TicTacToe;
|