Advertisement
codelyon

Untitled

Nov 21st, 2019
21,838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {Client, RichEmbed } = require('discord.js')
  2.  
  3. const bot = new Client()
  4.  
  5. const ping = require('minecraft-server-util')
  6.  
  7. const token = 'YOUR TOKEN'
  8.  
  9. const PREFIX = '!'
  10.  
  11. bot.on('ready', () =>{
  12.     console.log('Bot has come online.')
  13. })
  14.  
  15. bot.on('message', message =>{
  16.  
  17.     let args = message.content.substring(PREFIX.length).split(' ')
  18.  
  19.     switch(args[0]){
  20.         case 'mc':
  21.  
  22.             if(!args[1]) return message.channel.send('You must type a minecraft server ip')
  23.             if(!args[2]) return message.channel.send('You must type a minecraft server port')
  24.  
  25.             ping(args[1], parseInt(args[2]), (error, reponse) =>{
  26.                 if(error) throw error
  27.                 const Embed = new RichEmbed()
  28.                 .setTitle('Server Status')
  29.                 .addField('Server IP', reponse.host)
  30.                 .addField('Server Version', reponse.version)
  31.                 .addField('Online Players', reponse.onlinePlayers)
  32.                 .addField('Max Players', reponse.maxPlayers)
  33.                
  34.                 message.channel.send(Embed)
  35.             })
  36.         break
  37.  
  38.     }
  39.  
  40. })
  41.  
  42. bot.login(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement