From fc16d15ef9002926abbf2236527771367a752cb4 Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Thu, 26 Sep 2024 16:52:48 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E5=91=A8=E3=82=8A?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dislocker_slash.py b/dislocker_slash.py index 913b543..e75931e 100644 --- a/dislocker_slash.py +++ b/dislocker_slash.py @@ -761,7 +761,6 @@ class ReasonModal(discord.ui.Modal): else: await interaction.response.send_message("# :skull_crossbones: 登録できませんでした。\n内部エラーが発生しています。", ephemeral=True) - dislocker = DL() intents = discord.Intents.default() @@ -780,6 +779,13 @@ async def on_ready(): await tree.sync() @client.event +async def on_interaction(interaction: discord.Interaction): + try: + if interaction.data["component_type"] == 2: + await on_button(interaction) + except KeyError: + pass + async def on_button(interaction: discord.Interaction): custom_id = interaction.data["custom_id"] custom_id_split = custom_id.split("_") @@ -997,7 +1003,7 @@ async def devicereg(interaction: discord.Interaction): if onetime["about"] == "error": await interaction.response.send_message(":x: 内部エラーが発生しました。\nサーバーでエラーが発生しています。管理者に問い合わせてください。", ephemeral=True) -@tree.command(name="fstop", description="PCの使用を強制終了します。") +@tree.command(name="fstop", description="PCの使用登録を強制的に終了します。") async def fstop(interaction: discord.Interaction, pc_number: int, about: str): force_stop = dislocker.force_stop(pc_number=pc_number, bot_about=about) if force_stop["result"] == 0: @@ -1043,6 +1049,8 @@ async def button_init(interaction: discord.Interaction, text_channel: discord.Te await client.get_channel(text_channel.id).send(f'# :index_pointing_at_the_viewer: 使いたいPCの番号を選んでください!', view=pc_button_view) dislocker.log(title=f"[INFO] サーバーで初回処理を実行しました。", flag=0) + await interaction.response.send_message(f":white_check_mark: ボタンを送信しました!", ephemeral=True) + client.run(dislocker.server_config["bot"]["token"]) \ No newline at end of file