Updated to v1.9.3

[8b98361](8b983618f2)
This commit is contained in:
ElBe 2022-11-12 22:15:52 +01:00 committed by GitHub
parent 8b983618f2
commit e58c8c4692
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 567 additions and 526 deletions

View File

@ -2,17 +2,17 @@
Slash command creator for the discord.py Bot. Slash command creator for the discord.py Bot.
© by ElBe. © by ElBe.
Version: 0.1.5 Version: 1.4
''' '''
#Imports #Imports
import os
import requests import requests
import functions
#Variables #Variables
url = 'https://discord.com/api/v10/applications/' + str(os.environ['application_id']) + '/commands' url = 'https://discord.com/api/v10/applications/' + str(functions.json_module.get_config('Config')['Application ID']) + '/commands'
headers = { headers = {
'Authorization': 'Bot ' + str(os.environ['token']) 'Authorization': 'Bot ' + str(functions.json_module.get_config('Config')['Token'])
} }
#Example Command #Example Command
@ -26,6 +26,5 @@ json = {
def create_command(json): def create_command(json):
try: try:
r = requests.post(url, headers=headers, json=json) r = requests.post(url, headers=headers, json=json)
print('Command /' + str(json['name']) + ' was sucessfully created.')
except Exception as e: except Exception as e:
print('Error while trying to create the command /' + str(json['name']) + '.\n' + str(e)) print('Error while trying to create the command /' + str(json['name']) + '.\n' + str(e))

1
Bot/commands.json Normal file
View File

@ -0,0 +1 @@
{"Created": 0}

View File

@ -3,7 +3,7 @@ Command creator for the discord.py Bot.
© by ElBe. © by ElBe.
Version: 0.1.5 Version: 1.5
NOTE: Only execute once. NOTE: Only execute once.
''' '''

View File

@ -1,13 +1,18 @@
{ {
"Config": { "Config": {
"Version": "1.9.2 final-r", "Token": "<INSERT TOKEN HERE>",
"Version-Comment": "Bugfix and error handler.", "Application ID": "<INSERT APPLICATION ID HERE>",
"Footer": "Bot made by ElBe.", "Version": "1.9.3 final",
"Version-Comment": "Added error handling.",
"Footer": "Made by ElBe.",
"Credits": true "Credits": true
}, },
"Channels": { "Channels": {
"Welcome": "<Insert welcome channel name here>", "Welcome": "",
"Goodbye": "<Insert goodbye channel name here>" "Goodbye": ""
},
"Roles": {
"Member": "member"
}, },
"Commands": { "Commands": {
"stop": true, "stop": true,

24
Bot/errors.py Normal file
View File

@ -0,0 +1,24 @@
'''
Errors for the discord.py Bot.
© by ElBe.
Version: 1.0
'''
#Imports
import functions
#Error
class error():
def __init__(self, name: str, text: str):
functions.console.error(name + '\n' + text)
exit()
#API error
class APIError(error):
def __init__(self, text: str):
super().__init__('API error', text)
#OutdatedVersionError
class OutdatedVersionError():
def __init__(self, outdated: str, version: str, download: str):
functions.console.warn('Outdated version\nYou installed an outdated version of ' + outdated + '. Please install version ' + version + ' from ' + download + '.')

View File

@ -2,7 +2,7 @@
Functions for the discord.py Bot. Functions for the discord.py Bot.
© by ElBe. © by ElBe.
Version: 0.1.1 Version: 1.2
''' '''
#Imports #Imports
@ -11,6 +11,10 @@ import os
import colorama import colorama
import datetime import datetime
import re import re
import requests
#Bot modules
import errors
class variables(): class variables():
'''All variables used in this module.''' '''All variables used in this module.'''
@ -104,3 +108,11 @@ class console():
def erase_last(): def erase_last():
'''Erases the last line.''' '''Erases the last line.'''
print('\x1b[1A' + '\x1b[2K' + '\x1b[1A') print('\x1b[1A' + '\x1b[2K' + '\x1b[1A')
class outdated():
def __init__(package: str, min_version: str):
min_version_int = int(min_version.replace('.',''))
try:
latest_version = int(str(json.loads(requests.get('https://pypi.python.org/pypi/' + package + '/json').text)['info']['version']).replace('.', ''))
except Exception as e:
print(console.error('Package not found.'))

View File

@ -1 +1 @@
__version__ = '1.9.2' version = '1.9.3'