discord.py otter 命令使用 python-pixabay 错误
discord.py otter command using python-pixabay error
使用 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
上的说明安装的
我注意到一件事是描述是空的。通常,如果嵌入的字段为空,则嵌入不会发送,因此我建议您至少检查一下 \u200b
(空字符)* 或某些描述的文本。
此外,color
参数似乎实际上没有值。 discord.Color.from_rgb()
实际上是一种方法,它接受0-255之间的3个整数值(#FFFFFF,#000000不允许)。
附带说明一下,您可以使用 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"
使用 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
上的说明安装的我注意到一件事是描述是空的。通常,如果嵌入的字段为空,则嵌入不会发送,因此我建议您至少检查一下 \u200b
(空字符)* 或某些描述的文本。
此外,color
参数似乎实际上没有值。 discord.Color.from_rgb()
实际上是一种方法,它接受0-255之间的3个整数值(#FFFFFF,#000000不允许)。
附带说明一下,您可以使用 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"