-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreportmain.py
executable file
·65 lines (52 loc) · 1.75 KB
/
reportmain.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
64
65
from discord.ext import commands
import discord
import os
import logging
from modules import cogs
import aiofiles
import json
import argparse
parser = argparse.ArgumentParser(description="report_bot!を起動する")
parser.add_argument("-dev", action="store_true", help="開発モードで実行")
parser.add_argument("-reset", action="store_true", help="何も読み込まない")
args = parser.parse_args()
if args.dev:
cog_list = cogs.get_cogs()
dev_cog_list = cogs.get_dev_cogs()
elif args.reset:
cog_list = []
dev_cog_list = None
else:
cog_list = cogs.get_cogs()
dev_cog_list = None
intents = discord.Intents.none()
intents.messages = True
intents.guilds = True
bot = commands.Bot(command_prefix="!!!!!", intents=intents)
try:
TOKEN = os.environ["ReportBot_TOKEN"]
report_bot_service_cha = int(os.environ["report_bot_service_cha"])
except KeyError:
with open("env.json", mode="r") as f:
content = json.load(f)
TOKEN = content["ReportBot_TOKEN"]
report_bot_service_cha = int(content["report_bot_service_cha"])
@bot.event
async def on_ready():
for x in cog_list:
await bot.load_extension(x)
print(f"ロード完了:{x}")
if dev_cog_list:
for x in dev_cog_list:
await bot.load_extension(x)
print(f"ロード完了:{x}")
await bot.tree.sync()
print("全ロード完了")
channel = bot.get_channel(report_bot_service_cha)
await channel.send(f"{bot.user.mention} がオンラインになったよう。")
path = "data/bot_version"
async with aiofiles.open(path, mode="r", encoding="UTF-8") as f:
version = await f.read()
custom_activity = discord.Game(f"/help | ver{version}")
await bot.change_presence(status=discord.Status.online,activity=custom_activity)
bot.run(TOKEN, log_level = logging.WARNING)