Untitled

By Speedy Peafowl, 5 Years ago, written in Plain Text, viewed 127 times.
URL http://pb.stoleyour.com/view/4bc633b6 Embed
Download Paste or View RawExpand paste to full width of browser
  1. import discord
  2. import asyncio
  3. import urllib.request
  4. import requests
  5. from discord.ext import commands
  6.  
  7. class Shorten:
  8.  
  9.     def __init__(self, bot):
  10.         self.bot = bot
  11.  
  12.     @commands.command(pass_context=True)
  13.     async def ouo(self, ctx):
  14.         if "465896415751569408" in [role.id for role in ctx.message.author.roles]:
  15.             url = ("http://ouo.io/api/B3Nm9g8L?s=" + ctx.message.content)
  16.             handle = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
  17.             html = urllib.request.urlopen(handle).read().decode('utf-8')
  18.             await self.bot.say("Shortened: " + html)
  19.             await asyncio.sleep(1)
  20.         else:
  21.             await self.bot.say("nope")
  22.             await asyncio.sleep(1)
  23.  
  24. def setup(bot):
  25.     bot.add_cog(Shorten(bot))

Reply to "Untitled"

Here you can reply to the paste above