使用python-pixabay,我试图搜索水鼠图像,然后让我的discord.py机器人在嵌入中发送图像。在我搜索图像并获得图像后,我将其打印出来,但它没有打印任何内容,所以我非常确定这是图像搜索的问题。我没有收到错误消息,但它就是不能工作。
下面是我的代码:
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)我没有展示我所有的代码,因为里面有一些敏感的东西,但我展示了你需要看到的所有东西。Pixabay肯定是安装的,因为我是通过PyPi website上的说明安装的
发布于 2020-05-13 07:26:23
我注意到的一件事是描述是空的。通常,如果embeds有空字段就不会发送,所以我建议您至少检查一下\u200b (空字符)*或某些描述的文本。
此外,color参数似乎没有实际的值。discord.Color.from_rgb()实际上是一个方法,它接受0-000000之间的3个整数值(不允许#FFFFFF,#255)。
作为附注,您可以使用this网站获取颜色的十六进制代码。
示例:
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"
https://stackoverflow.com/questions/61763609
复制相似问题