Я хочу спросить, как исправить ошибку. Проблема в том; бот говорит: «Это взаимодействие не удалось», когда я выбираю опцию в функции ok_button. И журналов ошибок нет. Не могли бы вы решить мою проблему? Это для моего проекта, поэтому я очень хочу решить эту проблему как можно быстрее.
Вот что я попробовал:
Отключение эфемерного режима: ничего столь маловероятного не изменилось эта ошибка возникает из-за эфемерного сообщения
Когда я Это следующий журнал, который сообщил Discord.py
[2025-01-06 13:02:45] [INFO ] discord.client: logging in using static token
[2025-01-06 13:02:46] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: b639f3cf5e021f92343b8f456bc7a57b).
Logged in as テスト用bot#6295
Received interaction: 1325675932790427728
Interaction 1325675932790427728 deferred.
Follow-up message sent for interaction 1325675932790427728
Вот полный код (в целях безопасности изменена часть токена)
Я хочу спросить, как исправить ошибку. Проблема в том; бот говорит: «Это взаимодействие не удалось», когда я выбираю опцию в функции ok_button. И журналов ошибок нет. Не могли бы вы решить мою проблему? Это для моего проекта, поэтому я очень хочу решить эту проблему как можно быстрее. Вот что я попробовал: Отключение эфемерного режима: ничего столь маловероятного не изменилось эта ошибка возникает из-за эфемерного сообщения Когда я Это следующий журнал, который сообщил Discord.py [code][2025-01-06 13:02:45] [INFO ] discord.client: logging in using static token [2025-01-06 13:02:46] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: b639f3cf5e021f92343b8f456bc7a57b). Logged in as テスト用bot#6295 Received interaction: 1325675932790427728 Interaction 1325675932790427728 deferred. Follow-up message sent for interaction 1325675932790427728 [/code] Вот полный код (в целях безопасности изменена часть токена) [code]import discord from discord.ext import commands from discord import app_commands
def get_channel_options(self): # サーバーのテキストチャンネルを取得して選択肢として表示 return [ discord.SelectOption(label=channel.name, value=str(channel.id)) for channel in self.guild.text_channels ]
async def ok_button_callback(self, interaction: discord.Interaction): # Only send the response if the interaction hasn't been responded to yet if not interaction.response.is_done(): if self.thread_channel: await interaction.response.send_message( f"設定が完了しました!\n" f"宣伝スレッド: {self.thread_channel.mention}", ephemeral=True ) else: await interaction.response.send_message( "チャンネルが選択されていません。", ephemeral=True )
async def select_callback(self, interaction: discord.Interaction, custom_id: str, selected_value: str): # Handle channel selection and update the button state if custom_id == "select_thread_channel": self.thread_channel = interaction.guild.get_channel(int(selected_value))
# Defer the interaction so it doesn't fail when processing updates await interaction.response.defer(ephemeral=True)
# Update message with the current selection await interaction.followup.send( f"現在の設定:\n" f"宣伝スレッド: {self.thread_channel.mention if self.thread_channel else '未設定'}", ephemeral=True )
# Update the OK button based on the channel selection self.update_ok_button()
@bot.tree.command(name="setup_adve", description="注意事項を確認します") async def setup_adve(interaction: discord.Interaction): try: # Check if this interaction has been processed already if interaction_status.get(interaction.id, False): print(f"Interaction {interaction.id} has already been completed.") return # Don't proceed if interaction is finished
# Mark the interaction as in-progress interaction_status[interaction.id] = False
print(f"Received interaction: {interaction.id}")
# Defer the interaction await interaction.response.defer(ephemeral=True) print(f"Interaction {interaction.id} deferred.")
# Send the follow-up message await interaction.followup.send( content=warning_message, view=view, ephemeral=True ) print(f"Follow-up message sent for interaction {interaction.id}")
# Mark the interaction as finished after sending the response interaction_status[interaction.id] = True
except discord.errors.NotFound: # Handle invalidated interaction print(f"Error: Interaction {interaction.id} has been invalidated or expired.") except Exception as e: # Handle any other errors print(f"Unexpected error: {e}")
bot.run(TOKEN) [/code] Что вы думаете? Ответ на мой вопрос был бы полезен, спасибо!