为什么我的代码中得到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:“模块”对象不可调用
答案 0 :(得分:0)
Client = discord.Client()
完全删除此行。您不会在任何地方使用Client
,并且discord.ext.commands.Bot
是discord.Client
的子类,因此您可以通过Client
访问所有Bot
属性。>