Client = discord.client()TypeError:“模块”对象不可调用

时间:2018-11-03 21:46:12

标签: python discord.py

为什么我的代码中得到TypeError: 'module' object is not callable

import discord
from discord.ext.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("Bot is online and connected to Discord")
@client.event
async def on_message(message):
 if message.content == "cookie":
 await client.send_message(message.channel, ":cookie:")
client.run("...") 

完整错误:

  

错误:Client = discord.client()TypeError:“模块”对象不可调用

1 个答案:

答案 0 :(得分:0)

Client = discord.Client() 

完全删除此行。您不会在任何地方使用Client,并且discord.ext.commands.Botdiscord.Client的子类,因此您可以通过Client访问所有Bot属性。