【发布时间】:2022-11-20 01:43:04
【问题描述】:
我正在创建一个将创建语音通道的命令,它从用户那里获取一些参数并使用它创建一个语音通道。这是代码-
##TEST CREATE VC
@bot.command(name="createvoice")
async def createvoice(ctx, name = "Voice Channel", user_limit = 5,):
guild = ctx.message.author.guild
await guild.create_voice_channel(name, int(user_limit))
它使用 1 个参数正常工作,但是当我添加更多参数(例如 user_limit 或任何其他参数)时会出现问题。所以我输入 .createvoice testname 5 我得到了错误 -nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Guild.create_voice_channel() takes 2 positional arguments 但给出了3个
它仅在我不允许用户编辑参数并且我设置默认的不可编辑参数时有效 -
##TEST CREATE VC
@bot.command(name="createvoice")
async def createvoice(ctx, name = "Voice Channel"):
guild = ctx.message.author.guild
await guild.create_voice_channel(name, user_limit=5)
任何人都知道如何解决它?
【问题讨论】:
标签: python discord.py bots nextcord