From b95af98c7448cba0c56aff7e4088d79d952cc945 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 13:56:13 +1000 Subject: [PATCH] bot: create site add parsing --- discord-bot/bot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/discord-bot/bot.py b/discord-bot/bot.py index f1ce7e1..9c91781 100644 --- a/discord-bot/bot.py +++ b/discord-bot/bot.py @@ -57,7 +57,7 @@ async def license(ctx): if r.status_code == 200: json = r.json() if json['success'] == "true": - await ctx.response.send_message(json['licence_key']) + await ctx.response.send_message("Licence: "+json['licence_key']) else: await ctx.response.send_message(f"Error getting license\n" + json['error']) else: @@ -65,11 +65,15 @@ async def license(ctx): @tree.command(name="createsite", description="Create a new WordPress site") async def createsite(ctx, domain: str, licence: str): - r = requests.get(f"http://{Master_IP}:{Master_Port}/create-site?domain={domain}",headers={"key":os.getenv('licence')}) + r = requests.post(f"http://{Master_IP}:{Master_Port}/new-site?domain={domain}",headers={"key":os.getenv('licence')}) if r.status_code == 200: - await ctx.response.send_message(r.text,ephemeral=False) + json = r.json() + if json['success'] == "true": + await ctx.response.send_message(f"Site {domain} creating...\nPlease send /siteinfo domain:{domain}") + else: + await ctx.response.send_message(f"Error creating site\n" + json['error']) else: - await ctx.response.send_message(f"Error creating site\n" + r.text,ephemeral=False) + await ctx.response.send_message(f"Error creating site\n" + r.text) # When the bot is ready