所以我正在尝试创建一个票务系统,其中机器人创建一个频道并将其放在不同频道的类别中(例如:bot-cmds}
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=">")
@client.command() #or bot
async def ticket(ctx):
guild = ctx.guild
category = discord.utils.get(guild.categories, name="category_name")
if category is None:
await guild.create_category_channel(name="category_name")
ticket = await guild.create_text_channel(name=f"{ctx.author.name}#{ctx.author.discriminator}'s ticket")
await ctx.send(f"Here's your ticket #{ticket}")
await ctx.channel.edit(category=category)
但是它将 bot-cmds 放在了类别中,那么我该如何解决?
答案 0 :(得分:0)
我猜您想在另一个频道类别中创建票务频道?
如果这是正确的,你可以这样做
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=">")
@client.command() #or bot
async def ticket(ctx):
guild = ctx.guild
category = discord.utils.get(guild.categories, name="category_name")
# Gets the category of that channel (used your version so I don't know if this works)
ticket = await ctx.guild.create_text_channel(f"{ctx.author.name}#{ctx.author.discriminator}'s ticket", category=category)
# Creates the text channel in the specified category
await ticket.send(f"Here's your ticket #{ticket}")