relevant XKCD
This commit is contained in:
+24
@@ -94,6 +94,30 @@ class Shitpost(object):
|
|||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
|
@commands.command(pass_context=True)
|
||||||
|
@asyncio.coroutine
|
||||||
|
def relevantxkcd(self, ctx, query: str):
|
||||||
|
"""There is always a relevant XKCD
|
||||||
|
Bijvoorbeeld:
|
||||||
|
!relevantxkcd python
|
||||||
|
"""
|
||||||
|
|
||||||
|
#self.bot.say("deed ik het ding?")
|
||||||
|
response = requests.get("https://relevantxkcd.appspot.com/process?action=xkcd&query=" + query)
|
||||||
|
|
||||||
|
splitResponse = response.text.split(" ")
|
||||||
|
photoUrl = "http://www.explainxkcd.com" + splitResponse[3]
|
||||||
|
|
||||||
|
print(photoUrl)
|
||||||
|
|
||||||
|
em = discord.Embed(title='', type='photo')
|
||||||
|
em.set_image(url=photoUrl)
|
||||||
|
|
||||||
|
try:
|
||||||
|
yield from ctx.message.delete()
|
||||||
|
except:
|
||||||
|
print("No permission to delete message")
|
||||||
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|||||||
Reference in New Issue
Block a user