forked from scubot/scubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
63 lines (53 loc) · 1.89 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import json
import sys
import discord
from discord.ext import commands
PREFIX = "!"
DESCRIPTION = "scubot"
BOT_VERSION = "2.2.0"
CONFIG_PATH = "config.json"
TOKEN_PATH = "token.json"
try:
with open(CONFIG_PATH, 'r') as fp:
config = json.load(fp)
modules_to_load = config["load_modules"]
configIntents = config["intents"]
except FileNotFoundError:
print("[FATAL] No config.json file found. Startup aborted.")
sys.exit()
try:
with open(TOKEN_PATH, 'r') as fp:
token = json.load(fp)["token"]
except FileNotFoundError:
print("[FATAL] No token file found. Startup aborted.")
sys.exit()
print("""
----------------------------------------------------------
..######...######..##.....##.########...#######..########
.##....##.##....##.##.....##.##.....##.##.....##....##...
.##.......##.......##.....##.##.....##.##.....##....##...
..######..##.......##.....##.########..##.....##....##...
.......##.##.......##.....##.##.....##.##.....##....##...
.##....##.##....##.##.....##.##.....##.##.....##....##...
..######...######...#######..########...#######.....##...
----------------------------------------------------------
""")
print(f"v{BOT_VERSION}")
print("Logging in...")
def run_bot():
intents = discord.Intents.default()
intents.presences = configIntents["presences"]
intents.members = configIntents["members"]
bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION, case_insensitive=True, intents=intents)
bot.version = BOT_VERSION
if len(modules_to_load) != 0:
for module in modules_to_load:
try:
bot.load_extension(module)
print(f"[LOAD] Successfully loaded extension {module}")
except Exception as e:
print(e)
print(f"[ERROR] Failed to load extension {module}, continuing.")
bot.run(token)
if __name__ == '__main__':
run_bot()