From 994cba6ad0658ebf383e7779bf62c929e47fe4a6 Mon Sep 17 00:00:00 2001 From: ElBe <90863907+ElBe-Plaq@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:52:23 +0200 Subject: [PATCH] Create command_creator.py --- Replit/command_creator.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Replit/command_creator.py diff --git a/Replit/command_creator.py b/Replit/command_creator.py new file mode 100644 index 0000000..fae7bb0 --- /dev/null +++ b/Replit/command_creator.py @@ -0,0 +1,31 @@ +''' +Slash command creator for the discord.py Bot. +© by ElBe. + +Version: 0.1.4 +''' + +#Imports +import os +import requests + +#Variables +url = 'https://discord.com/api/v10/applications/' + str(os.environ['application_id']) + '/commands' +headers = { + 'Authorization': 'Bot ' + str(os.environ['token']) +} + +#Example Command +json = { + 'name': 'ping', + 'type': 1, + 'description': 'Shows you the ping of the bot.' +} + +#Function +def create_command(json): + try: + r = requests.post(url, headers=headers, json=json) + print('Command /' + str(json['name']) + ' was sucessfully created.') + except Exception as e: + print('Error while trying to create the command /' + str(json['name']) + '.\n' + str(e))