如何发送带有discord.py的图像

问题描述 投票:0回答:1
@client.command(past_context = True)
async def ss(ctx):
    try:
        os.remove("ss.png")
    except:
        pass
    pyautogui.screenshot("ss.png")
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    file = File(filename="ss.png")
    await ctx.send(file=file)

[我正在尝试使不和谐的bot在服务器中发送.ss时发送屏幕截图,而我正在使用python 3.8.2,有人知道一种方法,因为我在任何地方都找不到方法?

python discord.py
1个回答
0
投票
with open(my_filename, "rb") as fh:
    f = discord.File(fh, filename=my_filename)
await ctx.send(file=f)
© www.soinside.com 2019 - 2024. All rights reserved.