ticket_number = int(data["ticket-counter"])
ticket_number += 1
ticket_channel = await ctx.guild.create_text_channel("ticket-{}".format(ticket_number))
await ticket_channel.set_permissions(ctx.guild.get_role(ctx.guild.id), send_messages=False, read_messages=False)
有人可以使用示例代码进行指导,假设频道是在一个类别中创建的。
答案 0 :(得分:1)
首先,您需要获取您希望频道所在的类别
# By name
category = discord.utils.get(ctx.guild.categories, name="some name")
# By ID (you can also use `Guild.get_channel`
category = discord.utils.get(ctx.guild.categories, id=123123)
您现在可以在将频道创建为 kwarg 时传递它
ticket_channel = await ctx.guild.create_text_channel("...", category=category)
您也可以在类别对象本身内创建频道
ticket_channel = await category.create_text_channel("...")