printfデバックを削除、チャンネルIDがintで記述されていない場合は起動しなくなるように

This commit is contained in:
suti7yk5032 2024-07-07 17:24:33 +09:00
parent 62537a1038
commit 80a266142b

View file

@ -29,8 +29,8 @@ class DL():
},
"bot": {
"token": "TYPE HERE BOTS TOKEN KEY",
"log_channel_id" : "TYPE HERE CHANNEL ID",
"config_channel_id": "TYPE HERE CHANNEL ID"
"log_channel_id" : "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)",
"config_channel_id": "TYPE HERE CHANNEL ID (YOU MUST USE INT !!!!)"
}
}
@ -42,13 +42,18 @@ class DL():
with open(self.server_config_path, "r") as r:
self.server_config = json.load(r)
print("config ファイルを読み込みました。")
if not os.path.isdir(self.export_dir_path):
print("export ディレクトリが見つかりません... 作成します。")
os.mkdir(self.export_dir_path)
self.db = psycopg2.connect(f"host={self.server_config['db']['host']} dbname={self.server_config['db']['db_name']} port={self.server_config['db']['port']} user={self.server_config['db']['username']} password={self.server_config['db']['password']}")
self.init_result = "ok"
if not type(self.server_config["bot"]["log_channel_id"]) is int or type(self.server_config["bot"]["config_channel_id"]) is int:
print("config ファイル内でチャンネルIDがint型で記述されていません。int型で記述して、起動してください。")
self.init_result = "not_int"
else:
self.db = psycopg2.connect(f"host={self.server_config['db']['host']} dbname={self.server_config['db']['db_name']} port={self.server_config['db']['port']} user={self.server_config['db']['username']} password={self.server_config['db']['password']}")
self.init_result = "ok"
except (Exception) as error:
print("初回処理でエラーが発生しました。\nエラー内容\n" + str(error))
@ -262,7 +267,6 @@ class Bot(discord.Client):
print("DiscordのBotが起動しました。")
async def on_message(self, message):
print("メッセージ来た")
if message.author.bot:
pass
@ -350,7 +354,6 @@ class Bot(discord.Client):
dislocker = DL()
if dislocker.init_result == "ok":
print(dislocker.server_config)
intents = discord.Intents.default()
intents.message_content = True
bot = Bot(intents=intents)