Skip to content

Commit

Permalink
Adds hostname support for the status cog
Browse files Browse the repository at this point in the history
  • Loading branch information
Crossedfall committed May 25, 2019
1 parent ed1f18e commit 4974a0a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions status/ss13status.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ async def server(self, ctx, host: str):
Sets the server IP used for status checks, defaults to localhost
"""
try:
ipaddress.ip_address(host) # Confirms that the IP provided is valid. If the IP is not valid, a ValueError is thrown.
await self.config.server.set(host)
await ctx.send(f"Server set to `{host}`")
except(ValueError):
await ctx.send(f"`{host}` is not a valid IP address!")
await ctx.send(f"Server set to: `{host}`")
except (ValueError, KeyError, AttributeError):
await ctx.send("There was an error setting the host! Please check your entry and try again.")

@setstatus.command()
@checks.is_owner()
Expand Down Expand Up @@ -235,7 +234,7 @@ async def players(self, ctx):
"""
Lists the current players on the server
"""
server = await self.config.server()
server = socket.gethostbyname(await self.config.server())
port = await self.config.game_port()
data = await self.query_server(server,port,"?whoIs")

Expand All @@ -257,7 +256,7 @@ async def adminwho(self, ctx):
"""
List the current admins on the server
"""
server = await self.config.server()
server = socket.gethostbyname(await self.config.server())
port = await self.config.game_port()
data = await self.query_server(server,port,"?getAdmins")

Expand All @@ -282,7 +281,7 @@ async def status(self, ctx):
"""
Gets the current server status and round details
"""
server = await self.config.server()
server = socket.gethostbyname(await self.config.server())
port = await self.config.game_port()
msg = await self.config.offline_message()
server_url = await self.config.server_url()
Expand Down

0 comments on commit 4974a0a

Please sign in to comment.