async def whatif(self, ctx, *args): """gives random xkcd comic""" if len(args) and args[0].isdigit(): comic = xkcd.getWhatIf(args[0]) else: comic = xkcd.getRandomWhatIf() await ctx.send( f"WhatIf #{comic.getNumber()} **{comic.getTitle()}** {comic.getLink()}" )
async def whatIf(self, ctx, call='random'): """Functions that call to xkcd whatif API, currently incomplete""" if call == 'random': whif = xkcd.getRandomWhatIf() elif call == 'latest': whif = xkcd.getLatestWhatIf() elif call.isdigit(): whif = xkcd.getWhatIf(call) else: await ctx.bot.send_message(\ ctx.message.channel,\ 'Hmm... I can\'t find a WhatIf with that parameter.') wtitle = whif.getTitle() wurl = whif.getLink() wnumber = whif.getNumber() # Embed and send message embed = discord.Embed(title=wtitle) embed.set_image(url=wurl) embed.set_footer(text='WhatIf issue {}'.format(wnumber)) await ctx.bot.send_message(ctx.message.channel, embed=embed)
def test_whatif(self): # Get a What If to test. test = xkcd.getWhatIf(3) self.assertEqual(test.number, 3) self.assertEqual(test.title, "Yoda")
async def whatif(ctx, number): whatif = xkcd.getWhatIf(number) await makeWhatIf(ctx, whatif)