python - 如何设置用户特定的频道权限 discord.py
问题描述
我正在尝试创建一个支持系统,用户可以在其中发言;support reason
,然后使用权限创建一个频道,供管理员和非管理员用户交谈和讨论帮助!这是我的代码:
@command()
async def support(self, ctx, *, reason = None):
guildid = ctx.guild.id
guild = ctx.guild
user = ctx.author
amount2 = 1
await ctx.channel.purge(limit=amount2)
channel = await guild.create_text_channel(f'Ticket {user}')
await channel.set_permissions(ctx.guild.default_role, send_messages=False, read_messages=False)
perms = channel.overwrites_for(user)
await channel.set_permissions(user, view_channel=not perms.view_channel)
await channel.set_permissions(user, read_message_history=not perms.read_message_history)
await channel.set_permissions(user, send_messages=not perms.send_messages)
await channel.send(f"{user.mention}")
supem = discord.Embed(title=f"{user} requested support.", description= "", color=0x00ff00)
supem.add_field(name="Reason", value=f"``{reason}``")
supem.set_footer(text=f"Either an admin or support staff will be with you shortly...")
await channel.send(embed=supem)
但我无法获得工作权限,我希望用户能够看到频道、发送消息和查看消息历史记录。请解释为什么我的权限设置部分不起作用。我没有收到任何错误,它只是没有分配 view_channel 权限。
解决方案
推荐阅读
- javascript - 如何读取 1 个标志位并同时获取整数
- python - 最小垂直切片总和
- crystal-lang - 程序在运行 Crystal 程序时收到但未处理信号 IOT (6)
- bash - 参数以一种奇怪的方式组合
- reactjs - 如何在样式化组件 React 中获取 refs.value?
- prolog - Prolog graph representation missing fact
- android - Android Studio 3.1.4 中的 logcat 在哪里?
- javascript - 我可以使用一个对象作为其他对象的模板吗?
- javascript - 速记方法定义
- java - Tizen TV - 部署引发错误