ボタンを呼び出せないバグを修正

This commit is contained in:
suti7yk5032 2024-09-29 00:18:30 +09:00
parent 5f17506447
commit c82351e186

View file

@ -1176,10 +1176,11 @@ async def on_button(interaction: discord.Interaction):
keyboard_list = dislocker.get_keyboard_list() keyboard_list = dislocker.get_keyboard_list()
for i in keyboard_list["output_dict"].keys(): for i in keyboard_list["output_dict"].keys():
if i['alt_name'] == None: current_keyboard_list = keyboard_list['output_dict'][i]
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'])}") 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: 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_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") 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 keyboard_number_show = keyboard_number
for i in mouse_list["output_dict"].keys(): for i in mouse_list["output_dict"].keys():
current_mouse_list = mouse_list['output_dict'][i]
if i['alt_name'] == None: 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: 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_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") 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) pc_button_view = discord.ui.View(timeout=None)
for i in pc_list["output_dict"].keys(): for i in pc_list["output_dict"].keys():
if i['alt_name'] == None: current_pc_list = pc_list['output_dict'][i]
pc_register_button = discord.ui.Button(style=discord.ButtonStyle.primary, label=f"{str(i['pc_number'])}", custom_id=f"pcregister_{str(i['pc_number'])}") 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: 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) 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) 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) result_embed = discord.Embed(title=":information_source: 現在のPCリスト", description="PCリストです。", color=0x2286C9)
for i in pc_list['output_dict'].keys(): for i in pc_list['output_dict'].keys():
if i['alt_name'] == None: current_pc_list = pc_list['output_dict'][i]
pc_name_title = f'{i['pc_number']}' if current_pc_list['alt_name'] == None:
pc_name_title = f'{current_pc_list['pc_number']}'
else: 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'未使用' pc_using_value = f'未使用'
else: 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}> が使用中' pc_using_value = f'<@{discord_user_id}> が使用中'
result_embed.add_field(name=f'{pc_name_title}', value=f'{pc_using_value}') result_embed.add_field(name=f'{pc_name_title}', value=f'{pc_using_value}')