2022-02-02 23:54:06 +05:00
|
|
|
|
// Thanks to simply-djs for this =)
|
|
|
|
|
|
2022-08-09 23:48:33 +05:00
|
|
|
|
const { EmbedBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle, ComponentType } = require("discord.js");
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
|
|
|
|
/**
|
2022-08-09 23:48:33 +05:00
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-07-26 17:20:10 +05:00
|
|
|
|
* @param {Array} options
|
2022-02-02 23:54:06 +05:00
|
|
|
|
*/
|
|
|
|
|
/**
|
2022-08-08 18:19:56 +05:00
|
|
|
|
slash => Boolean
|
|
|
|
|
userSlash => String
|
|
|
|
|
resultBtn => Boolean
|
|
|
|
|
embedFoot => String
|
|
|
|
|
embedColor => HexColor
|
|
|
|
|
timeoutEmbedColor => HexColor
|
|
|
|
|
xEmoji => (Emoji ID) String
|
|
|
|
|
oEmoji => (Emoji ID) String
|
|
|
|
|
idleEmoji => (Emoji ID) String
|
2022-02-02 23:54:06 +05:00
|
|
|
|
*/
|
2022-07-29 23:31:08 +05:00
|
|
|
|
async function tictactoe(interaction, options = {}) {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
// eslint-disable-next-line no-async-promise-executor
|
|
|
|
|
return new Promise(async (resolve) => {
|
|
|
|
|
try {
|
2022-07-29 23:31:08 +05:00
|
|
|
|
const { client } = interaction;
|
2022-02-02 23:54:06 +05:00
|
|
|
|
let opponent;
|
|
|
|
|
|
2022-07-29 23:31:08 +05:00
|
|
|
|
if (interaction.commandId) {
|
|
|
|
|
opponent = interaction.options.getUser(options.userSlash || "user");
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
|
|
|
|
if (!opponent)
|
2022-07-29 23:31:08 +05:00
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:NO_USER"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (opponent.bot)
|
2022-07-29 23:31:08 +05:00
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:BOT_USER"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-29 23:31:08 +05:00
|
|
|
|
if (opponent.id == (interaction.user ? interaction.user : interaction.author).id)
|
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:YOURSELF"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
2022-07-29 23:31:08 +05:00
|
|
|
|
} else if (!interaction.commandId) {
|
|
|
|
|
opponent = interaction.mentions.members.first()?.user;
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
|
|
|
|
if (!opponent)
|
2022-07-29 23:31:08 +05:00
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:NO_USER")
|
2022-02-02 23:54:06 +05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (opponent.bot)
|
2022-07-29 23:31:08 +05:00
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:BOT_USER"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-29 23:31:08 +05:00
|
|
|
|
if (opponent.id === interaction.member.id)
|
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:YOURSELF")
|
2022-02-02 23:54:06 +05:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 12:11:51 +05:00
|
|
|
|
const foot = options.embedFoot ? { text: options.embedFoot } : { text: "Удачи =)" };
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const acceptEmbed = new EmbedBuilder()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setTitle(interaction.translate("economy/tictactoe:REQUEST_WAIT", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
user: opponent.tag
|
|
|
|
|
}))
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setAuthor({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
name: (interaction.user ? interaction.user : interaction.author).tag,
|
|
|
|
|
iconURL: (interaction.user ? interaction.user : interaction.author).displayAvatarURL()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
})
|
|
|
|
|
.setColor(options.embedColor || "#075FFF")
|
2022-02-03 12:11:51 +05:00
|
|
|
|
.setFooter(foot)
|
|
|
|
|
.setTimestamp();
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const accept = new ButtonBuilder()
|
2022-08-08 18:19:56 +05:00
|
|
|
|
.setLabel(interaction.translate("common:ACCEPT"))
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.setStyle(ButtonStyle.Success)
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setCustomId("acceptttt");
|
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const decline = new ButtonBuilder()
|
2022-08-08 18:19:56 +05:00
|
|
|
|
.setLabel(interaction.translate("common:DECLINE"))
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.setStyle(ButtonStyle.Danger)
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setCustomId("declinettt");
|
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const accep = new ActionRowBuilder().addComponents([
|
2022-02-02 23:54:06 +05:00
|
|
|
|
accept,
|
|
|
|
|
decline
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
let m;
|
2022-07-29 23:31:08 +05:00
|
|
|
|
if (interaction.commandId) {
|
|
|
|
|
m = await interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:INVITE_USER", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
opponent: opponent.id
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [acceptEmbed],
|
|
|
|
|
components: [accep]
|
|
|
|
|
});
|
2022-07-29 23:31:08 +05:00
|
|
|
|
} else if (!interaction.commandId) {
|
|
|
|
|
m = await interaction.reply({
|
|
|
|
|
content: interaction.translate("economy/tictactoe:INVITE_USER", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
opponent: opponent.id
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [acceptEmbed],
|
|
|
|
|
components: [accep]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const collector = m.createMessageComponentCollector({
|
2022-08-09 23:48:33 +05:00
|
|
|
|
componentType: ComponentType.Button,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
time: 30000
|
|
|
|
|
});
|
2022-08-09 23:48:33 +05:00
|
|
|
|
collector.on("collect", async button => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
if (button.user.id !== opponent.id)
|
|
|
|
|
return button.reply({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:REQUEST_SEND", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
opponent: opponent.id
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (button.customId == "declinettt") {
|
|
|
|
|
button.deferUpdate();
|
|
|
|
|
return collector.stop("decline");
|
|
|
|
|
} else if (button.customId == "acceptttt") {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
button.deferUpdate();
|
2022-02-02 23:54:06 +05:00
|
|
|
|
collector.stop();
|
|
|
|
|
|
|
|
|
|
const fighters = [
|
2022-07-29 23:31:08 +05:00
|
|
|
|
(interaction.user ? interaction.user : interaction.author).id,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
opponent.id
|
|
|
|
|
].sort(() => (Math.random() > 0.5 ? 1 : -1));
|
|
|
|
|
|
|
|
|
|
const x_emoji = options.xEmoji || "❌";
|
|
|
|
|
const o_emoji = options.oEmoji || "⭕";
|
|
|
|
|
|
|
|
|
|
const dashmoji = options.idleEmoji || "➖";
|
|
|
|
|
|
|
|
|
|
const Args = {
|
|
|
|
|
user: 0,
|
|
|
|
|
a1: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
a2: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
a3: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
b1: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
b2: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
b3: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
c1: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
c2: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
},
|
|
|
|
|
c3: {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Secondary,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: dashmoji,
|
|
|
|
|
disabled: false
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const { ActionRowBuilder, ButtonBuilder } = require("discord.js");
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const epm = new EmbedBuilder()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setTitle(interaction.translate("economy/tictactoe:DESCRIPTION"))
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setColor(options.embedColor || "#075FFF")
|
|
|
|
|
.setFooter(foot)
|
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
|
|
let msg;
|
2022-07-29 23:31:08 +05:00
|
|
|
|
if (interaction.commandId) {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
msg = await interaction.editReply({
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WAITING", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
user: `<@${Args.userid}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
});
|
2022-07-29 23:31:08 +05:00
|
|
|
|
} else if (!interaction.commandId) {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
msg = await button.message.edit({
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WAITING", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
user: `<@${Args.userid}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await ttt(msg);
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-inner-declarations
|
|
|
|
|
async function ttt(m) {
|
|
|
|
|
Args.userid = fighters[Args.user];
|
|
|
|
|
const won = {
|
|
|
|
|
"<:O_:863314110560993340>": false,
|
|
|
|
|
"<:X_:863314044781723668>": false
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const a1 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.a1.style)
|
|
|
|
|
.setEmoji(Args.a1.emoji)
|
|
|
|
|
.setCustomId("a1")
|
|
|
|
|
.setDisabled(Args.a1.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const a2 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.a2.style)
|
|
|
|
|
.setEmoji(Args.a2.emoji)
|
|
|
|
|
.setCustomId("a2")
|
|
|
|
|
.setDisabled(Args.a2.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const a3 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.a3.style)
|
|
|
|
|
.setEmoji(Args.a3.emoji)
|
|
|
|
|
.setCustomId("a3")
|
|
|
|
|
.setDisabled(Args.a3.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const b1 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.b1.style)
|
|
|
|
|
.setEmoji(Args.b1.emoji)
|
|
|
|
|
.setCustomId("b1")
|
|
|
|
|
.setDisabled(Args.b1.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const b2 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.b2.style)
|
|
|
|
|
.setEmoji(Args.b2.emoji)
|
|
|
|
|
.setCustomId("b2")
|
|
|
|
|
.setDisabled(Args.b2.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const b3 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.b3.style)
|
|
|
|
|
.setEmoji(Args.b3.emoji)
|
|
|
|
|
.setCustomId("b3")
|
|
|
|
|
.setDisabled(Args.b3.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const c1 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.c1.style)
|
|
|
|
|
.setEmoji(Args.c1.emoji)
|
|
|
|
|
.setCustomId("c1")
|
|
|
|
|
.setDisabled(Args.c1.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const c2 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.c2.style)
|
|
|
|
|
.setEmoji(Args.c2.emoji)
|
|
|
|
|
.setCustomId("c2")
|
|
|
|
|
.setDisabled(Args.c2.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const c3 = new ButtonBuilder()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setStyle(Args.c3.style)
|
|
|
|
|
.setEmoji(Args.c3.emoji)
|
|
|
|
|
.setCustomId("c3")
|
|
|
|
|
.setDisabled(Args.c3.disabled);
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const a = new ActionRowBuilder().addComponents([a1, a2, a3]);
|
|
|
|
|
const b = new ActionRowBuilder().addComponents([b1, b2, b3]);
|
|
|
|
|
const c = new ActionRowBuilder().addComponents([c1, c2, c3]);
|
2022-02-02 23:54:06 +05:00
|
|
|
|
const buttons = [a, b, c];
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.b1.emoji == o_emoji &&
|
|
|
|
|
Args.c1.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a2.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c2.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == o_emoji &&
|
|
|
|
|
Args.b3.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c1.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.a2.emoji == o_emoji &&
|
|
|
|
|
Args.a3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.b1.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.b3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.c1.emoji == o_emoji &&
|
|
|
|
|
Args.c2.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (won["<:O_:863314110560993340>"] != false) {
|
|
|
|
|
if (Args.user == 0) {
|
|
|
|
|
const wonner = await client.users
|
|
|
|
|
.fetch(fighters[1])
|
|
|
|
|
.catch(console.error);
|
|
|
|
|
resolve(wonner);
|
|
|
|
|
|
|
|
|
|
if (options.resultBtn === true)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
components: buttons,
|
|
|
|
|
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("⭕");
|
|
|
|
|
});
|
|
|
|
|
else if (!options.resultBtn || options.resultBtn === false)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
`${interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})}\n\`\`\`\n${Args.a1.emoji
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.b1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.c1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n\`\`\``.replaceAll(
|
|
|
|
|
dashmoji,
|
|
|
|
|
"➖"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("⭕");
|
|
|
|
|
});
|
|
|
|
|
} else if (Args.user == 1) {
|
|
|
|
|
const wonner = await client.users
|
|
|
|
|
.fetch(fighters[0])
|
|
|
|
|
.catch(console.error);
|
|
|
|
|
resolve(wonner);
|
|
|
|
|
|
|
|
|
|
if (options.resultBtn === true)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
components: buttons,
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("⭕");
|
|
|
|
|
});
|
|
|
|
|
else if (!options.resultBtn || options.resultBtn === false)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
`${interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})}\n\`\`\`\n${Args.a1.emoji
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.b1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.c1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n\`\`\``.replaceAll(
|
|
|
|
|
dashmoji,
|
|
|
|
|
"➖"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("⭕");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == x_emoji &&
|
|
|
|
|
Args.b1.emoji == x_emoji &&
|
|
|
|
|
Args.c1.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a2.emoji == x_emoji &&
|
|
|
|
|
Args.b2.emoji == x_emoji &&
|
|
|
|
|
Args.c2.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == x_emoji &&
|
|
|
|
|
Args.b3.emoji == x_emoji &&
|
|
|
|
|
Args.c3.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == x_emoji &&
|
|
|
|
|
Args.b2.emoji == x_emoji &&
|
|
|
|
|
Args.c3.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == x_emoji &&
|
|
|
|
|
Args.b2.emoji == x_emoji &&
|
|
|
|
|
Args.c1.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == x_emoji &&
|
|
|
|
|
Args.a2.emoji == x_emoji &&
|
|
|
|
|
Args.a3.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.b1.emoji == x_emoji &&
|
|
|
|
|
Args.b2.emoji == x_emoji &&
|
|
|
|
|
Args.b3.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.c1.emoji == x_emoji &&
|
|
|
|
|
Args.c2.emoji == x_emoji &&
|
|
|
|
|
Args.c3.emoji == x_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:X_:863314044781723668>"] = true;
|
|
|
|
|
if (won["<:X_:863314044781723668>"] != false) {
|
|
|
|
|
if (Args.user == 0) {
|
|
|
|
|
const wonner = await client.users
|
|
|
|
|
.fetch(fighters[1])
|
|
|
|
|
.catch(console.error);
|
|
|
|
|
resolve(wonner);
|
|
|
|
|
|
|
|
|
|
if (options.resultBtn === true)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
components: buttons,
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("❌");
|
|
|
|
|
});
|
|
|
|
|
else if (!options.resultBtn || options.resultBtn === false)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
`${interaction.translate("economy/tictactoe:WON", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
winner: `<@${fighters[1]}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})}\n\`\`\`\n${Args.a1.emoji
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.b1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.c1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n\`\`\``.replaceAll(
|
|
|
|
|
dashmoji,
|
|
|
|
|
"➖"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("❌");
|
|
|
|
|
});
|
|
|
|
|
} else if (Args.user == 1) {
|
|
|
|
|
const wonner = await client.users
|
|
|
|
|
.fetch(fighters[0])
|
|
|
|
|
.catch(console.error);
|
|
|
|
|
resolve(wonner);
|
|
|
|
|
|
|
|
|
|
if (options.resultBtn === true)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
components: buttons,
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("❌");
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
`${interaction.translate("economy/tictactoe:WON", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
winner: fighters[0],
|
|
|
|
|
emoji: client.emojis.cache.get(o_emoji) || "⭕"
|
|
|
|
|
})}\n\`\`\`\n${Args.a1.emoji
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.b1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.c1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n\`\`\``.replaceAll(
|
|
|
|
|
dashmoji,
|
|
|
|
|
"➖"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react("❌");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m.edit({
|
|
|
|
|
content: `<@${Args.userid}>`,
|
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
interaction.translate("economy/tictactoe:WAITING", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
user: `<@${Args.userid}>`,
|
2022-02-03 12:11:51 +05:00
|
|
|
|
emoji: Args.user == 0 ? `${client.emojis.cache.get(o_emoji) || "⭕"}` : `${client.emojis.cache.get(x_emoji) || "❌"}`
|
|
|
|
|
})
|
2022-02-02 23:54:06 +05:00
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: [a, b, c]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const collector = m.createMessageComponentCollector({
|
2022-08-09 23:48:33 +05:00
|
|
|
|
componentType: ComponentType.Button,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
max: 1,
|
|
|
|
|
time: 30000
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-09 23:48:33 +05:00
|
|
|
|
collector.on("collect", b => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
if (b.user.id !== Args.userid) {
|
|
|
|
|
b.reply({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:CANT_PLAY"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ttt(m);
|
|
|
|
|
} else {
|
|
|
|
|
if (Args.user == 0) {
|
|
|
|
|
Args.user = 1;
|
|
|
|
|
Args[b.customId] = {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Success,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: o_emoji,
|
|
|
|
|
disabled: true
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
Args.user = 0;
|
|
|
|
|
Args[b.customId] = {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
style: ButtonStyle.Danger,
|
2022-02-02 23:54:06 +05:00
|
|
|
|
emoji: x_emoji,
|
|
|
|
|
disabled: true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
b.deferUpdate();
|
|
|
|
|
const map = (obj, fun) =>
|
|
|
|
|
Object.entries(obj).reduce(
|
|
|
|
|
(prev, [key, value]) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
[key]: fun(key, value)
|
2022-02-03 12:11:51 +05:00
|
|
|
|
}), {}
|
2022-02-02 23:54:06 +05:00
|
|
|
|
);
|
|
|
|
|
const objectFilter = (obj, predicate) =>
|
|
|
|
|
Object.keys(obj)
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.filter(key => predicate(obj[key]))
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.reduce((res, key) => ((res[key] = obj[key]), res), {});
|
|
|
|
|
const Brgs = objectFilter(
|
|
|
|
|
map(Args, (_, fruit) => fruit.emoji == dashmoji),
|
|
|
|
|
(num) => num == true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (Object.keys(Brgs).length == 0) {
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.b1.emoji == o_emoji &&
|
|
|
|
|
Args.c1.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a2.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c2.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == o_emoji &&
|
|
|
|
|
Args.b3.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a3.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.c1.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.a1.emoji == o_emoji &&
|
|
|
|
|
Args.a2.emoji == o_emoji &&
|
|
|
|
|
Args.a3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.b1.emoji == o_emoji &&
|
|
|
|
|
Args.b2.emoji == o_emoji &&
|
|
|
|
|
Args.b3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
if (
|
|
|
|
|
Args.c1.emoji == o_emoji &&
|
|
|
|
|
Args.c2.emoji == o_emoji &&
|
|
|
|
|
Args.c3.emoji == o_emoji
|
|
|
|
|
)
|
|
|
|
|
won["<:O_:863314110560993340>"] = true;
|
|
|
|
|
|
|
|
|
|
if (won["<:O_:863314110560993340>"] == true) return ttt(m);
|
|
|
|
|
else if (won["<:X_:863314044781723668>"] == true) return;
|
|
|
|
|
else {
|
|
|
|
|
ttt(m);
|
|
|
|
|
|
|
|
|
|
if (options.resultBtn === true)
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:TIE"),
|
|
|
|
|
embeds: [epm.setDescription(interaction.translate("economy/tictactoe:TIE_DESC"))]
|
2022-02-02 23:54:06 +05:00
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react(dashmoji);
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
return m
|
|
|
|
|
.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:TIE"),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [
|
|
|
|
|
epm.setDescription(
|
2022-07-29 23:31:08 +05:00
|
|
|
|
`${interaction.translate("economy/tictactoe:TIE_DESC")}!\n\`\`\`\n${Args.a1.emoji
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.a3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.b1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.b3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n${Args.c1.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c2.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")} | ${Args.c3.emoji
|
|
|
|
|
.replace(o_emoji, "⭕")
|
|
|
|
|
.replace(x_emoji, "❌")}\n\`\`\``.replaceAll(
|
|
|
|
|
dashmoji,
|
|
|
|
|
"➖"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
|
.then(m => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.react(dashmoji);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ttt(m);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
collector.on("end", (collected, reason) => {
|
|
|
|
|
if (collected.size === 0 && reason == "time")
|
|
|
|
|
m.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:NO_ANSWER", {
|
2022-08-09 23:48:33 +05:00
|
|
|
|
user: `<@${Args.userid}>`
|
2022-02-03 12:11:51 +05:00
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
components: []
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-26 00:21:26 +05:00
|
|
|
|
collector.on("end", (_, reason) => {
|
2022-02-02 23:54:06 +05:00
|
|
|
|
if (reason == "time") {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const embed = new EmbedBuilder()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setTitle(interaction.translate("economy/tictactoe:NO_ANSWER_TITLE"))
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setAuthor({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
name: (interaction.user ? interaction.user : interaction.author).tag,
|
|
|
|
|
iconURL: (interaction.user ? interaction.user : interaction.author).displayAvatarURL()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
})
|
|
|
|
|
.setColor(options.timeoutEmbedColor || "#C90000")
|
|
|
|
|
.setFooter(foot)
|
2022-02-03 12:11:51 +05:00
|
|
|
|
.setTimestamp()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setDescription(interaction.translate("economy/tictactoe:TIMES_UP"));
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.edit({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
content: interaction.translate("economy/tictactoe:NOT_ANSWERED", {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
user: opponent.id
|
|
|
|
|
}),
|
2022-02-02 23:54:06 +05:00
|
|
|
|
embeds: [embed],
|
|
|
|
|
components: []
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (reason == "decline") {
|
2022-07-31 17:08:00 +05:00
|
|
|
|
const embed = new EmbedBuilder()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setTitle(interaction.translate("economy/tictactoe:CANCELED"))
|
2022-02-02 23:54:06 +05:00
|
|
|
|
.setAuthor({
|
2022-07-29 23:31:08 +05:00
|
|
|
|
name: (interaction.user ? interaction.user : interaction.author).tag,
|
|
|
|
|
iconURL: (interaction.user ? interaction.user : interaction.author).displayAvatarURL()
|
2022-02-02 23:54:06 +05:00
|
|
|
|
})
|
|
|
|
|
.setColor(options.timeoutEmbedColor || "#C90000")
|
|
|
|
|
.setFooter(foot)
|
2022-02-03 12:11:51 +05:00
|
|
|
|
.setTimestamp()
|
2022-07-29 23:31:08 +05:00
|
|
|
|
.setDescription(interaction.translate("economy/tictactoe:CANCELED_DESC", {
|
2022-06-09 14:59:12 +05:00
|
|
|
|
user: opponent.id
|
2022-02-03 12:11:51 +05:00
|
|
|
|
}));
|
2022-02-02 23:54:06 +05:00
|
|
|
|
m.edit({
|
|
|
|
|
embeds: [embed],
|
|
|
|
|
components: []
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
2022-02-03 12:11:51 +05:00
|
|
|
|
console.log(`tictactoe | ERROR: ${err.stack}`);
|
2022-02-02 23:54:06 +05:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = tictactoe;
|