import discord import asyncio import urllib.request import requests from discord.ext import commands class Shorten: def __init__(self, bot): self.bot = bot @commands.command(pass_context=True) async def ouo(self, ctx): if "467711093888909334" in [role.id for role in ctx.message.author.roles]: await self.bot.say("I have the role") if "71597167550144512" == ctx.message.author.id: url = ("http://ouo.io/api/B3Nm9g8L?s=" + ctx.message.content) handle = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) html = urllib.request.urlopen(handle).read().decode('utf-8') await self.bot.say("Here you go :link: " + html) elif "129360731085864961" == ctx.message.author.id: await self.bot.say("user2") else: await self.bot.say("nein " + ctx.message.author.id) def setup(bot): bot.add_cog(Shorten(bot))