mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-29 23:03:02 +05:00
Compare commits
3 commits
4aa0cfe9fa
...
f77913c007
Author | SHA1 | Date | |
---|---|---|---|
f77913c007 | |||
358253a4e3 | |||
19ed241e76 |
1 changed files with 11 additions and 48 deletions
|
@ -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,28 +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]);
|
||||||
|
|
||||||
let m;
|
const m = await interaction.reply({
|
||||||
if (interaction.commandId)
|
content: interaction.translate("fun/tictactoe:INVITE_USER", {
|
||||||
m = interaction.reply({
|
opponent: opponent.id,
|
||||||
content: interaction.translate("fun/tictactoe:INVITE_USER", {
|
}),
|
||||||
opponent: opponent.id,
|
embeds: [acceptEmbed],
|
||||||
}),
|
components: [accep],
|
||||||
embeds: [acceptEmbed],
|
fetchReply: true,
|
||||||
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({
|
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({
|
||||||
|
@ -267,9 +260,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("⭕");
|
|
||||||
});
|
});
|
||||||
else if (!options.resultBtn || options.resultBtn === false)
|
else if (!options.resultBtn || options.resultBtn === false)
|
||||||
return m
|
return m
|
||||||
|
@ -294,9 +284,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
components: [],
|
components: [],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("⭕");
|
|
||||||
});
|
});
|
||||||
} else if (Args.user == 1) {
|
} else if (Args.user == 1) {
|
||||||
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
||||||
|
@ -318,9 +305,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("⭕");
|
|
||||||
});
|
});
|
||||||
else if (!options.resultBtn || options.resultBtn === false)
|
else if (!options.resultBtn || options.resultBtn === false)
|
||||||
return m
|
return m
|
||||||
|
@ -345,9 +329,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
components: [],
|
components: [],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("⭕");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,9 +361,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("❌");
|
|
||||||
});
|
});
|
||||||
else if (!options.resultBtn || options.resultBtn === false)
|
else if (!options.resultBtn || options.resultBtn === false)
|
||||||
return m
|
return m
|
||||||
|
@ -406,9 +384,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
components: [],
|
components: [],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("❌");
|
|
||||||
});
|
});
|
||||||
} else if (Args.user == 1) {
|
} else if (Args.user == 1) {
|
||||||
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
const won = await client.users.fetch(fighters[0]).catch(console.error);
|
||||||
|
@ -430,9 +405,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("❌");
|
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
return m
|
return m
|
||||||
|
@ -456,9 +428,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
components: [],
|
components: [],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react("❌");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,9 +511,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
.edit({
|
.edit({
|
||||||
content: interaction.translate("fun/tictactoe:TIE"),
|
content: interaction.translate("fun/tictactoe:TIE"),
|
||||||
embeds: [epm.setDescription(interaction.translate("fun/tictactoe:TIE_DESC"))],
|
embeds: [epm.setDescription(interaction.translate("fun/tictactoe:TIE_DESC"))],
|
||||||
})
|
|
||||||
.then(m => {
|
|
||||||
m.react(dashmoji);
|
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
return m
|
return m
|
||||||
|
@ -563,9 +529,6 @@ async function tictactoe(interaction, options = {}) {
|
||||||
],
|
],
|
||||||
components: [],
|
components: [],
|
||||||
})
|
})
|
||||||
.then(m => {
|
|
||||||
m.react(dashmoji);
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue