繁体   English   中英

如何使用discord.py发送图像

[英]How to send a image with discord.py

@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)

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

with open(my_filename, "rb") as fh:
    f = discord.File(fh, filename=my_filename)
await ctx.send(file=f)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM