Custom Command for MineCraft Server

I want to make a command that give certain info about a MineCraft server:

Command: !server
Response: Online players : […] Ping: […]

I can’t find a good website (custom api) to do this, they only website I found:
https://mcapi.ca/query/[server_name]/info

But I don’t know how to get the information out of this page into the command.


SSocialGamer

I could do something like that. Message me on Twitch so we can set it up

If you’re wanting to host your own API, meaning you have a website to host the php file to, you can just use this:

<?php
$MinecraftServer = $_GET["Server"];
if (empty($_GET["Server"]) || $_GET["Server"] == null)
{
    $MinecraftServer = "play.teegeecraft.net";
}
$MinecraftServerJson = json_decode(@file_get_contents("https://mcapi.ca/query/$MinecraftServer/info"), true);
if($MinecraftServerJson['status'] == null)
{
    echo ' Server "' . $MinecraftServer . '" is currently offline!';
}
else
{
    echo $MinecraftServer . ' has ';
    echo $MinecraftServerJson['players']['online'];
    echo '/';
    echo $MinecraftServerJson['players']['max'];
    echo ' players, with a ping of ';
    echo $MinecraftServerJson['ping'];
    echo 'ms.';
}
?>

All you’d have to do is edit line #5 $MinecraftServer = "play.teegeecraft.net"; and instead of the play.teegeecraft.net just add your own server, just make sure to keep the "" at either end of the server and the ; at the end. This API will also accommodate a user inputted server, but will fall back to a default if nothing is added after !server. So you can type “!server” and it’ll output the stats of whatever server is hardcoded in, or “!server whatever.server.you.want” and it’ll show the stats, if any of “whatever.server.you.want”.
Or if you don’t want/can’t host your own API, I’ll host this API for awhile. I have a site, just basically to host APIs. You can use this command to add the API into your NightBot

!addcom !server $(customapi http://owyn.us/APIs/MinecraftServerStatus.php?Server=$(query))

Just let me know what you plan on doing, if you want to use my solution, I’ll keep the API on my hosting, otherwise I’ll just delete it since I don’t play Minecraft.

1 Like

Thank you for answering my question. No I don’t have a server/website to host the API, so it would be very nice if you can host it on your website. This is for a Dutch channel so it would be nice if they respond of the command is Dutch :wink:
They server that would be the most requested is: ‘’ 193.111.140.158:28281 ‘’ So the new API would be:

I hope I adjusted it right. Thanks for helping me :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.