我正在用nextcord.py做一个工单系统,这是一个discord.py维护的分支。我的setup命令要求您指定一个类别ID,将在其中创建新的票证通道。下面是命令:
@commands.command()
async def setup(self, client, context, message : nextcord.Message=None, category : nextcord.CategoryChannel=None):
if message is None or category is None:
await context.channel.send("Ticket system configuration failure.")
return
client.ticket_configs[context.guild.id] = [message.id, message.channel.id, category.id]
async with aiofiles.open("ticket_configs.txt", mode="r") as file:
data = await file.readlines()
async with aiofiles.open("ticket_configs.txt", mode="w") as file:
await file.write(f"{context.guild.id} {message.id} {message.channel.id} {category.id}\n")
for line in data:
if int(line.split(" ")[0]) != context.guild.id:
await file.write(line)
await message.add_reaction(u"\U0001F3AB")
await context.channel.send("Ticket system successfully configured!")当我在不一致的情况下运行此命令时,它会在终端中引发以下错误:
nextcord.ext.commands.errors.ChannelNotFound: Channel "None" not found.当我从category : nextcord.CategoryChannel中删除=None时,也会引发此错误。
所有的帮助都将不胜感激!谢谢。
发布于 2021-09-11 20:44:17
好的,这里有一些潜在的问题:
nextcord.Client,则不能使用nextcord.ext.commands,因此请使用nextcord.ext.commands.Bot而不是async def setup(self, client, context, ...,但是如果您使用的是齿轮,您可以使用< client >D9(如果您在__init__中定义了它)访问Nextcord,并且在实际的命令函数中,您只需确保您不能仅仅因为Nextcord在加载齿轮时运行setup就调用函数setup,因此可以这样做:@commands.command(name='setup')
async def setupCommand(...):https://stackoverflow.com/questions/69146043
复制相似问题