嘿,我最近开始编码,现在我想做一个可以加入Voice Chanel的Discord机器人。当我执行此操作时:
BOT_PREFIX = '%'
bot = commands.Bot(command_prefix=BOT_PREFIX)
@bot.commmands(pass_context=True, aliases=['j', 'joi'])
async def join (ctx):
channel = ctx.message.author.voice.channel
voicechannel = await channel.connect()
出现此错误后:
Traceback (most recent call last):
File "C:\DEV\Python\Einführung\venv\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:/DEV/Python/pythonProject1/venv/Discord Bot/Bot.py", line 23, in on_message
@bot.commmands(pass_context=True, aliases=['j', 'joi'])
AttributeError: 'Bot' object has no attribute 'commmands'
答案 0 :(得分:0)
它的@bot.command()
不是@bot.commands
。在这种情况下,不能使用命令。
也可以
channel = ctx.author.voice.channel
而非ctx.message.author.voice.channel
并且不需要为 await channel.connect()
传递变量。