首页 > 解决方案 > 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"))

标签: pythondiscorddiscord.py

解决方案


第一个错误:你导入了discord.exe;它叫discord.ext

第二个错误:您将message参数分配给声明maker中的名称。on_message将其更改为on_message(message)以获取变量


推荐阅读