Fix setkey: use button+modal instead of ctx.send_modal

This commit is contained in:
2026-08-16 22:55:02 -05:00
parent 3e1300112a
commit 71b70c3ba1
+13 -1
View File
@@ -21,6 +21,17 @@ class APIKeyModal(discord.ui.Modal):
await interaction.response.send_message("API key saved.", ephemeral=True)
class APIKeyButton(discord.ui.View):
def __init__(self, config):
super().__init__(timeout=60)
self.config = config
@discord.ui.button(label="Set API Key", style=discord.ButtonStyle.primary)
async def set_key(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(APIKeyModal(self.config))
self.stop()
class Assistant(commands.Cog):
"""AI chatbot assistant. Set a chat channel or get responses when the bot is pinged."""
@@ -177,7 +188,8 @@ class Assistant(commands.Cog):
@checks.is_owner()
async def assistant_setkey(self, ctx: commands.Context):
"""Set the API key (opens a private modal)."""
await ctx.send_modal(APIKeyModal(self.config))
view = APIKeyButton(self.config)
await ctx.send("Click below to set the API key:", view=view)
@assistant.command(name="toggle")
async def assistant_toggle(self, ctx: commands.Context):