fix: wordwar - la liste des participants ne se mettait pas à jour

This commit is contained in:
Nemo 2021-11-15 11:51:56 +01:00
parent a5ed48a315
commit 9a9f7d3cc5
1 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@ var wwId = 1;
/** /**
* This function aims to do word wars inside a discord channel. * This function aims to do word wars inside a discord channel.
* Someone launches a wordwar and other people can join in by clicking on the react icon. * Someone launches a wrdwar and other people can join in by clicking on the react icon.
* First argument is the time of duration of the wordwar. * First argument is the time of duration of the wordwar.
* Second argument is the waiting time before the wordwar. * Second argument is the waiting time before the wordwar.
**/ **/
@ -85,7 +85,7 @@ module.exports = {
ongoingww.set(interaction.user.id, wwRole.name); ongoingww.set(interaction.user.id, wwRole.name);
interaction.member.roles.add(wwRole.id); interaction.member.roles.add(wwRole.id);
commandReply = "la " + wwRole.name + " a été initiée. Elle commencera dans " + wwdelay + " minutes et durera " + wwtimer + " minutes.\nInscrits : " + getRegistered(wwRole); const commandReply = getRegistered(wwRole.name,wwdelay,wwtimer);
const row = new MessageActionRow() const row = new MessageActionRow()
.addComponents( .addComponents(
@ -119,8 +119,8 @@ module.exports = {
OnlyReply('Vous êtes déjà enregistré.e dans la wordwar ' + ongoingww.get(i.user.id), i, wwRole); OnlyReply('Vous êtes déjà enregistré.e dans la wordwar ' + ongoingww.get(i.user.id), i, wwRole);
} else { } else {
i.member.roles.add(wwRole); i.member.roles.add(wwRole);
ongoingww.set(i.user.id, wwRole); ongoingww.set(i.user.id, wwRole.name);
i.message.edit(commandReply); i.message.edit(getRegistered(wwRole.name, wwdelay, wwtimer));
i.deferUpdate(); i.deferUpdate();
} }
}); });
@ -137,6 +137,7 @@ module.exports = {
} else { } else {
i.member.roles.remove(wwRole); i.member.roles.remove(wwRole);
ongoingww.delete(i.user.id); ongoingww.delete(i.user.id);
console.log(ongoingww);
i.deferUpdate(); i.deferUpdate();
// Si l'utilisateur qui annule est le dernier dans cette wordwar // Si l'utilisateur qui annule est le dernier dans cette wordwar
@ -154,7 +155,7 @@ module.exports = {
console.log(wwRole.name + ' canceled'); console.log(wwRole.name + ' canceled');
return; return;
}else{ }else{
i.message.edit(commandReply); i.message.edit(getRegistered(wwRole.name, wwdelay, wwtimer));
} }
} }
}); });
@ -203,13 +204,12 @@ function OnlyReply(str, int, ww) {
} }
} }
function getRegistered(ww) { function getRegistered(ww,d, t) {
var str = ""; var str = "";
ongoingww.forEach(async (value, key) => { ongoingww.forEach(async (value, key) => {
if (value == ww.name){ if (value == ww){
str += userMention(key) + ' '; str += userMention(key) + ' ';
} }
}); });
return str; return "la " + ww + " a été initiée. Elle commencera dans " + d + " minutes et durera " + t + " minutes.\nInscrits : " + str;
} }