Exemple #1
0
 async def urban(self, ctx, *, search_terms: str):
     '''Searches Up a Term in Urban Dictionary'''
     client = urbanasync.Client(ctx.session)
     search_terms = search_terms.split()
     definition_number = terms = None
     try:
         definition_number = int(search_terms[-1]) - 1
         search_terms.remove(search_terms[-1])
     except ValueError:
         definition_number = 0
     if definition_number not in range(0, 11):
         pos = 0
     search_terms = " ".join(search_terms)
     emb = discord.Embed()
     try:
         term = await client.get_term(search_terms)
     except LookupError:
         emb.title = "Ничего не найдено."
         return await ctx.send(embed=emb)
     emb.color = await ctx.get_dominant_color(
         url=ctx.message.author.avatar_url)
     definition = term.definitions[definition_number]
     emb.title = f"{definition.word}  ({definition_number+1}/{len(term.definitions)})"
     emb.description = definition.definition
     emb.url = definition.permalink
     emb.add_field(name='Пример', value=definition.example)
     emb.add_field(
         name='Голоса',
         value=f'{definition.upvotes}👍    {definition.downvotes}👎')
     emb.set_footer(text=f"Обьяснение написано {definition.author}",
                    icon_url="http://urbandictionary.com/favicon.ico")
     await ctx.send(embed=emb)
Exemple #2
0
 async def urban(self, ctx, *, search_terms: str):
     '''Urban Dictionary'''
     client = urbanasync.Client(ctx.session)
     search_terms = search_terms.split()
     definition_number = terms = None
     try:
         definition_number = int(search_terms[-1]) - 1
         search_terms.remove(search_terms[-1])
     except ValueError:
         definition_number = 0
     if definition_number not in range(0, 11):
         pos = 0
     search_terms = " ".join(search_terms)
     emb = discord.Embed()
     try:
         term = await client.get_term(search_terms)
     except LookupError:
         emb.title = "Search term not found."
         return await ctx.send(embed=emb)
     emb.color = await ctx.get_dominant_color(
         url=ctx.message.author.avatar_url_as(static_format="png"))
     definition = term.definitions[definition_number]
     emb.title = f"{definition.word}  ({definition_number+1}/{len(term.definitions)})"
     emb.description = definition.definition
     emb.url = definition.permalink
     emb.add_field(name='Example', value=definition.example)
     emb.add_field(
         name='Votes',
         value=f'{definition.upvotes}👍    {definition.downvotes}👎')
     emb.set_footer(text=f"Definition written by {definition.author}",
                    icon_url="http://urbandictionary.com/favicon.ico")
     await ctx.send(embed=emb)
Exemple #3
0
 def __init__(self):
     super().__init__(command_prefix="!")
     self.session = aiohttp.ClientSession(loop=self.loop)
     self._last_result = None
     self.urban_client = urbanasync.Client(session=self.session)
     self.maintenance = False
     self.role_message_ids = [[439701001210167306, 439701431088447489, 439701716234141696]]
     self.get_roles_lang = [
         ["🇬🇧", 390820109620477952],
         ["🇪🇸", 390820111310651395],
         ["🇮🇹", 390820130109652992],
         ["🇫🇷", 412266663317078016],
         ["🇩🇪", 390820128964608002],
         ["🇵🇹", 390820477641424896]
     ]
     self.get_roles_region = [
         ["🇺🇸", 393226619579400193],
         ["🇬🇧", 393226622247108621],
         ["🇦🇺", 393226625333985280]
     ]
Exemple #4
0
 def __init__(self, bot):
     self.bot = bot
     self.session = bot.session
     self.urban_client = urbanasync.Client(session=self.session)