Guild.create_text_channel() 得到参数 'name' 的多个值
Guild.create_text_channel() got multiple values for argument 'name'
我正在尝试创建一个用于设置服务器的机器人。但是,在设置类别名称后,我无法将频道附加到该类别。
@has_permissions(administrator=True)
@client.command(name='setup')
async def setup(ctx):
for channel in ctx.guild.channels:
await channel.delete()
for category in ctx.guild.categories:
await category.delete()
for category in server_types["categories"]:
await ctx.guild.create_category(category)
for channel in server_types["information"]:
await ctx.guild.create_text_channel(channel, name='information')
这是我的代码。
{
"categories":["information", "marketplace", "staff"],
"information":["welcome", "faq", "announcements", "partnerships", "deals-and-promotions"],
"marketplace":["general","purchase-info", "support", "bump"],
"staff":["staff-chat", "bot-test", "Company Voice Chat"]
}
这是 JSON 文件,我从中提取频道名称和类别。
每当我调用该命令时,我都会收到此错误:Guild.create_text_channel() 为参数 'name'.
获取了多个值
我不明白为什么会出现此错误,因为我只将一个值传递给名称参数。
在这种情况下,您需要ctx.guild.create_text_channel('information')
。
尝试传递 category
for channel in server_types["information"]:
category = discord.utils.get(ctx.guild.channels, name='information') # Better to pass an ID
await ctx.guild.create_text_channel(name=channel, category=category)
我正在尝试创建一个用于设置服务器的机器人。但是,在设置类别名称后,我无法将频道附加到该类别。
@has_permissions(administrator=True)
@client.command(name='setup')
async def setup(ctx):
for channel in ctx.guild.channels:
await channel.delete()
for category in ctx.guild.categories:
await category.delete()
for category in server_types["categories"]:
await ctx.guild.create_category(category)
for channel in server_types["information"]:
await ctx.guild.create_text_channel(channel, name='information')
这是我的代码。
{
"categories":["information", "marketplace", "staff"],
"information":["welcome", "faq", "announcements", "partnerships", "deals-and-promotions"],
"marketplace":["general","purchase-info", "support", "bump"],
"staff":["staff-chat", "bot-test", "Company Voice Chat"]
}
这是 JSON 文件,我从中提取频道名称和类别。
每当我调用该命令时,我都会收到此错误:Guild.create_text_channel() 为参数 'name'.
获取了多个值我不明白为什么会出现此错误,因为我只将一个值传递给名称参数。
在这种情况下,您需要ctx.guild.create_text_channel('information')
。
尝试传递 category
for channel in server_types["information"]:
category = discord.utils.get(ctx.guild.channels, name='information') # Better to pass an ID
await ctx.guild.create_text_channel(name=channel, category=category)