JaBa/commands/Fun/tictactoe.js

71 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-08-09 23:48:33 +05:00
const { SlashCommandBuilder } = require("discord.js");
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"),
})
.setDMPermission(false)
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
* @param {Object} data
*/
async execute(client, interaction) {
tictactoe(interaction, {
resultBtn: true,
embedColor: client.config.embed.color,
embedFoot: client.config.embed.footer,
2022-08-09 23:48:33 +05:00
}).then(async winner => {
const memberData = await client.findOrCreateMember({
id: winner.id,
guildId: interaction.guildId,
2022-08-09 23:48:33 +05:00
});
2022-10-09 14:26:22 +05:00
memberData.money += 100;
2022-08-09 23:48:33 +05:00
const info = {
user: interaction.translate("economy/transactions:TTT"),
amount: 100,
date: Date.now(),
type: "got",
2022-08-09 23:48:33 +05:00
};
2023-10-30 21:45:10 +05:00
2022-08-09 23:48:33 +05:00
memberData.transactions.push(info);
2023-10-30 21:45:10 +05:00
memberData.markModified("money");
memberData.markModified("transactions");
2023-10-30 21:45:10 +05:00
await memberData.save();
2022-08-09 23:48:33 +05:00
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = TicTacToe;