From c82351e1868576300bffdf64a14046be91213ec9 Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Sun, 29 Sep 2024 00:18:30 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E5=91=BC?= =?UTF-8?q?=E3=81=B3=E5=87=BA=E3=81=9B=E3=81=AA=E3=81=84=E3=83=90=E3=82=B0?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker_slash.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/dislocker_slash.py b/dislocker_slash.py index 941bc21..13680cf 100644 --- a/dislocker_slash.py +++ b/dislocker_slash.py @@ -1176,10 +1176,11 @@ async def on_button(interaction: discord.Interaction): keyboard_list = dislocker.get_keyboard_list() for i in keyboard_list["output_dict"].keys(): - if i['alt_name'] == None: - keyboard_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['keyboard_number'])} 番", custom_id=f"keyboardregister_{str(pc_number)}_{str(i['keyboard_number'])}") + current_keyboard_list = keyboard_list['output_dict'][i] + if current_keyboard_list['alt_name'] == None: + keyboard_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_keyboard_list['keyboard_number'])} 番", custom_id=f"keyboardregister_{str(pc_number)}_{str(current_keyboard_list['keyboard_number'])}") else: - keyboard_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['keyboard_number'])} 番 | ({i['alt_name']})", custom_id=f"keyboardregister_{str(pc_number)}_{str(i['keyboard_number'])}") + keyboard_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_keyboard_list['keyboard_number'])} 番 | ({current_keyboard_list['alt_name']})", custom_id=f"keyboardregister_{str(pc_number)}_{str(current_keyboard_list['keyboard_number'])}") keyboard_register_view.add_item(keyboard_register_button) keyboard_not_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="キーボードは自前", custom_id=f"keyboardregister_{str(pc_number)}_own") @@ -1198,10 +1199,11 @@ async def on_button(interaction: discord.Interaction): keyboard_number_show = keyboard_number for i in mouse_list["output_dict"].keys(): + current_mouse_list = mouse_list['output_dict'][i] if i['alt_name'] == None: - mouse_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['mouse_number'])} 番", custom_id=f"mouseregister_{str(pc_number)}_{str(keyboard_number)}_{str(i['mouse_number'])}") + mouse_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_mouse_list['mouse_number'])} 番", custom_id=f"mouseregister_{str(pc_number)}_{str(keyboard_number)}_{str(current_mouse_list['mouse_number'])}") else: - mouse_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['mouse_number'])} 番 | ({i['alt_name']})", custom_id=f"mouseregister_{str(pc_number)}_{str(keyboard_number)}_{str(i['mouse_number'])}") + mouse_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_mouse_list['mouse_number'])} 番 | ({current_mouse_list['alt_name']})", custom_id=f"mouseregister_{str(pc_number)}_{str(keyboard_number)}_{str(current_mouse_list['mouse_number'])}") mouse_register_view.add_item(mouse_register_button) mouse_not_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label="マウスは自前", custom_id=f"mouseregister_{str(pc_number)}_{str(keyboard_number)}_own") @@ -1517,10 +1519,11 @@ async def button_init(interaction: discord.Interaction, text_channel: discord.Te pc_button_view = discord.ui.View(timeout=None) for i in pc_list["output_dict"].keys(): - if i['alt_name'] == None: - pc_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['pc_number'])} 番", custom_id=f"pcregister_{str(i['pc_number'])}") + current_pc_list = pc_list['output_dict'][i] + if current_pc_list['alt_name'] == None: + pc_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_pc_list['pc_number'])} 番", custom_id=f"pcregister_{str(current_pc_list['pc_number'])}") else: - pc_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['pc_number'])} 番 | ({i['alt_name']})", custom_id=f"pcregister_{str(i['pc_number'])}") + pc_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(current_pc_list['pc_number'])} 番 | ({current_pc_list['alt_name']})", custom_id=f"pcregister_{str(current_pc_list['pc_number'])}") pc_button_view.add_item(pc_register_button) await client.get_channel(text_channel.id).send(f'# :index_pointing_at_the_viewer: 使いたいPCの番号を選んでください!', view=pc_button_view) @@ -1558,15 +1561,16 @@ async def pcinfo(interaction: discord.Interaction): result_embed = discord.Embed(title=":information_source: 現在のPCリスト", description="PCリストです。", color=0x2286C9) for i in pc_list['output_dict'].keys(): - if i['alt_name'] == None: - pc_name_title = f'{i['pc_number']} 番' + current_pc_list = pc_list['output_dict'][i] + if current_pc_list['alt_name'] == None: + pc_name_title = f'{current_pc_list['pc_number']} 番' else: - pc_name_title = f'{i['pc_number']} 番 ({i['alt_name']})' + pc_name_title = f'{current_pc_list['pc_number']} 番 ({current_pc_list['alt_name']})' - if i['using_member_id'] == None: + if current_pc_list['using_member_id'] == None: pc_using_value = f'未使用' else: - discord_user_id = dislocker.get_discord_user_id(i['using_member_id']) + discord_user_id = dislocker.get_discord_user_id(current_pc_list['using_member_id']) pc_using_value = f'<@{discord_user_id}> が使用中' result_embed.add_field(name=f'{pc_name_title}', value=f'{pc_using_value}')