def orly(self, ctx, title, guide, author, *, top_text=''):
"""Generates O'Reilly book covers."""
api_base = 'https://orly-appstore.herokuapp.com/generate?'
url = (api_base +
f'title={urlescape(title)}&top_text={urlescape(top_text)}&image_code={randrange(0, 41)}' +
f'&theme={randrange(0, 17)}&author={urlescape(author)}&guide_text={urlescape(guide)}' +
f'&guide_text_placement=bottom_right')
try:
async with ctx.typing():
async with ctx.bot.session.get(url) as resp:
with BytesIO(await resp.read()) as bio:
await ctx.send(file=discord.File(filename='orly.png', fp=bio))
except aiohttp.ClientError:
await ctx.send("Couldn't contact the API.")
评论列表
文章目录