Beispiel #1
0
 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()}"
     )
Beispiel #2
0
 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)
Beispiel #3
0
 def test_whatif(self):
     # Get a What If to test.
     test = xkcd.getWhatIf(3)
     self.assertEqual(test.number, 3)
     self.assertEqual(test.title, "Yoda")
Beispiel #4
0
async def whatif(ctx, number):
    whatif = xkcd.getWhatIf(number)
    await makeWhatIf(ctx, whatif)
Beispiel #5
0
	def test_whatif(self):
		# Get a What If to test.
		test = xkcd.getWhatIf(3)
		self.assertEqual(test.number, 3)
		self.assertEqual(test.title, "Yoda")