Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some dumb spaces, check ports, include starting status, update versions for testing (pylint) #47

Merged
merged 4 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8.16", "3.9.16", "3.10.10", "3.11.2"]
python-version: ["3.8.16", "3.9.16", "3.10.11", "3.11.3"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
11 changes: 10 additions & 1 deletion cogs/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from discord import Embed, utils as dutils
from utils import Utils


class Status(commands.Cog):
def __init__(self, bot):
self.bot = bot
Expand All @@ -27,6 +26,9 @@ async def status(self, ctx, serverip=None):
serverip += ".aternos.me"
if serverip.count(".") > 2:
return await ctx.respond("Please provide a valid Aternos server ip!\nExample: example.aternos.me")
if serverip.count(":") == 1:
if len(serverip.split(":")[1]) != 5:
return await ctx.respond("Please provide a valid Aternos server ip!\nExample: example.aternos.me")
await ctx.defer()
try:
stat = await wait_for(Utils.get_server_status(serverip), timeout=3)
Expand All @@ -46,6 +48,13 @@ async def status(self, ctx, serverip=None):
embed.colour = Utils.Colors.red
embed.timestamp = dutils.utcnow()
embed.set_footer(text="Command executed by " + ctx.author.name + "#" + ctx.author.discriminator)
elif stat.version.name == "§4● Starting":
embed.description = "We are not able to gather info from starting servers, sorry!\nProtocol Latency: " + str(
round(
stat.latency)) + "ms\n\nIf you believe this is wrong, please [join our discord server](https://discord.gg/G2AaJbvdHT)."
embed.colour = Utils.Colors.red
embed.timestamp = dutils.utcnow()
embed.set_footer(text="Command executed by " + ctx.author.name + "#" + ctx.author.discriminator)
else:
embed.add_field(name="**__Status__**", value="Online", inline=True)
embed.add_field(name="**__Players__**", value=str(stat.players.online) + "/" + str(stat.players.max),
Expand Down
3 changes: 0 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
bot.help_command = Utils.HelpCmd() # Disables the default help command
BOOTED = False


@bot.listen()
async def on_connect():
print('Connected to Discord!')
Expand All @@ -20,7 +19,6 @@ async def on_connect():
database.execute("CREATE TABLE IF NOT EXISTS server (guild_id VARCHAR(255) PRIMARY KEY, server_ip TEXT NOT NULL)")
database.close()


@bot.listen()
async def on_ready():
global BOOTED
Expand All @@ -32,5 +30,4 @@ async def on_ready():
print('------')
BOOTED = True


bot.run(data['Token'])