ddp Ignore own messages

This commit is contained in:
Lamp 2018-11-06 00:24:10 -08:00 committed by GitHub
parent b774b78409
commit 7b8a16e1cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@ var Discord = require('discord.js');
var ws;
var wasConnected = false;
var myId;
(function connect() {
ws = new WebSocket("wss://daydun.com:5012/?nick=%5Bdiscord.gg%2Fk44Eqha%5D");
@ -18,12 +19,15 @@ var wasConnected = false;
if (transmission.type == 'chat') {
let chatmsg = transmission.message;
if (chatmsg.type == "message") {
if (chatmsg.id != myId)
send2discord(`**${chatmsg.nick}:** ${chatmsg.content}`);
} else if (chatmsg.type == "join") {
send2discord(`__***${chatmsg.nick || chatmsg.id} joined.***__`);
} else if (chatmsg.type == "leave") {
send2discord(`__***${chatmsg.nick || chatmsg.id} left.***__`);
}
} else if (transmission.type == 'load') {
myId = transmission.id;
}
});
ws.on("error", error => console.error(error));