-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
54 lines (41 loc) · 1.3 KB
/
main.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
import asyncio
import os
from logging import DEBUG, Formatter, StreamHandler, getLogger
import discord
from discord.ext import commands
from config.load_config import config
COGS = [
"cogs.locale",
"cogs.help",
"cogs.reaction",
"cogs.test",
]
bot = commands.Bot(command_prefix="", help_command=None, intents=discord.Intents.all())
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
formatter = Formatter("%(asctime)s : %(levelname)s : %(name)s : %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.propagate = False
@bot.event
async def on_ready():
logger.info("We have logged in as {0.user}".format(bot))
# コマンドが存在しない場合にエラーを出さない
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
return
raise error
if __name__ == "__main__":
async def main():
for cog in COGS:
await bot.load_extension(cog)
if config["USE_WEBUI"]:
await bot.load_extension("cogs.sd")
await bot.load_extension("cogs.link_expand")
if config["USE_NOVELAI"]:
await bot.load_extension("cogs.nai")
await bot.start(os.getenv("DISCORD_TOKEN"))
asyncio.run(main())