summaryrefslogtreecommitdiff
path: root/src/cmd/debug.js
blob: 1cc5343ef087bc3f315f07f2d5cfaf596d206a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const mcs = require('node-mcstatus');

module.exports.loadModule = function loadModule(bot) {
    bot.handler.endpoint('^ping$', [], (match, message) => {
        bot.createMessage(message.channel.id, 'Pong').catch(console.error);
    });

    bot.handler.endpoint('^server$', [], async (match, message) => {
        let results = await mcs.statusJava('minecraft1240.omgserv.com', 10004);

        let msg = `${results.players.online}/${results.players.max} connected:\n`;

        results.players.list.forEach(p => {
            msg += `- ${p.name_clean}\n`;
        });

        bot.createMessage(message.channel.id, msg);
    });
};