fix and todos

This commit is contained in:
Adrian Amaglio 2020-03-31 10:54:11 +02:00
parent b500d7d485
commit af7e3d1557

12
educ.js
View File

@ -27,7 +27,7 @@ var reactions = {
'description': 'Je veux répondre rapidement', 'description': 'Je veux répondre rapidement',
}, },
'suffit': { 'suffit': {
'prefix': ':octogonal_sign:', 'prefix': ':octagonal_sign:',
'description': 'On tourne en rond', 'description': 'On tourne en rond',
}, },
'écoute': { 'é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 */ 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 => { client.on('message', msg => {
if(msg.content === '!educpop-reset') { if(msg.content === '!educpop-reset') { //TODO room parametrized
for (var index in reactions) { for (var index in reactions) {
reactions[index].people = [] reactions[index].people = []
} }
reply(msg) reply(msg)
msg.reply('La liste est vidée :)')
} }
else if (msg.content === '!educpop-enable') { else if (msg.content === '!educpop-enable') {
var id = msg.channel.id var id = msg.channel.id
@ -98,7 +97,7 @@ client.on('message', msg => {
/* Educ pop stuff */ /* Educ pop stuff */
else if(msg.content.startsWith('-')) { else if(msg.content.startsWith('-')) {
var content = msg.content.slice(1) var content = msg.content.slice(1)
if (content in reactions) { if (content.toLowerCase() in reactions) {
var reaction = reactions[content].people var reaction = reactions[content].people
var index = reaction.indexOf(msg.author.username) var index = reaction.indexOf(msg.author.username)
if (index >= 0) { if (index >= 0) {
@ -107,7 +106,7 @@ client.on('message', msg => {
reply(msg) reply(msg)
} }
} }
else if (msg.content in reactions) { else if (msg.content.toLowerCase() in reactions) {
var reaction = reactions[msg.content].people var reaction = reactions[msg.content].people
if (reaction.indexOf(msg.author.username) < 0) { if (reaction.indexOf(msg.author.username) < 0) {
reaction.push(msg.author.username) reaction.push(msg.author.username)
@ -123,6 +122,9 @@ function reply (msg) {
if (reactions[index].people.length > 0) if (reactions[index].people.length > 0)
text += '\n' + reactions[index].prefix + String(reactions[index].people) text += '\n' + reactions[index].prefix + String(reactions[index].people)
} }
if (text === '') {
text = 'Personne ne sest manifesté :/'
}
if(channels[msg.channel.id]) channels[msg.channel.id].delete() if(channels[msg.channel.id]) channels[msg.channel.id].delete()
msg.reply(text) msg.reply(text)