mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-29 23:03:02 +05:00
Compare commits
No commits in common. "f77913c0070e0648a1e3f752b66730e86586969d" and "4aa0cfe9fad623d8027ce68648947dcba5795d0e" have entirely different histories.
f77913c007
...
4aa0cfe9fa
1 changed files with 48 additions and 11 deletions
|
@ -16,8 +16,7 @@ const { ButtonBuilder, ActionRowBuilder, ButtonStyle, ComponentType } = require(
|
|||
* @returns {Promise<import("discord.js").User>}
|
||||
*/
|
||||
async function tictactoe(interaction, options = {}) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async resolve => {
|
||||
return new Promise(resolve => {
|
||||
try {
|
||||
const { client } = interaction;
|
||||
let opponent;
|
||||
|
@ -82,20 +81,28 @@ async function tictactoe(interaction, options = {}) {
|
|||
const decline = new ButtonBuilder().setLabel(interaction.translate("common:DECLINE")).setStyle(ButtonStyle.Danger).setCustomId("declinettt");
|
||||
const accep = new ActionRowBuilder().addComponents([accept, decline]);
|
||||
|
||||
const m = await interaction.reply({
|
||||
content: interaction.translate("fun/tictactoe:INVITE_USER", {
|
||||
opponent: opponent.id,
|
||||
}),
|
||||
embeds: [acceptEmbed],
|
||||
components: [accep],
|
||||
fetchReply: true,
|
||||
});
|
||||
let m;
|
||||
if (interaction.commandId)
|
||||
m = interaction.reply({
|
||||
content: interaction.translate("fun/tictactoe:INVITE_USER", {
|
||||
opponent: opponent.id,
|
||||
}),
|
||||
embeds: [acceptEmbed],
|
||||
components: [accep],
|
||||
});
|
||||
else if (!interaction.commandId)
|
||||
m = interaction.reply({
|
||||
content: interaction.translate("fun/tictactoe:INVITE_USER", {
|
||||
opponent: opponent.id,
|
||||
}),
|
||||
embeds: [acceptEmbed],
|
||||
components: [accep],
|
||||
});
|
||||
|
||||
const collector = m.createMessageComponentCollector({
|
||||
componentType: ComponentType.Button,
|
||||
time: 30 * 1000,
|
||||
});
|
||||
|
||||
collector.on("collect", async button => {
|
||||
if (button.user.id !== opponent.id)
|
||||
return button.reply({
|
||||
|
@ -260,6 +267,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
}),
|
||||
),
|
||||
],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("⭕");
|
||||
});
|
||||
else if (!options.resultBtn || options.resultBtn === false)
|
||||
return m
|
||||
|
@ -284,6 +294,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
),
|
||||
],
|
||||
components: [],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("⭕");
|
||||
});
|
||||
} else if (Args.user == 1) {
|
||||
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
||||
|
@ -305,6 +318,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
}),
|
||||
),
|
||||
],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("⭕");
|
||||
});
|
||||
else if (!options.resultBtn || options.resultBtn === false)
|
||||
return m
|
||||
|
@ -329,6 +345,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
),
|
||||
],
|
||||
components: [],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("⭕");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -361,6 +380,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
}),
|
||||
),
|
||||
],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("❌");
|
||||
});
|
||||
else if (!options.resultBtn || options.resultBtn === false)
|
||||
return m
|
||||
|
@ -384,6 +406,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
),
|
||||
],
|
||||
components: [],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("❌");
|
||||
});
|
||||
} else if (Args.user == 1) {
|
||||
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
||||
|
@ -405,6 +430,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
}),
|
||||
),
|
||||
],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("❌");
|
||||
});
|
||||
else
|
||||
return m
|
||||
|
@ -428,6 +456,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
),
|
||||
],
|
||||
components: [],
|
||||
})
|
||||
.then(m => {
|
||||
m.react("❌");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -511,6 +542,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
.edit({
|
||||
content: interaction.translate("fun/tictactoe:TIE"),
|
||||
embeds: [epm.setDescription(interaction.translate("fun/tictactoe:TIE_DESC"))],
|
||||
})
|
||||
.then(m => {
|
||||
m.react(dashmoji);
|
||||
});
|
||||
else
|
||||
return m
|
||||
|
@ -529,6 +563,9 @@ async function tictactoe(interaction, options = {}) {
|
|||
],
|
||||
components: [],
|
||||
})
|
||||
.then(m => {
|
||||
m.react(dashmoji);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue