예제 #1
0
 async def urbandict(self, ctx, *, terms):
     embeds = []
     try:
         async with self.http as http:
             data = await http.get(f"http://api.urbandictionary.com/v0/define", params={'term': terms})
         await http.close()
         items = data['list']
         for item in items:
             embed = discord.Embed(color=self.bot.colour)
             embed.title = item['word']
             embed.set_author(name=item['author'],
                              icon_url="https://images-ext-1.discordapp.net/external/Gp2DBilGEcbI2YR0qkOGVkivomBLwmkW_7v3K8cD1mg/https/cdn.discordapp.com/emojis/734991429843157042.png")
             embed.description = cyberformat.hyper_replace(str(item['definition']), old=['[', ']'], new=['', ''])
             embed.description += f"\n👍 **{item['thumbs_up']:,}** 👎 **{item['thumbs_down']}**"
             embed.add_field(name="Example",
                             value=cyberformat.hyper_replace(str(item['example']), old=['[', ']'], new=['', '']))
             embeds.append(embed)
         source = paginator.EmbedSource(embeds)
         menu = paginator.CatchAllMenu(source=source)
         menu.add_info_fields({"<:author:734991429843157042>": "The author of the post",
                               ":thumbsup:": "How many thumbs up the post has",
                               ":thumbsdown:": "How many thumbs down the post has"})
         await menu.start(ctx)
     except (APIError, IndexError):
         raise commands.BadArgument(f"term not found on urban dictionary.")
예제 #2
0
 async def cleverbot_session(self, message):
     if message.channel.id in (730486269468999741, 730570845013147708,
                               750404241566335088):
         if message.author.bot:
             return
         async with message.channel.typing():
             if len(message.content) < 2 or len(message.content) > 100:
                 return await message.channel.send(
                     f"**{message.author.name}**, text must be below 100 characters and over 2."
                 )
             resp = await self.clever.ask(message.content,
                                          message.author.id)
             r = str(resp) if str(resp).startswith("I") else minimalize(
                 str(resp))
             if str(r)[-1] not in ['.', '?', '!']:
                 suff = "?" if any(s in str(r) for s in [
                     'who', 'what', 'when', 'where', 'why', 'how'
                 ]) else "."
             else:
                 suff = "\u200b"
             send = hyper_replace(str(r),
                                  old=[' i ', "i'm", "i'll"],
                                  new=[' I ', "I'm", "I'll"])
             await message.channel.send(
                 f"**{message.author.name}**, {send}{suff}")
예제 #3
0
 async def cleverbot(self, ctx, *, text: str):
     """
     Ask the clever bot a question.
     """
     async with ctx.typing():
         if len(ctx.message.content) < 2 or len(ctx.message.content) > 60:
             return await ctx.send(
                 f"**{ctx.author.name}**, text must be below 60 characters and over 2.")
         resp = await self.clever.ask(text, ctx.author.id)
         r = str(resp) if str(resp).startswith("I") else cyberformat.minimalize(str(resp))
         if str(r)[-1] not in ['.', '?', '!']:
             suff = "?" if any(s in str(r) for s in ['who', 'what', 'when', 'where', 'why', 'how']) else "."
         else:
             suff = "\u200b"
         send = cyberformat.hyper_replace(str(r), old=[' i ', "i'm", "i'll"], new=[' I ', "I'm", "I'll"])
         await ctx.send(f"**{ctx.author.name}**, {send}{suff}")
예제 #4
0
 async def b(self, ctx, *, message):
     await ctx.send(
         cyberformat.hyper_replace(text=message,
                                   old=['b', 'B', 'D', 'd'],
                                   new=['🅱', '🅱', "🅱", "🅱"]))
예제 #5
0
 async def owo(self, ctx, *, message):
     await ctx.send(
         cyberformat.hyper_replace(text=message,
                                   old=['r', 'l', 'R', 'L'],
                                   new=['w', 'w', "W", "W"]))