parent
8b983618f2
commit
e58c8c4692
@ -2,17 +2,17 @@
|
||||
Slash command creator for the discord.py Bot.
|
||||
© by ElBe.
|
||||
|
||||
Version: 0.1.5
|
||||
Version: 1.4
|
||||
'''
|
||||
|
||||
#Imports
|
||||
import os
|
||||
import requests
|
||||
import functions
|
||||
|
||||
#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 = {
|
||||
'Authorization': 'Bot ' + str(os.environ['token'])
|
||||
'Authorization': 'Bot ' + str(functions.json_module.get_config('Config')['Token'])
|
||||
}
|
||||
|
||||
#Example Command
|
||||
@ -26,6 +26,5 @@ json = {
|
||||
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))
|
||||
1
Bot/commands.json
Normal file
1
Bot/commands.json
Normal file
@ -0,0 +1 @@
|
||||
{"Created": 0}
|
||||
@ -3,7 +3,7 @@ Command creator for the discord.py Bot.
|
||||
|
||||
© by ElBe.
|
||||
|
||||
Version: 0.1.5
|
||||
Version: 1.5
|
||||
|
||||
NOTE: Only execute once.
|
||||
'''
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
{
|
||||
"Config": {
|
||||
"Version": "1.9.2 final-r",
|
||||
"Version-Comment": "Bugfix and error handler.",
|
||||
"Footer": "Bot made by ElBe.",
|
||||
"Token": "<INSERT TOKEN HERE>",
|
||||
"Application ID": "<INSERT APPLICATION ID HERE>",
|
||||
"Version": "1.9.3 final",
|
||||
"Version-Comment": "Added error handling.",
|
||||
"Footer": "Made by ElBe.",
|
||||
"Credits": true
|
||||
},
|
||||
"Channels": {
|
||||
"Welcome": "<Insert welcome channel name here>",
|
||||
"Goodbye": "<Insert goodbye channel name here>"
|
||||
"Welcome": "",
|
||||
"Goodbye": ""
|
||||
},
|
||||
"Roles": {
|
||||
"Member": "member"
|
||||
},
|
||||
"Commands": {
|
||||
"stop": true,
|
||||
|
||||
24
Bot/errors.py
Normal file
24
Bot/errors.py
Normal 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 + '.')
|
||||
@ -2,7 +2,7 @@
|
||||
Functions for the discord.py Bot.
|
||||
© by ElBe.
|
||||
|
||||
Version: 0.1.1
|
||||
Version: 1.2
|
||||
'''
|
||||
|
||||
#Imports
|
||||
@ -11,6 +11,10 @@ import os
|
||||
import colorama
|
||||
import datetime
|
||||
import re
|
||||
import requests
|
||||
|
||||
#Bot modules
|
||||
import errors
|
||||
|
||||
class variables():
|
||||
'''All variables used in this module.'''
|
||||
@ -104,3 +108,11 @@ class console():
|
||||
def erase_last():
|
||||
'''Erases the last line.'''
|
||||
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.'))
|
||||
@ -1 +1 @@
|
||||
__version__ = '1.9.2'
|
||||
version = '1.9.3'
|
||||
Loading…
x
Reference in New Issue
Block a user