bug fix wordwar

This commit is contained in:
Nemo 2021-11-13 22:58:26 +01:00
parent 0ab0bcac22
commit ec95f1a24a

View File

@ -103,6 +103,9 @@ module.exports = {
interaction.reply({ content: commandReply, components: [row] }) interaction.reply({ content: commandReply, components: [row] })
.then(() => { .then(() => {
var publicReplies = undefined;
const filterParticipate = (btnInt) => btnInt.customId === 'primary'; const filterParticipate = (btnInt) => btnInt.customId === 'primary';
const collectorParticipate = interaction.channel.createMessageComponentCollector({ const collectorParticipate = interaction.channel.createMessageComponentCollector({
@ -128,7 +131,6 @@ module.exports = {
}); });
collectorCancel.on('collect', async i => { collectorCancel.on('collect', async i => {
console.log("pouet on passe combien de fois ici ?");
if (!i.member.roles.cache.has(wwRole.id)) { if (!i.member.roles.cache.has(wwRole.id)) {
OnlyReply('Vous n\'êtes pas enregistré pour cette wordwar', i, wwRole); OnlyReply('Vous n\'êtes pas enregistré pour cette wordwar', i, wwRole);
} else { } else {
@ -145,43 +147,39 @@ module.exports = {
wwRole.delete(); wwRole.delete();
collectorCancel.stop(); collectorCancel.stop();
collectorParticipate.stop(); collectorParticipate.stop();
if (publicReplies != undefined) {
publicReplies.delete();
}
console.log(wwRole.name + ' canceled');
return; return;
} }
} }
}); });
if (wwRole.deleted != true) {
setTimeout(async () => { setTimeout(async () => {
console.log('Wordwar launched'); if (wwRole.deleted != true) {
console.log(wwRole.name + ' launched');
var participantStart = '\nLa wordwar ' + wwRole.name + ' commence. Vous pouvez toujours la rejoindre si vous le désirez. Bonne chance à tou.te.s !! ' + roleMention(wwRole.id) + '\n'; var participantStart = '\nLa wordwar ' + wwRole.name + ' commence. Vous pouvez toujours la rejoindre si vous le désirez. Bonne chance à tou.te.s !! ' + roleMention(wwRole.id) + '\n';
var sentMsg = await interaction.channel.send({ content: participantStart, fetchReply: true }); publicReplies = await interaction.channel.send({ content: participantStart, fetchReply: true });
if (wwRole.deleted != true) {
setTimeout(async () => { setTimeout(async () => {
if (wwRole.deleted != true) { if (wwRole.deleted != true) {
console.log('Wordwar ended'); console.log(wwRole.name + ' ended');
var participantEnd = 'La wordwar ' + wwRole.name + ' est maintenant terminée, merci d\'y avoir participé \! ' + roleMention(wwRole.id) + '\n'; var participantEnd = 'La wordwar ' + wwRole.name + ' est maintenant terminée, merci d\'y avoir participé \! ' + roleMention(wwRole.id) + '\n';
interaction.channel.send(participantEnd); await interaction.channel.send({ content: participantEnd, fetchReply: true });
ongoingww.forEach(element => { ongoingww.forEach((value,key,ongoingww) => {
if (element.value == wwRole.name) { if (value == wwRole.name) {
element.delete(); ongoingww.delete(key);
} }
collectorCancel.stop();
collectorParticipate.stop();
}); });
setTimeout(() => { setTimeout(() => {
wwRole.delete(); wwRole.delete();
collectorCancel.stop();
collectorParticipate.stop();
}, 30 * 1000); // Wait 30 seconds to delete the role }, 30 * 1000); // Wait 30 seconds to delete the role
} else {
sentMsg.delete();
console.log('Wordwar canceled');
} }
}, wwtimer * 1000); }, wwtimer * 1000);
} else {
sentMsg.delete();
console.log('Wordwar canceled');
} }
}, wwdelay * 1000); }, wwdelay * 1000);
}
}); });
/* } /* }
*/ } */ }
@ -197,7 +195,7 @@ function OnlyReply(str, int, ww) {
intTable.set(ww.name + int.user.id, int); intTable.set(ww.name + int.user.id, int);
int.reply({ content: str, ephemeral: true }); int.reply({ content: str, ephemeral: true });
} else { } else {
intTable.get(ww.name + int.user.id).editReply({ content: str, ephemeral: true }); intTable.get(ww.name + int.user.id).editReply({ content: str, ephemeral: true, fetchReply: true });
int.deferUpdate(); int.deferUpdate();
} }
} }