removed a file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
__pycache__
|
||||
DiscordVerifier/out
|
||||
local.db
|
||||
*.DS_Store
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
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):
|
||||
servers = {"Earth": "25568", "Moon": "25567"}
|
||||
ip = "81.82.224.207:"
|
||||
|
||||
# List of colours for the amount of servers that are online
|
||||
upColours = [discord.Colour.red(), discord.Colour.orange(), discord.Colour.green()]
|
||||
|
||||
embed = discord.Embed()
|
||||
embed.set_author(name="Status")
|
||||
|
||||
# Amount of servers that are online
|
||||
upCounter = 2
|
||||
|
||||
# Add field for all the servers (for-loop so nothing has to be changed for future servers)
|
||||
for server in servers:
|
||||
minecraftServer = MinecraftServer.lookup(ip + servers[server])
|
||||
|
||||
try:
|
||||
# Online
|
||||
latency = f":green_circle: Server replied in {minecraftServer.ping()}ms."
|
||||
except ConnectionRefusedError:
|
||||
# Offline
|
||||
upCounter -= 1
|
||||
latency = ":red_circle: Server is offline."
|
||||
embed.add_field(name=server, value=latency, inline=False)
|
||||
|
||||
# Set the embed colour
|
||||
embed.colour = upColours[upCounter]
|
||||
|
||||
# Bot's latency
|
||||
embed.add_field(name="WorldCraft Bot", value=f":green_circle: {round(self.client.latency * 1000)}ms")
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(ServerStatus(client))
|
||||
Reference in New Issue
Block a user