Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在discordpy中创建一个类别,其权限只有特定角色才能加入并键入_Python_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python 在discordpy中创建一个类别,其权限只有特定角色才能加入并键入

Python 在discordpy中创建一个类别,其权限只有特定角色才能加入并键入,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,希望使文本和语音频道的类别仅由特定角色(位于同一命令中)可见。。。这是我到目前为止所拥有的,但在向类别添加权限时,我有点不知所措 @bot.command(pass\u context=True) @commands.has_权限(kick_members=True) 异步def createfriendgroup(ctx,角色名称): guild=ctx.guild 等待公会。创建类别(角色名称) category=discord.utils.get(ctx.guild.categories,

希望使文本和语音频道的类别仅由特定角色(位于同一命令中)可见。。。这是我到目前为止所拥有的,但在向类别添加权限时,我有点不知所措

@bot.command(pass\u context=True)
@commands.has_权限(kick_members=True)
异步def createfriendgroup(ctx,角色名称):
guild=ctx.guild
等待公会。创建类别(角色名称)
category=discord.utils.get(ctx.guild.categories,name=role\u name)
等待公会。创建角色(名称=角色名称)
等待公会。创建文本频道(f“{role\u name}-private tc”,category=category,sync\u permissions=True)
等待公会。创建语音频道(f“{role\u name}-private vc”,category=category,sync\u permissions=True)

所以我已经创建了类别、文本和语音频道(都具有同步权限),但是现在知道如何在类别内设置权限了,所以任何帮助都绝对令人惊讶!谢谢大家!

你有两个选择,要么做,要么做

  • 设置权限()
  • @bot.command()
    @commands.has_权限(kick_members=True)
    异步def createfriendgroup(ctx,角色名称):
    guild=ctx.guild
    类别=等待公会。创建类别(角色名称)
    角色=等待公会。创建角色(名称=角色名称)
    等待类别。设置权限(角色、读取消息=True、发送消息=True、连接=True、讲话=True)
    等待类别。设置权限(ctx.guild.default\u角色,read\u messages=False,connect=False)
    等待公会。创建文本频道(f“{role\u name}-private tc”,category=category,sync\u permissions=True)
    等待公会。创建语音频道(f“{role\u name}-private vc”,category=category,sync\u permissions=True)
    
  • 使用覆盖
  • @bot.command()
    @commands.has_权限(kick_members=True)
    异步def createfriendgroup(ctx,角色名称):
    guild=ctx.guild
    类别=等待公会。创建类别(角色名称)
    角色=等待公会。创建角色(名称=角色名称)
    覆盖={
    ctx.guild.default_角色:discord.PermissionOverwrite(read_messages=False,connect=False),
    角色:discord.PermissionOverwrite(read_messages=True、send_messages=True、connect=True、speak=True)
    }
    等待类别。编辑(覆盖=覆盖)
    等待公会。创建文本频道(f“{role\u name}-private tc”,category=category,sync\u permissions=True)
    等待公会。创建语音频道(f“{role\u name}-private vc”,category=category,sync\u permissions=True)
    
    非常感谢!这真的弄清楚了如何使用权限和类别。设置权限,非常感谢!