feature: ajout de l'affichage des nomes des participants, mis à jour à chaque clic de bouton dans wordwar

This commit is contained in:
Nemo 2021-11-15 11:04:55 +01:00
parent aa96432be1
commit 86e61fa589
1 changed files with 19 additions and 4 deletions

View File

@ -81,11 +81,12 @@ module.exports = {
reason: "Rôle temporaire pour les wordwar"
};
var wwRole = await interaction.guild.roles.create(newRole);
console.log(wwRole);
wwId++;
ongoingww.set(interaction.user.id, wwRole.name);
interaction.member.roles.add(wwRole.id);
commandReply = "la " + wwRole.name + " a été initiée. Elle commencera dans " + wwdelay + " minutes et durera " + wwtimer + " minutes.";
commandReply = "la " + wwRole.name + " a été initiée. Elle commencera dans " + wwdelay + " minutes et durera " + wwtimer + " minutes.\nInscrits : " + getRegistered(wwRole);
const row = new MessageActionRow()
.addComponents(
@ -119,8 +120,9 @@ module.exports = {
OnlyReply('Vous êtes déjà enregistré.e dans la wordwar ' + ongoingww.get(i.user.id), i, wwRole);
} else {
i.member.roles.add(wwRole);
ongoingww.set(i.user.ida, wwRole);
OnlyReply('Participation enregistrée', i, wwRole);
ongoingww.set(i.user.id, wwRole);
i.message.edit(commandReply);
i.deferUpdate();
}
});
@ -134,9 +136,9 @@ module.exports = {
if (!i.member.roles.cache.has(wwRole.id)) {
OnlyReply('Vous n\'êtes pas enregistré pour cette wordwar', i, wwRole);
} else {
OnlyReply('Participation annulée', i, wwRole);
i.member.roles.remove(wwRole);
ongoingww.delete(i.user.id);
i.deferUpdate();
// Si l'utilisateur qui annule est le dernier dans cette wordwar
if (typeof ongoingww.find(wordWar => wordWar == wwRole.name) == "undefined") {
@ -152,6 +154,8 @@ module.exports = {
}
console.log(wwRole.name + ' canceled');
return;
}else{
i.message.edit(commandReply);
}
}
});
@ -198,4 +202,15 @@ function OnlyReply(str, int, ww) {
intTable.get(ww.name + int.user.id).editReply({ content: str, ephemeral: true, fetchReply: true });
int.deferUpdate();
}
}
function getRegistered(ww) {
var str = "";
ongoingww.forEach(async (value, key) => {
if (value == ww.name){
str += userMention(key) + ' ';
}
});
return str;
}