bot: Fixed admin commands
All checks were successful
Build Docker / Build Master (push) Successful in 24s
Build Docker / Build Bot (push) Successful in 28s

This commit is contained in:
Nathan Woodburn 2023-08-24 11:33:02 +10:00
parent ffe95d87fc
commit 2a959b8f1f
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -18,7 +18,7 @@ tree = app_commands.CommandTree(client)
@tree.command(name="addworker", description="Adds a worker to the master server") @tree.command(name="addworker", description="Adds a worker to the master server")
async def addworker(ctx, ip: str, name: str): async def addworker(ctx, ip: str, name: str):
if ctx.author.id == ADMINID: if ctx.user.id == ADMINID:
r = requests.get(f"http://{Master_IP}:{Master_Port}/add-worker?worker={name}&ip={ip}",headers={"key":os.getenv('WORKER_KEY')}) r = requests.get(f"http://{Master_IP}:{Master_Port}/add-worker?worker={name}&ip={ip}",headers={"key":os.getenv('WORKER_KEY')})
if r.status_code == 200: if r.status_code == 200:
await ctx.response.send_message(f"Worker {name} added to the master server",ephemeral=True) await ctx.response.send_message(f"Worker {name} added to the master server",ephemeral=True)
@ -29,7 +29,7 @@ async def addworker(ctx, ip: str, name: str):
@tree.command(name="listworkers", description="Lists all workers on the master server") @tree.command(name="listworkers", description="Lists all workers on the master server")
async def listworkers(ctx): async def listworkers(ctx):
if ctx.author.id == ADMINID: if ctx.user.id == ADMINID:
r = requests.get(f"http://{Master_IP}:{Master_Port}/list-workers",headers={"key":os.getenv('WORKER_KEY')}) r = requests.get(f"http://{Master_IP}:{Master_Port}/list-workers",headers={"key":os.getenv('WORKER_KEY')})
if r.status_code == 200: if r.status_code == 200:
await ctx.response.send_message(r.text,ephemeral=True) await ctx.response.send_message(r.text,ephemeral=True)
@ -40,7 +40,7 @@ async def listworkers(ctx):
@tree.command(name="licence", description="Gets a licence key") @tree.command(name="licence", description="Gets a licence key")
async def license(ctx): async def license(ctx):
if ctx.author.id != ADMINID: if ctx.user.id != ADMINID:
await ctx.response.send_message("You do not have permission to use this command",ephemeral=True) await ctx.response.send_message("You do not have permission to use this command",ephemeral=True)
return return