所以我想向我的bot添加一个bug报告命令,这是我的代码:
@client.command()
async def bug(ctx):
guild = ctx.message.guild
BugChannel = await guild.create_text_channel(f'bugreport {ctx.author.name}')
await ctx.send(f'{ctx.author.mention} Describe your Bug in <#{BugChannel.id}>')
我希望只有作者和具有特定角色的人才能查看BugChannel
您可以创建一个具有权限dict的文本通道
您可以在文档中了解更多信息。
例如:
overwrites = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
ctx.author: discord.PermissionOverwrite(view_channel=True),
your_role: discord.PermissionOverwrite(view_channel=True)
}
channel = await ctx.guild.create_text_channel(f'bugreport {ctx.author.name}', overwrites=overwrites)
因此dict的键是Role或User,值是PermissionOverwrite。
你也应该只使用ctx.message.guild
的ctx.guild
插件