Discord.py 嵌入本地文件

Discord.py Embed Local File

我试图将本地设备中的文件添加到 discord.py 嵌入中。下面是我的代码,虽然它不起作用请帮助我

import discord
from discord.ext import commands

client = commands.Bot(command_prefix="!")

@client.command
async def pika(ctx):
  file = discord.File("‪E:\Python\discord.py\Pikachu1.jpg", filename="image.jpg")
  embed = discord.Embed(color=0xFFFFFF)
  embed.set_image(url="E:\Python\discord.py\Pikachu1.jpg")
  await ctx.send(file=file, embed=embed)

要将本地文件用于嵌入图像,请使用 Discord 的 attachment:// 协议。 (归因于 Lukasz)。

file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)

https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image