微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使不和谐关闭票务通道?

如何解决如何使不和谐关闭票务通道?

@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,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”对象没有属性删除

真的很感谢您的帮助,因为它已经很长时间了,我无法找到解决方案,一切皆有可能

解决方法

您没有获得正确的频道名称,创建时您正在使用它。

MY_FILE_NAME_H

您使用带有大写 channel = await ctx.guild.create_text_channel(f'Ticket-{ctx.author.name}',category=category) Ticket 但在获取频道时您使用了 T

ticket

另一个建议使用 foundchan = discord.utils.get(ctx.guild.text_channels,name=f"ticket-{ctx.author.name}") ,因为它与名称不同,无法更改

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?