@commands.hybrid_command(name="urban", description = "Get the definition of a term(word) from Urban Dictionary.")
async def urbun(self, ctx:commands.Context, *, word:str):
response = requests.get(f"http://api.urbandictionary.com/v0/define?term={word}")
data = response.json()
result = [item for item in data["list"]]
random_choice = random.choice(result)
embed = discord.Embed(title=f"{word.capitalize()}",
description=f">>> **Definition**: {random_choice["definition"]}", color= 0x00FFFF)
embed.add_field(name="Example", value=f"{random_choice["example"]}", inline= False)
embed.add_field(name=f"🖒 {random_choice["thumbs_up"]}", value="", inline=True)
embed.add_field(name=f"🖓 {random_choice["thumbs_down"]}", value="", inline=True)
embed.set_footer(text=f"{random_choice["written_on"]}")
embed.set_author(name=f"Author: {random_choice["author"]}")
button = discord.ui.Button(
label= "Check Out",
url= random_choice["permalink"],
style= discord.ButtonStyle.link
)
view = discord.ui.View()
view.add_item(button)
await ctx.send(embed=embed, view= view)
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)