Files
WorldCraft_Discord_Bot/cogs/servertatus.py
2020-09-29 21:27:19 +02:00

27 lines
849 B
Python

import discord
from discord.ext import commands
from mcstatus import MinecraftServer
class ServerStatus(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name="Ping", aliases=["Status"])
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))