- Katılım
- 10 Kas 2019
- Konular
- 225
- Mesajlar
- 1,057
- Çözümler
- 19
- Tepki puanı
- 1,048
- Puanları
- 8,710
Main Bölümüne (bot.js , server.js , index.js vb.)
Kod:
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('TOKENIN');
var request = require('request');
var mcCommand = '/minecraft'; // KOMUT
var mcIP = 'MC SERVER IP'; // MC SERVER İPNİZ
var mcPort = 25565; // PORTUNUZ (25565 NORMAL)
client.on('message', message => {
if (message.content === mcCommand) {
var url = 'http://mcapi.us/server/status?ip=' + mcIP + '&port=' + mcPort;
request(url, function(err, response, body) {
if(err) {
console.log(err);
return message.reply('Server Error Veriyor');
}
body = JSON.parse(body);
var status = '*Sunucu Şuanda Offline*';
if(body.online) {
status = 'Sunucu Aktif Üye **online** - ';
if(body.players.now) {
status += '**' + body.players.now + '** Kişi Oynuyor';
} else {
status += '*Oynayan Kimse Yok*';
}
}
message.reply(status);
});
}
});