Cleaned up code and used ES6 string templating

This commit is contained in:
AlexKvazos
2015-04-30 19:23:52 -05:00
parent 4b33fc3fff
commit c9af42d284
6 changed files with 46 additions and 30 deletions
+19
View File
@@ -0,0 +1,19 @@
module.exports = (socket) => {
socket.mcbot.on('error', (error) => {
// this is okay because the connection was ended
if (error.toString() === 'Error: write after end') return;
// log the error in the client's buffer
socket.emit('buffer:error', error);
// if the bot is logged in and/or is an entity, destroy it
if (socket.mcbot.entity) socket.mcbot.end();
// delete the bot
delete socket.mcbot;
});
};