如何解决这个不一致的声音Bot错误?

问题描述

嘿,我最近开始编码,现在我想做一个可以加入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,'joi'])
AttributeError: 'Bot' object has no attribute 'commmands'

解决方法

它的@bot.command()不是@bot.commands。在这种情况下,不能使用命令。

也可以 channel = ctx.author.voice.channel而非ctx.message.author.voice.channel 并且不需要为 await channel.connect()传递变量。