【发布时间】:2019-02-22 21:37:52
【问题描述】:
if message.content.upper().startswith("!HEADPATS"):
time.sleep(1)
with open('tenor.gif', 'rb') as picture:
await client.send_file(channel, picture)
我的 discord 机器人已经启动并运行(一切都是用 python 编写的)。我试图让机器人根据命令“!headpats”在频道中发送.gif。文件已上传并且代码编译正常,但是当通过不和谐调用 !headpats 命令时,编译器会将其吐出...
File "main.py", line 106, in on_message
await client.send_file(channel, picture)
NameError: name 'channel' is not defined
【问题讨论】:
-
您需要通过消息解析频道:
message.channel。这里某处有一个副本。 -
@PatrickHaugh stackoverflow.com/a/51468829/3271649 这就是我想...
-
@PatrickHaugh 这修补了一切。感谢您的帮助!
-
This is the closest I could find 实际上不是一个很好的副本。我会写一个正确的答案。
标签: python discord discord.py