diff --git a/status/ss13status.py b/status/ss13status.py index f1be8db..a2adbae 100644 --- a/status/ss13status.py +++ b/status/ss13status.py @@ -641,3 +641,34 @@ async def server_check_loop(self): #This will be used to cache statuses later next_check = datetime.utcfromtimestamp(now.timestamp() + check_time) log.debug("Done. Next check at {}".format(next_check.strftime("%Y-%m-%d %H:%M:%S"))) await asyncio.sleep(check_time) + + async def byond(self, ctx): + """ + Provides the current byond version + """ + port = await self.config.game_port() + msg = await self.config.offline_message() + server_url = await self.config.server_url() + try: + server = socket.gethostbyname(await self.config.server()) + data = await self.query_server(server, port) + except TypeError: + await ctx.send(f"Failed to get the server's status. Check that you have fully configured this cog using `{ctx.prefix}setstatus`.") + return + + if not data: #Server is not responding, send the offline message + embed=discord.Embed(title="__Server Status:__", description=f"Failed to get byond version", color=0xff0000) + await ctx.send(embed=embed) + + else: + byond_version = data['byond_version'] + byond_build = data['byond_build'] + embed=discord.Embed(color=0x26eaea) + embed.add_field(name="Version", value=byond_version + "." + byond_build, inline=True) + embed.add_field(name="Downgrade", value= '''Older versions: https://www.byond.com/download/build/''', inline=True) + + try: + await self.statusmsg.delete() + self.statusmsg = await ctx.send(embed=embed) + except(discord.DiscordException, AttributeError): + self.statusmsg = await ctx.send(embed=embed) \ No newline at end of file