Compare commits

...

2 Commits

Author SHA1 Message Date
Adrian Amaglio
a72a1dbaeb 💄 some improvements 2020-04-02 18:01:29 +02:00
Adrian Amaglio
ec79a69eab Changed discord shortcuts bu actual emoji 2020-04-02 18:01:11 +02:00
4 changed files with 26 additions and 9 deletions

View File

@ -1,30 +1,30 @@
{
"oui": {
"prefix": ":thumbsup:",
"prefix": "👍",
"description": "Je suis daccord"
},
"non": {
"prefix": ":thumbsdown:",
"prefix": "👎",
"description": "Je ne suis pas daccord"
},
"parole": {
"prefix": ":raised_hand:",
"prefix": "",
"description": "Je veux parler"
},
"réponse": {
"prefix": ":raised_hands:",
"prefix": "🙌",
"description": "Je veux répondre rapidement"
},
"suffit": {
"prefix": ":octagonal_sign:",
"prefix": "🛑",
"description": "On tourne en rond"
},
"écoute": {
"prefix": ":hear_no_evil:",
"prefix": "🙉",
"description": "On ne sécoute pas"
},
"love": {
"prefix": ":heart_eyes:",
"prefix": "😍",
"description": "Jadore"
},
"dab": {

View File

@ -10,6 +10,7 @@
<main id="educbot-status">
<p v-if="connection">Connecté !</p>
<p v-else="">Non connecté !</p>
<p>{{message}}</p>
<ul>
<li v-for="(value, key) in reactions">
<!--<img src="https://discordapp.com/assets/08c0a077780263f3df97613e58e71744.svg" width="30px" />

View File

@ -2,6 +2,9 @@
require('dotenv').config();
const fs = require('fs');
/* Catch evry unhandled promise rejection */
process.on('unhandledRejection', error => console.error('Uncaught Promise Rejection', error));
/* Deep clone of objects */
const clonedeep = require('lodash.clonedeep')
@ -147,9 +150,14 @@ const client = new Discord.Client();
client.on('ready', () => {
console.log('Connected to Discord as ' + client.user.tag);
client.user.setAvatar('avatar.png')
client.user.setUsername('Educ-Bot')
});
/* Discord message center */
client.on('message', msg => {
//TODO
//const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*`);
//if (!prefixRegex.test(message.content)) return;
if (msg.content === '!educpop-enable') {
if (msg.channel.id in channels) {
msg.reply('Jécoute déjà ce canal texte.')

12
main.js
View File

@ -8,6 +8,7 @@ window.onload = function () {
ws_url: 'ws://localhost:8080',
reactions: {},
connection: false,
message: '',
},
created: function () {
var url = new URL(location.href)
@ -19,8 +20,15 @@ window.onload = function () {
}
this.ws = new WebSocket(this.ws_url)
this.ws.onmessage = (data) => {
this.reactions = JSON.parse(data.data)
console.log(this.reactions)
var reactions = JSON.parse(data.data)
if ('error' in reactions) {
this.message = 'Erreur ! '
if (reactions.error === "bad channel") {
this.message += 'Les identifiants sont incorrect ! Redemandez les à Educ-Bot avec la commande "!educpop-web"'
}
return
}
this.reactions = reactions
}
this.ws.onopen = () => {
this.sendWs('init')