JaBa/commands/Fun/tictactoe.js

63 lines
1.8 KiB
JavaScript
Raw Permalink 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"),
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"))
.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"),
})
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,
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
*/
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;
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;