Oblique
Oblique

Reputation: 556

discord.py otter command using python-pixabay error

Using python-pixabay I am trying to search for otter images, then get my discord.py bot to send the image in an embed. After I search for the image and get the image, then I print it out, but it doesn't print anything, so I am pretty sure it's a problem with the image search. I get no error messages, but it just won't work.

Here is my code:

import pixabay
import discord

pixa = os.getenv('PIXABAY_KEY')

image = Image(pixa)

@bot.command(name='otter', help='Generates a random otter!')
async def otter(ctx):
    page = random.choice(range(0, 4))


    embed = discord.Embed(title='Otter', color=discord.Color.from_rgb)
    embed.set_image(url=ims)
    embed.set_footer(text='Powered by pixabay.')

    await ctx.send(embed=embed)

bot.run(TOKEN)

I didn't show all my code because there is some sensitive stuff in there, but I showed all the things you need to see. Pixabay is definitely installed, as I installed it via the instructions on the PyPi website

Upvotes: 0

Views: 92

Answers (1)

Diggy.
Diggy.

Reputation: 6944

One thing I'm noticing is that the description is empty. Often, embeds won't send if they have empty fields, so I'd recommend checking you at least plop in a \u200b (empty character)* or text of some description.

Additionally, the color parameter doesn't seem to actually have a value. discord.Color.from_rgb() is actually a method which takes in 3 integer values between 0-255 (#FFFFFF, #000000 not allowed).

As a side note, you can use this website to get hex codes for the colours instead.

Example:

embed = discord.Embed(title="Otter", description="Some text!", color=discord.Color.from_rgb(85, 177, 74))

# equivalent
embed = discord.Embed(title="Otter", description="Some text!", color=0x55b14a)

*description="\u200b"

Upvotes: 1

Related Questions