This commit is contained in:
Jonny_Bro (Nikita) 2024-11-18 19:32:48 +05:00
parent 19ed241e76
commit 358253a4e3
Signed by: jonny_bro
GPG key ID: 3F1ECC04147E9BD8

View file

@ -16,7 +16,8 @@ const { ButtonBuilder, ActionRowBuilder, ButtonStyle, ComponentType } = require(
* @returns {Promise<import("discord.js").User>} * @returns {Promise<import("discord.js").User>}
*/ */
async function tictactoe(interaction, options = {}) { async function tictactoe(interaction, options = {}) {
return new Promise(resolve => { // eslint-disable-next-line no-async-promise-executor
return new Promise(async resolve => {
try { try {
const { client } = interaction; const { client } = interaction;
let opponent; let opponent;
@ -81,19 +82,20 @@ async function tictactoe(interaction, options = {}) {
const decline = new ButtonBuilder().setLabel(interaction.translate("common:DECLINE")).setStyle(ButtonStyle.Danger).setCustomId("declinettt"); const decline = new ButtonBuilder().setLabel(interaction.translate("common:DECLINE")).setStyle(ButtonStyle.Danger).setCustomId("declinettt");
const accep = new ActionRowBuilder().addComponents([accept, decline]); const accep = new ActionRowBuilder().addComponents([accept, decline]);
const m = interaction.reply({ const m = await interaction.reply({
content: interaction.translate("fun/tictactoe:INVITE_USER", { content: interaction.translate("fun/tictactoe:INVITE_USER", {
opponent: opponent.id, opponent: opponent.id,
}), }),
embeds: [acceptEmbed], embeds: [acceptEmbed],
components: [accep], components: [accep],
fetchReply: true, fetchReply: true,
}).then(m => m); });
const collector = m.createMessageComponentCollector({ const collector = m.createMessageComponentCollector({
componentType: ComponentType.Button, componentType: ComponentType.Button,
time: 30 * 1000, time: 30 * 1000,
}); });
collector.on("collect", async button => { collector.on("collect", async button => {
if (button.user.id !== opponent.id) if (button.user.id !== opponent.id)
return button.reply({ return button.reply({