我在使用 discord.py 时遇到了一些问题,我想用 discord.py 发送 jpeg 文件,但它给了我错误。
消息": "未定义变量'channel'
import discord
if message.content.startswith('!hello'):
await channel.send('Hello', file=discord.File('fff1.jpeg', spoiler=False))
你没有定义 channel。因此,Python 不知道你想把消息发送到哪里。如果你已经有了消息,你可以使用 message.channel 代替 channel.在它来自的同一个通道中发送它。
另外,如果您只是在使用命令,您可能会发现尝试使用 命令类 从discord.ext.来的。