Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
request(url, function (err, response, body) {
if (err) {
console.log(err);
return message.reply('Sorry, cannot get Mojang status at this time.');
};
body = JSON.parse(body);
//testOff = JSON.parse(testOffline);
const embed = new Discord.RichEmbed().addField(`${Object.keys(body[0])[0]}`, `${body[0]['minecraft.net'] ==="green" ? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //Minecraft.net
.addField(`${Object.keys(body[1])[0]}`, `${body[1]['session.minecraft.net'] === "green" ? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //session.minecraft.net
.addField(`${Object.keys(body[2])[0]}`, `${body[2]['account.mojang.com'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //account.mojang.com
.addField(`${Object.keys(body[3])[0]}`, `${body[3]['authserver.mojang.com'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //authserver.mojang.com
.addField(`${Object.keys(body[4])[0]}`, `${body[4]['sessionserver.mojang.com'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //sessionserver.mojang.com
.addField(`${Object.keys(body[5])[0]}`, `${body[5]['api.mojang.com'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //api.mojang.com
.addField(`${Object.keys(body[6])[0]}`, `${body[6]['textures.minecraft.net'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //textures.minecraft.net
.addField(`${Object.keys(body[7])[0]}`, `${body[7]['mojang.com'] ==="green"? '**Up And Online!** :white_check_mark: ' : '**Looks like the servers are having issues right now :x:**'}`) //mojang.com
.setThumbnail('https://vignette.wikia.nocookie.net/logopedia/images/d/d6/Mojang_ab_logo_vector.png/revision/latest?cb=20120306163913')
.setColor(config.green)
message.channel.send(embed);
});
};
async run (message) {
const data = await MojangAPI.getStatus()
return message.sendEmbed(new MessageEmbed()
.setColor('GREEN')
.setTitle('Status of Mojang services.')
.addField('Mojang.com', this.toEmoji(data[7]['mojang.com']), true)
.addField('Public API', this.toEmoji(data[5]['api.mojang.com']), true)
.addField('Minecraft.net', this.toEmoji(data[0]['minecraft.net']), true)
.addField('Minecraft skins', this.toEmoji(data[6]['textures.minecraft.net']), true)
.addField('Authentication service', this.toEmoji(data[3]['authserver.mojang.com']), true)
.addField('Mojang accounts website', this.toEmoji(data[2]['account.mojang.com']), true)
.addField('Multiplayer session service (Mojang)', this.toEmoji(data[4]['sessionserver.mojang.com']), true)
.addField('Multiplayer session service (Minecraft)', this.toEmoji(data[1]['session.minecraft.net']), true)
)
}
xhr.onload = function() {
var response = JSON.parse(xhr.responseText);
var status = {};
response.map(function(elem) {
var key = Object.keys(elem)[0];
status[key] = elem[key];
});
var textures_err = status["textures.minecraft.net"] !== "green";
var session_err = status["sessionserver.mojang.com"] !== "green";
if (textures_err || session_err) {
var warn = document.createElement("div");
warn.setAttribute("class", "alert alert-warning");
warn.setAttribute("role", "alert");
warn.innerHTML = "<h5>Mojang issues</h5> Mojang's servers are having trouble <i>right now</i>, this may affect requests at Crafatar. <small><a href="\"https://help.mojang.com\"">check status</a>";
document.querySelector("#alerts").appendChild(warn);
}
};
</small>