From ba6243bc8414e2856686afc76e56fc7a48e8c895 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Mon, 23 Aug 2021 19:33:25 -0500 Subject: [PATCH] update --- elhf.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/elhf.py b/elhf.py index 2486f3d..927dade 100644 --- a/elhf.py +++ b/elhf.py @@ -1,10 +1,10 @@ import requests - +import json def add_command(payload, version="8", app_id="172146408801959936", auth="Bot MTcyMTQ3NTcyMjY4NDY2MTc3.VxbS6w.cAmL2HkGmy58vS-nUdrL2w3Hcto"): - url = f"https://discord.com/api/v${version}/applications/${app_id}/commands" - + url = f"https://discord.com/api/v{version}/applications/{app_id}/commands" + print(url) # For authorization, you can use either your bot token headers = { "Authorization": auth @@ -15,11 +15,58 @@ def add_command(payload, version="8", app_id="172146408801959936", auth="Bot MTc def delete_command(command_id, version="8", app_id="172146408801959936", auth="Bot MTcyMTQ3NTcyMjY4NDY2MTc3.VxbS6w.cAmL2HkGmy58vS-nUdrL2w3Hcto"): - url = f"https://discord.com/api/v${version}/applications/${app_id}/commands/${command_id}" + url = f"https://discord.com/api/v{version}/applications/{app_id}/commands/{command_id}" # For authorization, you can use either your bot token headers = { "Authorization": auth } - r = requests.post(url, headers=headers) - print(r.content) \ No newline at end of file + r = requests.delete(url, headers=headers) + print(r.content) + +def update_command(command_id, payload, version="8", app_id="172146408801959936", auth="Bot MTcyMTQ3NTcyMjY4NDY2MTc3.VxbS6w.cAmL2HkGmy58vS-nUdrL2w3Hcto"): + url = f"https://discord.com/api/v{version}/applications/{app_id}/commands/{command_id}" + # For authorization, you can use either your bot token + headers = { + "Authorization": auth + } + + r = requests.patch(url, headers=headers, json=payload) + print(r.content) + +def get_commands(version="8", app_id="172146408801959936", auth="Bot MTcyMTQ3NTcyMjY4NDY2MTc3.VxbS6w.cAmL2HkGmy58vS-nUdrL2w3Hcto"): + url = f"https://discord.com/api/v{version}/applications/{app_id}/commands" + # For authorization, you can use either your bot token + headers = { + "Authorization": auth + } + + r = requests.get(url, headers=headers) + #print(r.content) + resp = r.content.decode("utf-8") + return json.loads(resp) + +command_dict = { + "name": "roll", + "description": "roll a dice", + "options": [ + { + "name": "dice", + "description": "The number of dice to roll use , for multiple groups of dice ex: 2,5,10", + "type": 3, + "required": False + }, + { + "name": "sides", + "description": "How many sides the dice have use , for multiple dice 6,20,4", + "type": 3, + "required": False + } + ] +} + +#add_command(json) +commands = get_commands() +print(commands) +#command_id = commands[0]["id"] +#(command_id=command_id, payload=command_dict) \ No newline at end of file