discord.ext.commands.errors.CommandInvokeError:命令引发了异常:TypeError:'list'对象不可调用

我正在用Python(discordbot.py 0.2.3a3)编写一个针对Discord的机器人。我需要一个机器人来播放音乐。

import asyncio
import discord
from discord.ext import commands
from discord.ext.commands import bot
bot = commands.Bot(command_prefix='!')
from discord.utils import get
songs = asyncio.Queue()
play_next_song = asyncio.Event()



async def audio_player_task():
    while True:
        play_next_song.clear()
        current = await songs.get()
        current.start()
        await play_next_song.wait()


def toggle_next():
    bot.loop.call_soon_threadsafe(play_next_song.set)

@bot.command(pass_context=True)
async def play(ctx,url):
    if not bot.voice_clients(ctx.message.guild):
        voice = await bot.join_voice_channel(ctx.message.author.voice_channel)
    else:
       voice = bot.voice_client_in(ctx.message.guild)

    player = await voice.create_ytdl_player(url,after=toggle_next)
    await songs.put(player)

bot.loop.create_task(audio_player_task())

当我尝试播放音乐时,在上面代码的第25行出现以下错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception:

TypeError: 'list' object is not callable
shen774013972 回答:discord.ext.commands.errors.CommandInvokeError:命令引发了异常:TypeError:'list'对象不可调用

您是否安装discord.py或discordbot.py?

discordbot discord 的扩展 我想问题是您使用的包装。

尝试:

$ pip install -U discord.py

如果没有,请确保正确配置了.json文件

,

bot.voice_clients是一个列表。您可以使用ctx.voice_client

在公会中访问漫游器的语音​​客户端
if ctx.voice_client is not None:
本文链接:https://www.f2er.com/3019257.html

大家都在问