Created
July 30, 2018 14:32
-
-
Save oddmario/cf36c476166baab88b4b6b98876f23be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Minecraft Server Status code for Discord.js | |
Author: https://github.com/mariolatiffathy | |
Usage: %mcserver IP:PORT | if PORT is not specified then 25565 will be used. | |
*/ | |
const { Client, Util } = require('discord.js'); | |
const Discord = require('discord.js'); | |
const client = new Client(); | |
var prefix = "%"; | |
const commands = { | |
'mcserver': (msg) => { | |
let serverip = msg.content.split(' ').splice(1).join(' '); | |
let serverip_fromfield = serverip.substring(0,serverip.indexOf(":")); | |
let serverport_fromfield = serverip.split(':')[1]; | |
if (!serverip) { | |
msg.channel.sendMessage(msg.author + " | No server IP entered. :x:"); | |
} else { | |
if (!serverip.includes(":")) { | |
serverip_final = serverip; | |
} else { | |
serverip_final = serverip_fromfield; | |
} | |
if (!serverport_fromfield) { | |
var serverport_final = "25565"; | |
} else { | |
var serverport_final = serverport_fromfield; | |
} | |
const embed = new Discord.RichEmbed() | |
.setTitle("Minecraft Server Status") | |
.setColor(0x00AE86) | |
.setFooter("Minecraft server status snippet by MarioLatifFathy#2793", "http://i.imgur.com/w1vhFSR.png") | |
.setImage("http://status.mclive.eu/Server/" + serverip_final + "/" + serverport_final + "/banner.png") | |
.setTimestamp() | |
.addField("Server IP", | |
serverip) | |
msg.channel.send({embed}); | |
} | |
} | |
}; | |
client.on('message', msg => { | |
if (!msg.content.startsWith(prefix)) return; | |
if (commands.hasOwnProperty(msg.content.toLowerCase().slice(prefix.length).split(' ')[0])) commands[msg.content.toLowerCase().slice(prefix.length).split(' ')[0]](msg); | |
}); | |
client.login("Your token here"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have Player And MOTD?