From af7e3d155707b5daccd7b196084ca005dd57f9c6 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Tue, 31 Mar 2020 10:54:11 +0200 Subject: [PATCH] fix and todos --- educ.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/educ.js b/educ.js index 934b77f..26ec0c3 100644 --- a/educ.js +++ b/educ.js @@ -27,7 +27,7 @@ var reactions = { 'description': 'Je veux répondre rapidement', }, 'suffit': { - 'prefix': ':octogonal_sign:', + 'prefix': ':octagonal_sign:', 'description': 'On tourne en rond', }, 'écoute': { @@ -54,12 +54,11 @@ var channels = {} var last_post = null; /* On se souvient du derier post que ce bot a envoyé pour le virer dès que possible */ client.on('message', msg => { - if(msg.content === '!educpop-reset') { + if(msg.content === '!educpop-reset') { //TODO room parametrized for (var index in reactions) { reactions[index].people = [] } reply(msg) - msg.reply('La liste est vidée :)') } else if (msg.content === '!educpop-enable') { var id = msg.channel.id @@ -98,7 +97,7 @@ client.on('message', msg => { /* Educ pop stuff */ else if(msg.content.startsWith('-')) { var content = msg.content.slice(1) - if (content in reactions) { + if (content.toLowerCase() in reactions) { var reaction = reactions[content].people var index = reaction.indexOf(msg.author.username) if (index >= 0) { @@ -107,7 +106,7 @@ client.on('message', msg => { reply(msg) } } - else if (msg.content in reactions) { + else if (msg.content.toLowerCase() in reactions) { var reaction = reactions[msg.content].people if (reaction.indexOf(msg.author.username) < 0) { reaction.push(msg.author.username) @@ -123,6 +122,9 @@ function reply (msg) { if (reactions[index].people.length > 0) text += '\n' + reactions[index].prefix + String(reactions[index].people) } + if (text === '') { + text = 'Personne ne s’est manifesté :/' + } if(channels[msg.channel.id]) channels[msg.channel.id].delete() msg.reply(text)