【发布时间】:2021-09-21 18:36:12
【问题描述】:
@client.command()
async def ticket(ctx):
#new_channel = discord.utils.get(ctx.guild.text_channels, name=f"ticket-{message.author.name}")
name = 'TICKETS'
category = discord.utils.get(ctx.guild.categories, name=name)
foundchan = discord.utils.get(
ctx.guild.text_channels, name=f"Ticket-{ctx.author.name}")
if category is None:
await ctx.guild.create_category(name)
if foundchan is None:
channel = await ctx.guild.create_text_channel(f'Ticket-{ctx.author.name}', category=category)
if foundchan:
await ctx.channel.send("ALREADY A CHANNEL")
Role = discord.utils.get(ctx.guild.roles, name="Ticket Support")
if Role is None:
await ctx.guild.create_role(name="Ticket Support")
else:
await channel.set_permissions(ctx.author, read_messages=True, send_messages=True, view_channel=True)
await channel.set_permissions(ctx.guild.default_role, view_channel=False)
await channel.set_permissions(Role, view_channel=True, send_messages=True, add_reactions=True)
await channel.send(f"Hey, {ctx.author.mention}, thank you for creating a ticket; please be patient untill one of our staff member to come.")
await channel.send("**Say '*close' to close the ticket.**")
@client.command()
async def close(ctx):
foundchan = discord.utils.get(
ctx.guild.text_channels, name=f"ticket-{ctx.author.name}")
# await discord.Member.send(f"Your ticket was closed by {ctx.author.name}")
await foundchan.delete()
#Here is the full code everything is working but when i try to delete the channel it doesnt work and give me this error 'NoneType' object has no attribute 'delete'
我需要帮助,它给了我这个错误“NoneType”对象没有属性“删除”
非常感谢您的帮助,因为它已经很长时间了,我找不到解决方案,一切都好
【问题讨论】:
标签: python arrays python-3.x discord discord.py