Merge pull request #1 from victormylle/server_status

Server status
This commit is contained in:
Stijn De Clercq
2020-09-29 21:25:15 +02:00
committed by GitHub

26
cogs/servertatus.py Normal file
View File

@@ -0,0 +1,26 @@
import discord
from discord.ext import commands
from mcstatus import MinecraftServer
class ServerStatus(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
#25568 -> Earth
#25567 -> Moon
server = MinecraftServer.lookup("81.82.224.207:25568")
try:
latency = server.ping()
embedVar = discord.Embed(title="", description="", color=0x00ff00)
embedVar.add_field(name="Server1", value="🟢 The Minecraft Server replied in {0} ms".format(latency), inline=False)
await ctx.send(embed=embedVar)
except ConnectionRefusedError:
await ctx.send("🔴 The Minecraft Server is offline")
def setup(client):
client.add_cog(ServerStatus(client))