Meme preview slash command

pull/127/head
stijndcl 2022-08-26 21:35:49 +02:00
parent a0c1b986cd
commit f9083e84ed
2 changed files with 13 additions and 4 deletions

View File

@ -64,7 +64,20 @@ class Fun(commands.Cog):
modal = GenerateMeme(self.client, result)
await interaction.response.send_modal(modal)
@memes_slash.command(
name="preview", description="Generate a preview for a meme, to see how the fields are structured"
)
async def memegen_preview_slash(self, interaction: discord.Interaction, meme: str):
"""Slash command to generate a meme preview"""
await interaction.response.defer()
fields = [f"Field #{i + 1}" for i in range(20)]
meme_url = await self._do_generate_meme(meme, fields)
await interaction.followup.send(meme_url)
@memegen_slash.autocomplete("meme")
@memegen_preview_slash.autocomplete("meme")
async def _memegen_slash_autocomplete_meme(
self, _: discord.Interaction, current: str
) -> list[app_commands.Choice[str]]:

View File

@ -38,10 +38,6 @@ class GenerateMeme(discord.ui.Modal, title="Generate Meme"):
fields = [item.value for item in self.children if isinstance(item, discord.ui.TextInput)]
meme_url = await generate_meme(self.client.http_session, self.meme, fields)
if meme_url is None:
return await interaction.followup.send("Something went wrong.")
await interaction.followup.send(meme_url)
@overrides