【问题标题】:Client = discord.client() TypeError: 'module' object is not callableClient = discord.client() TypeError: 'module' object is not callable
【发布时间】:2019-04-07 17:09:48
【问题描述】:

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

【问题讨论】:

标签: python discord.py


【解决方案1】:
Client = discord.Client() 

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

【讨论】:

    猜你喜欢
    • 2018-03-31
    • 1970-01-01
    • 2020-12-31
    • 1970-01-01
    • 2021-07-29
    • 1970-01-01
    • 2020-03-27
    • 2019-03-13
    • 1970-01-01
    相关资源
    最近更新 更多