Skip to content

Commit e58c8c4

Browse files
authored
Updated to v1.9.3
[8b98361](8b98361)
1 parent 8b98361 commit e58c8c4

File tree

8 files changed

+567
-526
lines changed

8 files changed

+567
-526
lines changed

Bot/bot.py

Lines changed: 299 additions & 299 deletions
Large diffs are not rendered by default.

Bot/command_creator.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
Slash command creator for the discord.py Bot.
33
© by ElBe.
44
5-
Version: 0.1.5
5+
Version: 1.4
66
'''
77

88
#Imports
9-
import os
109
import requests
10+
import functions
1111

1212
#Variables
13-
url = 'https://discord.com/api/v10/applications/' + str(os.environ['application_id']) + '/commands'
13+
url = 'https://discord.com/api/v10/applications/' + str(functions.json_module.get_config('Config')['Application ID']) + '/commands'
1414
headers = {
15-
'Authorization': 'Bot ' + str(os.environ['token'])
15+
'Authorization': 'Bot ' + str(functions.json_module.get_config('Config')['Token'])
1616
}
1717

1818
#Example Command
@@ -26,6 +26,5 @@
2626
def create_command(json):
2727
try:
2828
r = requests.post(url, headers=headers, json=json)
29-
print('Command /' + str(json['name']) + ' was sucessfully created.')
3029
except Exception as e:
3130
print('Error while trying to create the command /' + str(json['name']) + '.\n' + str(e))

Bot/commands.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Created": 0}

Bot/commands.py

Lines changed: 110 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,110 @@
1-
'''
2-
Command creator for the discord.py Bot.
3-
4-
© by ElBe.
5-
6-
Version: 0.1.5
7-
8-
NOTE: Only execute once.
9-
'''
10-
11-
#Imports
12-
import command_creator
13-
14-
#Stop command
15-
json = {
16-
'name': 'stop',
17-
'type': 1,
18-
'description': 'Stops the bot.'
19-
}
20-
command_creator.create_command(json)
21-
22-
#Help command
23-
json = {
24-
'name': 'help',
25-
'type': 1,
26-
'description': 'Shows you help about the bot.'
27-
}
28-
command_creator.create_command(json)
29-
30-
#Ping command
31-
json = {
32-
'name': 'ping',
33-
'type': 1,
34-
'description': 'Shows you the ping of the bot in ms.'
35-
}
36-
command_creator.create_command(json)
37-
38-
#Info command
39-
json = {
40-
'name': 'info',
41-
'type': 1,
42-
'description': 'Shows you information about the bot.'
43-
}
44-
command_creator.create_command(json)
45-
46-
#Kick command
47-
json = {
48-
'name': 'kick',
49-
'type': 1,
50-
'description': 'Kicks a member from the server.',
51-
"options": [
52-
{
53-
"name": "member",
54-
"description": "The member to kick.",
55-
"type": 6,
56-
"required": True
57-
},
58-
{
59-
"name": "reason",
60-
"description": "Reason for the kick.",
61-
"type": 3,
62-
"required": False
63-
}
64-
]
65-
}
66-
command_creator.create_command(json)
67-
68-
#Ban command
69-
json = {
70-
'name': 'ban',
71-
'type': 1,
72-
'description': 'Bans a member from the server.',
73-
"options": [
74-
{
75-
"name": "member",
76-
"description": "The member to ban.",
77-
"type": 6,
78-
"required": True
79-
},
80-
{
81-
"name": "reason",
82-
"description": "Reason for the ban.",
83-
"type": 3,
84-
"required": False
85-
}
86-
]
87-
}
88-
command_creator.create_command(json)
89-
90-
#Unban command
91-
json = {
92-
'name': 'unban',
93-
'type': 1,
94-
'description': 'Unbans a member from the server.',
95-
"options": [
96-
{
97-
"name": "member",
98-
"description": "The member to unban.",
99-
"type": 6,
100-
"required": True
101-
},
102-
{
103-
"name": "reason",
104-
"description": "Reason for the unban.",
105-
"type": 3,
106-
"required": False
107-
}
108-
]
109-
}
110-
command_creator.create_command(json)
1+
'''
2+
Command creator for the discord.py Bot.
3+
4+
© by ElBe.
5+
6+
Version: 1.5
7+
8+
NOTE: Only execute once.
9+
'''
10+
11+
#Imports
12+
import command_creator
13+
14+
#Stop command
15+
json = {
16+
'name': 'stop',
17+
'type': 1,
18+
'description': 'Stops the bot.'
19+
}
20+
command_creator.create_command(json)
21+
22+
#Help command
23+
json = {
24+
'name': 'help',
25+
'type': 1,
26+
'description': 'Shows you help about the bot.'
27+
}
28+
command_creator.create_command(json)
29+
30+
#Ping command
31+
json = {
32+
'name': 'ping',
33+
'type': 1,
34+
'description': 'Shows you the ping of the bot in ms.'
35+
}
36+
command_creator.create_command(json)
37+
38+
#Info command
39+
json = {
40+
'name': 'info',
41+
'type': 1,
42+
'description': 'Shows you information about the bot.'
43+
}
44+
command_creator.create_command(json)
45+
46+
#Kick command
47+
json = {
48+
'name': 'kick',
49+
'type': 1,
50+
'description': 'Kicks a member from the server.',
51+
"options": [
52+
{
53+
"name": "member",
54+
"description": "The member to kick.",
55+
"type": 6,
56+
"required": True
57+
},
58+
{
59+
"name": "reason",
60+
"description": "Reason for the kick.",
61+
"type": 3,
62+
"required": False
63+
}
64+
]
65+
}
66+
command_creator.create_command(json)
67+
68+
#Ban command
69+
json = {
70+
'name': 'ban',
71+
'type': 1,
72+
'description': 'Bans a member from the server.',
73+
"options": [
74+
{
75+
"name": "member",
76+
"description": "The member to ban.",
77+
"type": 6,
78+
"required": True
79+
},
80+
{
81+
"name": "reason",
82+
"description": "Reason for the ban.",
83+
"type": 3,
84+
"required": False
85+
}
86+
]
87+
}
88+
command_creator.create_command(json)
89+
90+
#Unban command
91+
json = {
92+
'name': 'unban',
93+
'type': 1,
94+
'description': 'Unbans a member from the server.',
95+
"options": [
96+
{
97+
"name": "member",
98+
"description": "The member to unban.",
99+
"type": 6,
100+
"required": True
101+
},
102+
{
103+
"name": "reason",
104+
"description": "Reason for the unban.",
105+
"type": 3,
106+
"required": False
107+
}
108+
]
109+
}
110+
command_creator.create_command(json)

Bot/config.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{
22
"Config": {
3-
"Version": "1.9.2 final-r",
4-
"Version-Comment": "Bugfix and error handler.",
5-
"Footer": "Bot made by ElBe.",
3+
"Token": "<INSERT TOKEN HERE>",
4+
"Application ID": "<INSERT APPLICATION ID HERE>",
5+
"Version": "1.9.3 final",
6+
"Version-Comment": "Added error handling.",
7+
"Footer": "Made by ElBe.",
68
"Credits": true
79
},
810
"Channels": {
9-
"Welcome": "<Insert welcome channel name here>",
10-
"Goodbye": "<Insert goodbye channel name here>"
11+
"Welcome": "",
12+
"Goodbye": ""
13+
},
14+
"Roles": {
15+
"Member": "member"
1116
},
1217
"Commands": {
1318
"stop": true,

Bot/errors.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'''
2+
Errors for the discord.py Bot.
3+
© by ElBe.
4+
5+
Version: 1.0
6+
'''
7+
#Imports
8+
import functions
9+
10+
#Error
11+
class error():
12+
def __init__(self, name: str, text: str):
13+
functions.console.error(name + '\n' + text)
14+
exit()
15+
16+
#API error
17+
class APIError(error):
18+
def __init__(self, text: str):
19+
super().__init__('API error', text)
20+
21+
#OutdatedVersionError
22+
class OutdatedVersionError():
23+
def __init__(self, outdated: str, version: str, download: str):
24+
functions.console.warn('Outdated version\nYou installed an outdated version of ' + outdated + '. Please install version ' + version + ' from ' + download + '.')

0 commit comments

Comments
 (0)