diff --git a/assistant/assistant.py b/assistant/assistant.py index 3a1a7fb..af70cd8 100644 --- a/assistant/assistant.py +++ b/assistant/assistant.py @@ -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):