Python discord.ext.commands.errors.CommandInvokeError:命令引发异常:TypeError:';列表';对象不可调用
我正在用Python为Discord编写一个bot(discordbot.py 0.2.3a3)。我需要一个机器人来播放音乐Python discord.ext.commands.errors.CommandInvokeError:命令引发异常:TypeError:';列表';对象不可调用,python,bots,discord.py,Python,Bots,Discord.py,我正在用Python为Discord编写一个bot(discordbot.py 0.2.3a3)。我需要一个机器人来播放音乐 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.Qu
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
您是否安装discord.py或discordbot.py discordbot是discord 我想问题在于你使用的软件包 试试看:
$ pip install -U discord.py
如果没有,请确保.json文件已正确配置
bot.voice\u客户端
是一个列表。您可以通过使用访问公会中机器人的语音客户端
$ pip install -U discord.py
错误发生在哪一行?如果不是bot.voice\u客户端(ctx.message.guild):根据
的说法,voice\u客户端不是一个函数,而是一个列表。现在在“voice=bot.voice\u client\u in(ctx.message.guild)”行上,它给出了一个错误:AttributeError:“bot”对象没有属性“voice\u client\u in”。如果我更改为“voice=ctx.voice_client(ctx.message.guild)”,我会得到以下错误:discord.ext.commands.errors.CommandInvokeError:Command引发异常:TypeError:“NoneType”对象不可调用我建议从discord.py存储库查看并放弃discordbot.py。看起来该项目已经很长时间没有更新了,discord.py从那时起经历了几次突破性的更改。