Ejemplo n.º 1
0
 async def ship(self, ctx, user1: str, *, user2: str = None):
     """Ship 2 users"""
     if not user2:
         user2 = arg.get_server_member(ctx, user1)
         user1 = ctx.author
     else:
         user1 = arg.get_server_member(ctx, user1)
         user2 = arg.get_server_member(ctx, user2)
     if not user1 or not user2:
         return await ctx.send("Invalid user :no_entry:")
     shipname = str(user1.name[:math.ceil(len(user1.name) / 2)]) + str(
         user2.name[math.ceil(len(user2.name) / 2):])
     state = random.getstate()
     random.seed(user2.id + user1.id)
     number = randint(0, 100)
     random.setstate(state)
     u1avatar = user1.avatar_url_as(format="png")
     u2avatar = user2.avatar_url_as(format="png")
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://localhost:8443/api/ship?firstImage={}&secondImage={}"
                 .format(u1avatar, u2avatar)) as f:
             if f.status == 200:
                 await ctx.send(
                     content="Ship Name: **{}**\nLove Percentage: **{}%**".
                     format(shipname, number),
                     file=discord.File(f.content, "ship.png"))
             elif f.status == 400:
                 return await ctx.send(await f.text())
             else:
                 return await ctx.send(
                     "Oops something went wrong! Status code: {}".format(
                         f.status))
Ejemplo n.º 2
0
 async def whowouldwin(self,
                       ctx,
                       user_or_imagelink: str,
                       user_or_imagelink2: str = None):
     """Who would win out of 2 images"""
     channel = ctx.channel
     author = ctx.author
     user = arg.get_server_member(ctx, user_or_imagelink)
     if not user:
         url1 = user_or_imagelink
     else:
         url1 = user.avatar_url_as(format="png")
     if not user_or_imagelink2:
         url2 = author.avatar_url_as(format="png")
     else:
         user = arg.get_server_member(ctx, user_or_imagelink2)
         if not user:
             url2 = user_or_imagelink2
         else:
             url2 = user.avatar_url_as(format="png")
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://localhost:8443/api/www?firstImage={}&secondImage={}"
                 .format(url1, url2)) as f:
             if f.status == 200:
                 await ctx.send(file=discord.File(f.content, "www.png"))
             elif f.status == 400:
                 await ctx.send(await f.text())
             else:
                 await ctx.send(
                     "Oops something went wrong! Status code: {}".format(
                         f.status))
Ejemplo n.º 3
0
 async def resetattempts(self, ctx, user: str = None):
     """Resets the attempts of a user"""
     if not user:
         user = ctx.author
     else:
         user = arg.get_server_member(ctx, user)
         if not user:
             return await ctx.send("I could not find that user :no_entry:")
     data = r.table("antiad").get(str(ctx.guild.id))
     if str(user.id) not in data["users"].map(lambda x: x["id"]).run(
             self.db, durability="soft"):
         return await ctx.send(
             "This user doesn't have any attempts :no_entry:")
     else:
         if data["users"].filter(
                 lambda x: x["id"] == str(user.id))[0]["attempts"].run(
                     self.db, durability="soft") == 0:
             return await ctx.send(
                 "This user doesn't have any attempts :no_entry:")
         else:
             await ctx.send("**{}** attempts have been reset.".format(user))
             data.update({
                 "users":
                 r.row["users"].map(lambda x: r.branch(
                     x["id"] == str(user.id), x.merge({"attempts": 0}), x))
             }).run(self.db, durability="soft")
Ejemplo n.º 4
0
 async def gay(self, ctx, user_or_imagelink: str = None):
     """Turn someone or yourself gay"""
     channel = ctx.message.channel
     author = ctx.message.author
     if not user_or_imagelink:
         if ctx.message.attachments:
             url = ctx.message.attachments[0].url
         else:
             url = author.avatar_url_as(format="png")
     else:
         user = arg.get_server_member(ctx, user_or_imagelink)
         if not user:
             return await ctx.send("Invalid user :no_entry:")
         else:
             url = user.avatar_url_as(format="png")
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://localhost:8443/api/gay?image={}".format(url)) as f:
             if f.status == 200:
                 await ctx.send(file=discord.File(f.content, "gay.png"))
             elif f.status == 400:
                 return await ctx.send(await f.text())
             else:
                 return await ctx.send(
                     "Oops something went wrong! Status code: {}".format(
                         f.status))
Ejemplo n.º 5
0
 async def beautiful(self, ctx, user_or_image: str = None):
     """Turn something to a masterpiece"""
     channel = ctx.channel
     author = ctx.author
     if not user_or_image:
         if ctx.message.attachments:
             url = ctx.message.attachments[0].url
         else:
             url = author.avatar_url_as(format="png")
     else:
         user = arg.get_server_member(ctx, user_or_image)
         if not user:
             url = user_or_image
         else:
             url = user.avatar_url_as(format="png")
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://localhost:8443/api/beautiful?image={}".format(
                     url)) as f:
             if f.status == 200:
                 await ctx.send(
                     file=discord.File(f.content, "beautiful.png"))
             elif f.status == 400:
                 return await ctx.send(await f.text())
             else:
                 return await ctx.send(
                     "Oops something went wrong! Status code: {}".format(
                         f.status))
Ejemplo n.º 6
0
 async def fear(self, ctx, user_or_imagelink: str = None):
     """Make someone look feared of"""
     channel = ctx.channel
     author = ctx.author
     if not user_or_imagelink:
         if ctx.message.attachments:
             url = ctx.message.attachments[0].url
         else:
             url = author.avatar_url_as(format="png")
     else:
         user = arg.get_server_member(ctx, user_or_imagelink)
         if not user:
             url = user_or_imagelink
         else:
             url = user.avatar_url_as(format="png")
     async with aiohttp.ClientSession() as session:
         async with session.get(
                 "http://localhost:8443/api/fear?image={}".format(
                     url)) as f:
             if f.status == 200:
                 await ctx.send(file=discord.File(f.content, "fear.png"))
             elif f.status == 400:
                 await ctx.send(await f.text())
             else:
                 await ctx.send(
                     "Oops something went wrong! Status code: {}".format(
                         f.status))
Ejemplo n.º 7
0
 async def _discord(self, ctx, user: str, *, discord_text: str):
     user = arg.get_server_member(ctx, user)
     if not user:
         return await ctx.send("Invalid user :no_entry:")
     if discord_text.lower().endswith(" --white"):
         white = True
         discord_text = discord_text[:-8]
     else: 
         white = False
     url = "http://localhost:8443/api/discord?image={}&theme={}&{}&colour={}&{}&bot={}".format(user.avatar_url_as(format="png"), "dark" if not white else "white", urllib.parse.urlencode({"text": discord_text}),
     str(user.colour)[1:], urllib.parse.urlencode({"name": user.display_name}), user.bot)
     async with aiohttp.ClientSession() as session:
         async with session.get(url) as f:
             if f.status == 200:
                 await ctx.send(file=discord.File(f.content, "discord.png"))
             elif f.status == 400:
                 await ctx.send(await f.text())
             else:
                 await ctx.send("Oops something went wrong! Status code: {}".format(f.status))
Ejemplo n.º 8
0
 async def tweet(self, ctx, user: str, *, text: commands.clean_content(fix_channel_mentions=True)):
     """Tweet from your or another users account"""
     await ctx.channel.trigger_typing()
     user = arg.get_server_member(ctx, user)
     if not user:
         return await ctx.send("I could not find that user :no_entry:")
     if len(text) > 250:
         await ctx.send("No more than 250 characters :no_entry:")
         return
     retweets = randint(1, ctx.guild.member_count)
     likes = randint(1, ctx.guild.member_count)
     urls = list(map(lambda x: x.avatar_url_as(format="png", size=128), random.sample(ctx.guild.members, min(ctx.guild.member_count, 10, likes))))
     data = {"displayName": user.display_name, "name": user.name, "avatarUrl": user.avatar_url_as(format="png", size=128), "urls": urls, "likes": likes, "retweets": retweets, "text": text}
     async with aiohttp.ClientSession() as session:
         async with session.post("http://localhost:8443/api/tweet", json=data, headers={"Content-Type": "application/json"}) as f:
             if f.status == 200:
                 await ctx.send(file=discord.File(f.content, "tweet.png"))
             elif f.status == 400:
                 return await ctx.send(await f.text())
             else:
                 return await ctx.send("Oops something went wrong! Status code: {}".format(f.status))