我希望我的机器人在使用已定义的函数 (+play) 键入 +playtest 时播放特定歌曲,但出现错误提示
“Discord.ext.commands.errors.CommandInvokeError:命令引发异常:TypeError:'Command'对象不可调用”
整个代码工作得很好,除了这个命令我想知道 ctx.invoke 是否启用传递参数?或者我只是错过了一些东西
这是我的简短代码
import discord
import wavelink
from discord.ext import commands
import asyncio
from bs4 import BeautifulSoup
import requests
import datetime
queue = []
class Bot(commands.Bot):
def __init__(self):
super(Bot, self).__init__(command_prefix=['+'])
self.add_cog(Music(self))
async def on_ready(self):
print(f'Logged in as {self.user.name} | {self.user.id}')
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
if not hasattr(bot, 'wavelink'):
self.bot.wavelink = wavelink.Client(bot=self.bot)
self.bot.loop.create_task(self.start_nodes())
self.bot.remove_command("help")
async def start_nodes(self):
await self.bot.wait_until_ready()
await self.bot.wavelink.initiate_node(host='127.0.0.1',
port=80,
rest_uri='http://127.0.0.1:80',
password='testing',
identifier='TEST',
region='us_central')
@commands.command(name='connect')
async def connect_(self, …Run Code Online (Sandbox Code Playgroud)