python - Python Discord 机器人错误
问题描述
我正在用 python 制作一个不和谐的机器人。
在输出中它说我有 4 个错误。
我不懂为什么。
我已经安装了 discord.py,我正在使用 Python 3.5。
关于发生了什么的任何想法?
错误:
E0611:No name 'exe' in module 'discord'
E0602:Undefined variable 'message'
E0401:Unable to import 'discord.exe.commands'
E0602:Undefined variable 'message'
代码:
import discord
from discord.exe.commands import Bot
from discord.ext import commands
import asyncio
import time
Client = discord.Client()
client = commands.Bot(command_prefix = ";")
@client.event
async def on_ready():
print("The bot is sailing on the seven seas")
@client.event
async def on_message(maker):
if message.content == "cookie":
await client.send_message(message.channel, ":cookie:")
client.run("1NDE2--CHANGED--L24CMo"))
解决方案
第一个错误:你导入了discord.exe
;它叫discord.ext
第二个错误:您将message
参数分配给声明maker
中的名称。on_message
将其更改为on_message(message)
以获取变量
推荐阅读
- homebrew - 酿造安装nvm。nvm:找不到命令
- python - plt.bar - x 轴绘图不符合 x 轴标签(python 中的 matplotlib)
- python - Pandas ValueError:索引数据帧时,系列的真值不明确
- python - 使用查找数据框替换数据框中的值
- c - 位操作良好实践
- mysql - 优化 Yii2 MYSQL 查询
- javascript - 如何在反应中访问父组件状态
- c++ - Qt 不能在一个类中执行 HTTP 请求
- grails - Grails 依赖 org.springframework:spring-test:4.0.5.RELEASE
- android - 布局可见/消失时闪烁