async def urban(ctx, *, str): if ctx.message.author == bot.user: return else: try: textchannel = ctx.message.channel await textchannel.trigger_typing() time.sleep(2) ud = UrbanDictionary() word = await ud.get_word(str) embed = discord.Embed(title="Word: {0.word}".format(word), color=0x9b59b6) embed.add_field(name="Urban Dictionary Definition", value="{0.definition}".format(word), inline=True) embed.add_field(name="Urban Link", value="{0.permalink}".format(word), inline=False) embed.set_thumbnail(url="https://imgur.com/HBPlcKQ.jpg") await ctx.send(embed=embed) await ud.close() except asyncurban.errors.WordNotFoundError(): embed = discord.Embed( title="There were no matches for that word!", color=0x9b59b6) await ctx.send(embed=embed) await ud.close()
async def randurban(self, ctx): if not ctx.channel.is_nsfw(): await ctx.send(embed=await macro.error( desc="Command must be used in an NSFW channel")) else: ud = UrbanDictionary() word = await ud.get_random() await ctx.send(embed=await macro.msg( desc=f"**{word}**\n```{word.definition}```"))
def __init__(self, bot): self.PARAMS = { "limit": 1, "includeRelated": "false", "useCanonical": "true", "includeTags": "false", "api_key": bot.api_keys["wordnik"], } self.bot = bot self.urban = UrbanDictionary(loop=bot.loop, session=bot.aio_session)
async def urban(self, ctx, *, search): urban = UrbanDictionary() terms = await urban.search(search, limit=2) word = random.choice(terms) embed = discord.Embed(title=f"Definition of {word.word}", description=word.definition) embed.add_field(name="Example", value=word.example, inline=False) embed.add_field(name="Link", value=word.permalink) await urban.close() await ctx.send(embed=embed)
async def urban(self, ctx, *, args): if ctx.channel.is_nsfw(): try: ud = UrbanDictionary() word = await ud.get_word(args) await ctx.send(embed=await macro.msg( f"**{word}**\n```{word.definition}```")) except: await ctx.send(embed=await macro.msg( desc=f"Could not find any word under ``{args}``")) else: await ctx.send(embed=await macro.error( desc="Command must be used in an NSFW channel"))
async def urbanr(ctx): if ctx.message.author == bot.user: return else: textchannel = ctx.message.channel await textchannel.trigger_typing() time.sleep(2) ud = UrbanDictionary() random_word = await ud.get_random() embed = discord.Embed( title="Word: {0.word}".format(random_word), color=0x9b59b6) embed.add_field(name="Urban Dictionary Definition", value="{0.definition}".format(random_word), inline=True) embed.add_field(name="Urban Link", value="{0.permalink}".format(random_word), inline=True) embed.set_thumbnail(url="https://imgur.com/HBPlcKQ.jpg") await ctx.send(embed=embed) await ud.close()
async def urban_random(ctx): urb = UrbanDictionary(loop=client.loop) word = str(await urb.get_random()) defi = urbandict.define(str(word)) define = defi[0]['def'] example = defi[0]['example'] out = discord.Embed(title=str.upper(word), descripition=define, color=0x0062f4) out.add_field(name="Meaning", value=str.title(define), inline=False) out.add_field(name="Example", value=str.title(example), inline=False) out.set_footer( text="Urban Dictionary, " + ctx.message.author.name, icon_url= 'https://vignette.wikia.nocookie.net/logopedia/images/a/a7/UDAppIcon.jpg/revision/latest?cb=20170422211150' ) out.set_thumbnail( url= 'https://s3.amazonaws.com/pushbullet-uploads/ujxPklLhvyK-RGDsDKNxGPDh29VWVd5iJOh8hkiBTRyC/urban_dictionary.jpg?w=188&h=188&fit=crop' ) await client.send_message(ctx.message.channel, embed=out) await client.delete_message(ctx.message)
def __init__(self, bot): self.bot = bot self.urban = UrbanDictionary(loop=bot.loop, session=bot.aio_session)