python-如何使用 discord.py 发送图像
我要做的是首先获取用户的消息,将其绘制到图像上,然后发送
一切正常,除了它应该发送图像的部分,那我该怎么做?
from msilib.schema import File
from tkinter import font
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import discord
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message}({channel})')
if username == "ChrisMightShootYou":
font = ImageFont.truetype(font='D:\DOWNLOAD\DiscordBot\FuturaBookFont.ttf', size=84)
image = Image.open('D:\DOWNLOAD\DiscordBot\erdemoji.png')
draw = ImageDraw.Draw(im=image)
draw.text(xy=(340, 50), text=user_message, font=font, fill='white', anchor='mm',stroke_width=4,stroke_fill='black')
image.show()
async def send(message):
await client.send_message(client.get_channel(), File=discord.File(image))