Skip to content

Commit

Permalink
fix !search command to have a raw output option
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Jun 1, 2024
1 parent 7f097bc commit ada9751
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions discord_tron_master/cogs/image/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ async def search_prompts(self, ctx, *, search_string: str):
await ctx.send(
f"{ctx.author.mention} Search is not currently available at this time, try again later."
)

@commands.command(name='random', help='Search for random prompts. Returns up to 10 prompts, unless a number is provided.')
async def random_prompts(self, ctx, count: int = 10):
async def random_prompts(self, ctx, count: int = 10, raw: str = None):
try:
app = AppConfig.flask
with app.app_context():
Expand All @@ -282,10 +283,16 @@ async def random_prompts(self, ctx, count: int = 10):
found_string = "a prompt"
if len(discovered_prompts) > 1:
found_string = f"{len(discovered_prompts)} prompts"
output_string = f"{ctx.author.mention} I found {found_string} for you:"
if raw is None:
output_string = f"{ctx.author.mention} I found {found_string} for you:"
else:
output_string = ""
for prompt in discovered_prompts[:int(count)]:
output_string = f"{output_string}\n- `{prompt[0]}`"
await ctx.send(output_string)
if raw is not None:
output_string = f"{output_string}\n{prompt[0]}"
else:
output_string = f"{output_string}\n- `{prompt[0]}`"
await DiscordBot.send_large_message(ctx=ctx, text=output_string)
except Exception as e:
logger.error("Caught error when searching prompts: " + str(e))
await ctx.send(
Expand Down

0 comments on commit ada9751

Please sign in to comment.