简体   繁体   English

公共角色权限有时不起作用

[英]Public Role permissions sometimes doesn't work

I create with a action a new channel, i wanna deny the reading permission for the public role but it works only sometimes.我通过操作创建了一个新频道,我想拒绝公共角色的阅读权限,但它仅在某些时候有效。 Sometimes everybody can read it sometimes the permission is denied.有时每个人都可以阅读,有时权限被拒绝。 Can anybody help me?有谁能够帮我?

TextChannel channel = cat.createTextChannel(getFormatedName()  + "-ticket-" + User.getId())
                .addPermissionOverride(guild.getPublicRole(), null, EnumSet.of(Permission.MESSAGE_READ))
                .addPermissionOverride(getAdminRole(), EnumSet.of(Permission.MESSAGE_READ), null)
                .addPermissionOverride(guild.getMemberById(User.getId()), EnumSet.of(Permission.MESSAGE_READ), null)
                .complete();

This seems to be a bug in versions older than 4.2.0_174 .这似乎是早于4.2.0_174的版本中的错误。 I recommend you update to fix this issue.我建议您更新以解决此问题。

Why does this happen?为什么会这样?

When you create a channel in a category using Category#createTextChannel it will first apply all the permission overrides from that category.当您使用 Category#createTextChannel 在类别中创建频道时,它将首先应用该类别中的所有权限覆盖。 After this, you apply your manual overrides which might collide with the existing overrides from the category.在此之后,您应用可能与类别中的现有覆盖冲突的手动覆盖。 Due to a bug this would end up with 2 overrides in the request.由于一个错误,这最终会在请求中出现 2 次覆盖。 This causes inconsistent output that can cause strange results.这会导致不一致的 output 可能导致奇怪的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM