Client = Discord.client() TypeError: 'module' 对象不可调用

2024-03-30

为什么我会得到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:“模块”对象不可调用


Client = discord.Client() 

完全删除此行。你没有使用Client任何地方,以及discord.ext.commands.Bot是一个子类discord.Client,这样您就可以访问所有Client属性通过Bot.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Client = Discord.client() TypeError: 'module' 对象不可调用 的相关文章

随机推荐