stopのKeyErrorを修正

This commit is contained in:
suti7yk5032 2024-08-23 02:28:23 +09:00
parent 26f5269ce5
commit d433f38d94

View file

@ -382,12 +382,13 @@ class Bot(discord.Client):
def stop(self, **kwargs):
try:
discord_user_id = str(kwargs["user_id"])
cursor = dislocker.db.cursor()
discord_user_id = str(kwargs["discord_user_id"])
if "bot_about" in kwargs:
bot_about = kwargs["bot_about"]
else:
bot_about = None
cursor = dislocker.db.cursor()
# ユーザーが登録してるかというよりはデータの取得のため
user_register = self.user_register_check(discord_user_id=discord_user_id)
member_id = user_register["user_info"]["member_id"]
@ -398,7 +399,7 @@ class Bot(discord.Client):
pc_usage_history_record = cursor.fetchall()
if pc_usage_history_record:
usage_id = pc_usage_history_record[0][0]
pc_usage_history_id = pc_usage_history_record[0][0]
pc_number = pc_usage_history_record[0][2]
keyboard_number = pc_usage_history_record[0][3]
mouse_number = pc_usage_history_record[0][4]
@ -408,9 +409,9 @@ class Bot(discord.Client):
if end_use_time == None:
# 利用停止の理由の有無を判断
if bot_about == None:
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp() WHERE id = %s", (usage_id,))
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp() WHERE id = %s", (pc_usage_history_id,))
else:
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp(), bot_about = %s WHERE id = %s", (bot_about, usage_id))
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp(), bot_about = %s WHERE id = %s", (bot_about, pc_usage_history_id))
# pc_listの使用中ユーザーを消す
cursor.execute("UPDATE pc_list SET using_member_id = NULL, password_hash = NULL WHERE pc_number = %s", (pc_number,))
if keyboard_number == None: