Kod Ne işe yarıyor: minecraft sunucu bilgilerini görmeye yarar
Gerekli Modüller: request
Kod:
Bot.js - Server.js içine atılacaktır
PHP Kod:
client.on("message", async message => {
const args = message.content.slice("!").trim().split(/ +/g);
if (message.content.toLowerCase().startsWith(`!mc`)) {
if(!args[1]){
message.channel.send("Sunucu ipsi yazmalısın!")
}
if(args[1]){
var url = 'https://mcapi.xdefcon.com/server/' + args[1] + '/full/json'
request(url, function (err, response, body) {
if (err) {
console.log(err);
const embed1 = new Discord.RicEmbed()
.setTitle("Hata!")
.setDescription(`Sunucu bilgilerini alırken hata oluştu!`)
.setColor("RED")
.setTimestamp()
.setFooter("Tarih");
return message.channel.send(embed1)
}
body = JSON.parse(body);
if(body.serverStatus == "offline"){
const embed2 = new Discord.RichEmbed()
.setColor("RED")
.setAuthor("Hata!")
.setDescription(`Bu sunucu aktif değil veya ip yanlış girdin!`)
.setTimestamp()
.setFooter("Tarih");
message.channel.send(embed2)
}
if(body.serverStatus == "online"){
const embed = new Discord.RichEmbed()
.setColor("RANDOM")
.setAuthor(`Minecraft Sunucu Bilgileri`)
.addField(`:rocket: İp Adresi`, "" + body.serverip, true)
.addField(`:satellite: Port`, "25565",false)
.addField(`:alarm_clock: Ping`, body.ping,false)
.addField(`:dolls: Oyuncu Sayısı`, body.players + "/" + body.maxplayers,true)
.setImage(`http://status.mclive.eu/Sunucu%20Durumu/${body.serverip}/25565/banner.png`)
.setTimestamp()
.setFooter("Tarih");
message.channel.send(embed)
}
});
}
}
});
)

