mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-18 20:33:28 +02:00
ES6 Stuff
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
module.exports = (socket) => {
|
||||
export default (socket) => {
|
||||
|
||||
function onChat(data) {
|
||||
let onChat = (data) => {
|
||||
if (socket.mcbot && socket.mcbot.entity) {
|
||||
socket.mcbot.chat(data.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
socket.on('chat', onChat);
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import mineflayer from 'mineflayer';
|
||||
import moment from 'moment';
|
||||
import events from '../../bot';
|
||||
|
||||
module.exports = (socket) => {
|
||||
export default (socket) => {
|
||||
|
||||
function onConnection(data) {
|
||||
let onConnection = (data) => {
|
||||
|
||||
let timestamp = moment().format('MMM D h:mm:ss a');
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = (socket) => {
|
||||
// bind bot events
|
||||
events(socket);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
socket.on('server:connect', onConnection);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
module.exports = (socket) => {
|
||||
export default (socket) => {
|
||||
|
||||
function onDisconnection() {
|
||||
let onDisconnection = () => {
|
||||
if (socket.mcbot) {
|
||||
socket.mcbot.end();
|
||||
delete socket.mcbot;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
socket.on('disconnect', onDisconnection);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module.exports = (socket) => {
|
||||
export default (socket) => {
|
||||
|
||||
function onPlayers() {
|
||||
let onPlayers = () => {
|
||||
if (socket.mcbot && socket.mcbot.players) {
|
||||
socket.emit('bot:players', socket.mcbot.players);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
socket.on('players', onPlayers);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = (io) => {
|
||||
export default (io) => {
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user