代码:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
client = commands.bot(command_prefix = ".")
@client.event
async def on_ready():
print("I'm in!")
@client.event
async def on_message(message):
print(message.content)
if message.author == client.user:
return
if message.content.startswith("hello"):
await message.channel.send('hello!')
@client.event
async def on_member_join(member):
print("someone's here!")
@client.event
async def on_typing(channel, user, when):
print("Lol, someone is typing!!1!")
@client.command()
async def answer(ans):
await ans.send("Here is your answer")
错误:
文件“ /Users/me/documents/bot/bot.py”,第5行,在 客户端= commands.bot(command_prefix =“。”) TypeError:“模块”对象不可调用
我是否还需要安装其他东西作为discord.py?
答案 0 :(得分:1)
注意小写/大写! commands.bot
确实是一个模块https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/bot.py
commands.bot.Bot
是可调用对象。由于您已经导入了Bot
,只需使用它即可。
client = Bot(command_prefix = ".")
答案 1 :(得分:0)
导入模件时,您可能需要包括模块前缀。
client = discord.commands.bot(command_prefix = ".")
如果这不起作用,我将无能为力。抱歉!
答案 2 :(得分:0)
您有错字,需要使用stdlib.h
。