【发布时间】:2023-01-07 10:48:26
【问题描述】:
我想做一个 Discord 交互,发送图片的频率与你在“多少”中所说的一样多,但使用我当前的代码,它发送 1 个嵌入图片,其余的不发送图片。如何解决这个问题?
@tree.command(name='embed', description='embed')
async def embed(interaction: discord.Interaction, seeable: bool, howmany: typing.Optional[int]):
embed = discord.Embed(title="Here is a title", color=0xff8c00)
file = discord.File(f"[file path]", filename="image.png")
embed.set_image(url="attachment://image.png")
if seeable == True:
await interaction.response.send_message(file=file, embed=embed)
if howmany >= 2:
for i in range(howmany-1):
await interaction.followup.send(file=file, embed=embed)
if seeable == False:
await interaction.response.send_message(file=file, embed=embed, ephemeral=True)
if howmany >= 2:
for i in range(howmany-1):
await interaction.followup.send(file=file, embed=embed, ephemeral=True)
它在没有交互的情况下已经工作得很好,就像旧的前缀系统一样。 如果您删除所有 # 它将从文件路径上传文件。否则它将显示来自网站的图片:
if message.content.startswith('+image'):
count = 0
args = message.content.split(' ')
if len(args) < 2:
count = 1
else:
if args[1].isdigit():
count = int(args[1])
else:
await message.channel.send("How many should it be?")
for i in range(count):
random = random.randint(1,68)
embed = discord.Embed(title="Title", color=0xff8c00)
embed.set_image(url=f"https://www.awebsite/pic{random}.png")
#file = discord.File(f"C:a/file/path/pic{random}.png", filename="image.png")
#embed.set_image(url="attachment://image.png")
#await message.channel.send(file=file, embed=embed)
await message.channel.send(embed=embed)
【问题讨论】:
标签: python discord discord.py embed discord-interactions