💄 some improvements
This commit is contained in:
parent
ec79a69eab
commit
a72a1dbaeb
@ -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" />
|
||||||
|
8
index.js
8
index.js
@ -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
12
main.js
@ -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')
|
||||||
|
Loading…
Reference in New Issue
Block a user