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

View File

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

View File

@ -2,6 +2,9 @@
require('dotenv').config(); require('dotenv').config();
const fs = require('fs'); const fs = require('fs');
/* Catch evry unhandled promise rejection */
process.on('unhandledRejection', error => console.error('Uncaught Promise Rejection', error));
/* Deep clone of objects */ /* Deep clone of objects */
const clonedeep = require('lodash.clonedeep') const clonedeep = require('lodash.clonedeep')
@ -147,9 +150,14 @@ const client = new Discord.Client();
client.on('ready', () => { client.on('ready', () => {
console.log('Connected to Discord as ' + client.user.tag); console.log('Connected to Discord as ' + client.user.tag);
client.user.setAvatar('avatar.png') client.user.setAvatar('avatar.png')
client.user.setUsername('Educ-Bot')
}); });
/* Discord message center */ /* Discord message center */
client.on('message', msg => { 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.content === '!educpop-enable') {
if (msg.channel.id in channels) { if (msg.channel.id in channels) {
msg.reply('Jécoute déjà ce canal texte.') 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', ws_url: 'ws://localhost:8080',
reactions: {}, reactions: {},
connection: false, connection: false,
message: '',
}, },
created: function () { created: function () {
var url = new URL(location.href) var url = new URL(location.href)
@ -19,8 +20,15 @@ window.onload = function () {
} }
this.ws = new WebSocket(this.ws_url) this.ws = new WebSocket(this.ws_url)
this.ws.onmessage = (data) => { this.ws.onmessage = (data) => {
this.reactions = JSON.parse(data.data) var reactions = JSON.parse(data.data)
console.log(this.reactions) 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.ws.onopen = () => {
this.sendWs('init') this.sendWs('init')