-
Notifications
You must be signed in to change notification settings - Fork 2
Feature channel subscribe #7
Feature channel subscribe #7
Conversation
Xstoudi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ptit résumé :
- Les messages du bot sont en français
- Mettre le chemin de la DB dans les variables d'environnement
- Ne pas spammer le channel dès que quelqu'un s'abonne/se désabonne. Si tu dois avoir un message d'erreur ou un message de confirmation, préfère les messages privés.
- Supprimer le message qui contient la commande (pour toutes les commandes)
config/prod.json
Outdated
| "JSKongress" | ||
| ] | ||
| ], | ||
| "subscriber": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cette config devrait être en variable d'environnement.
index.js
Outdated
| @@ -1,16 +1,24 @@ | |||
| require('dotenv').config() | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas nécessaire pour la prod, tu peux virer ça et ajouter les variables d'environnement dans ta commande.
src/commands/subscriber.js
Outdated
| channel: message.channel.name | ||
| }) | ||
| if (subscribedChannel !== null) { | ||
| return message.channel.send(`${message.author.username} already have subscribed to the channel \`#${message.channel.name}\``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'imagine que ce n'est pas la peine d'avertir la planète entière que le mec s'est abonné.
src/commands/subscriber.js
Outdated
| userId: message.author.id, | ||
| channel: message.channel.name | ||
| }) | ||
| return message.channel.send(`${message.author.username} has subscribed to the channel \`#${message.channel.name}\``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'imagine que ce n'est pas la peine d'avertir la planète entière que le mec s'est abonné.
src/commands/subscriber.js
Outdated
| userId: message.author.id | ||
| }) | ||
| if (subscribedChannels.length === 0) return message.channel.send('You haven\'t subscribed to a channel') | ||
| return message.channel.send(`${message.author.username} has subscribed to this channels :\n${subscribedChannels.map(a => `\`#${a.channel}\``).join('\n')}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'imagine que ce n'est pas la peine d'avertir la planète entière que le mec s'est abonné.
src/commands/subscriber.js
Outdated
| const subscribedChannels = subs.find({ | ||
| userId: message.author.id | ||
| }) | ||
| if (subscribedChannels.length === 0) return message.channel.send('You haven\'t subscribed to a channel') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'imagine que ce n'est pas la peine d'avertir la planète entière que le mec ne s'est pas abonné.
src/commands/subscriber.js
Outdated
| }) | ||
| if (subscribedChannel !== null) { | ||
| subs.remove(subscribedChannel) | ||
| return message.channel.send(`${message.author.username} has unsubscribed to the channel \`#${message.channel.name}\``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
src/commands/subscriber.js
Outdated
| subs.remove(subscribedChannel) | ||
| return message.channel.send(`${message.author.username} has unsubscribed to the channel \`#${message.channel.name}\``) | ||
| } | ||
| return message.channel.send(`${message.author.username} hasn't subscribed to the channel \`#${message.channel.name}\``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
src/commands/subscriber.js
Outdated
| channel: message.channel.name | ||
| }) | ||
| if (subscribersOnChannel.length === 0) { | ||
| return message.channel.send(`There is no subscribers for this channel.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
src/commands/subscriber.js
Outdated
| if (subscribersOnChannel.length === 0) { | ||
| return message.channel.send(`There is no subscribers for this channel.`) | ||
| } | ||
| return message.channel.send(`${args.join(' ')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supprimer le message qui contient la commande avant de faire ça.
|
Done |

Ajout des commandes:
!subscribe [list]: s'abonne à un channel / affiche la list des channel auxquels on est abonnés!unsubscribe: se désabonne a un channel!alert <message>: envoi une alerte a toutes les personnes aboonée a ce channel