-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.py
48 lines (40 loc) · 1015 Bytes
/
index.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
import os
from utils import default
from utils.data import (
Bot,
HelpFormat,
)
from multiprocessing import Process
import discord
def main():
config = default.get_from_env("CONFIG")
if config is None:
exit(3)
print("機器人登入中 ...")
intents = discord.Intents.default()
intents.members = True
bot = Bot(
command_prefix=config.prefix,
prefix=config.prefix,
command_attrs=dict(hidden=True),
help_command=HelpFormat(),
intents=intents
)
for file in os.listdir("cogs"):
if file.endswith(".py"):
name = file[:-3]
bot.load_extension(f"cogs.{name}")
token = os.environ.get("TOKEN")
if token is None:
exit(2)
bot.run(token)
if __name__ == '__main__':
while True:
p = Process(target=main)
p.start()
p.join()
if p.exitcode == 100:
print('準備重啟 ...')
continue
else:
exit(p.exitcode)