Fix memegen preview

pull/136/head
stijndcl 2022-09-25 18:54:18 +02:00
parent 5528ce7c2e
commit 105cee7e6e
2 changed files with 6 additions and 4 deletions

View File

@ -102,8 +102,7 @@ class Fun(commands.Cog):
async def memegen_preview_msg(self, ctx: commands.Context, template: str):
"""Generate a preview for the meme template `template`, to see how the fields are structured."""
async with ctx.typing():
fields = [f"Field #{i + 1}" for i in range(20)]
meme = await self._do_generate_meme(template, fields)
meme = await self._do_generate_meme(template, [])
return await ctx.reply(meme, mention_author=False)
@memes_slash.command(name="generate")
@ -121,8 +120,7 @@ class Fun(commands.Cog):
"""Generate a preview for a meme, to see how the fields are structured."""
await interaction.response.defer(ephemeral=True)
fields = [f"Field #{i + 1}" for i in range(20)]
meme_url = await self._do_generate_meme(template, fields)
meme_url = await self._do_generate_meme(template, [])
await interaction.followup.send(meme_url, ephemeral=True)

View File

@ -10,6 +10,10 @@ __all__ = ["generate_meme"]
def generate_boxes(meme: MemeTemplate, fields: list[str]) -> list[str]:
"""Generate the template boxes for Imgflip"""
# If no fields were passed, generate a template instead
if not fields:
fields = [f"Field #{i + 1}" for i in range(meme.field_count)]
# If a meme only has 1 field, join all the arguments together into one string
if meme.field_count == 1:
fields = [" ".join(fields)]