You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

permissions.rst 3.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Permissions
  2. ===========
  3. There are two types of permissions: *Channel Permissions* and *Server Permissions*.
  4. Channel Permissions
  5. -------------------
  6. Channel Permissions are controlled using a set of flags:
  7. ======================= ======= ==============
  8. Flag Type Description
  9. ======================= ======= ==============
  10. AttachFiles Text Send files to a channel.
  11. Connect Voice Connect to a voice channel.
  12. CreateInstantInvite General Create an invite to the channel.
  13. DeafenMembers Voice Prevent users of a voice channel from hearing other users (server-wide).
  14. EmbedLinks Text Create embedded links.
  15. ManageChannel General Manage a channel.
  16. ManageMessages Text Remove messages in a channel.
  17. ManagePermissions General Manage the permissions of a channel.
  18. MentionEveryone Text Use @everyone in a channel.
  19. MoveMembers Voice Move members around in voice channels.
  20. MuteMembers Voice Mute users of a voice channel (server-wide).
  21. ReadMessageHistory Text Read the chat history of a voice channel.
  22. ReadMessages Text Read any messages in a text channel; exposes the text channel to users.
  23. SendMessages Text Send messages in a text channel.
  24. SendTTSMessages Text Send TTS messages in a text channel.
  25. Speak Voice Speak in a voice channel.
  26. UseVoiceActivation Voice Use Voice Activation in a text channel (for large channels where PTT is preferred)
  27. ======================= ======= ==============
  28. If a user has a permission, the value is true. Otherwise, it must be null.
  29. Dual Channel Permissions
  30. ------------------------
  31. You may also access a user's permissions in a channel with the DualChannelPermissions class.
  32. Unlike normal ChannelPermissions, DualChannelPermissions hold three values:
  33. If a user has a permission, the value is true. If a user is denied a permission, it will be false. If the permission is not set, the value will return null.
  34. Setting Channel Permissions
  35. ---------------------------
  36. To set channel permissions, you may use either two ChannelPermissions, or one DualChannelPermissions.
  37. In the case of using two Channel Permissions, you must create one list of allowed permissions, and one list of denied permissions.
  38. Otherwise, you can use a single DualChannelPermissions.
  39. Server Permissions
  40. ------------------
  41. Server Permissions can be accessed by ``Server.GetPermissions(User)``, and updated with ``Server.UpdatePermissions(User, ServerPermissions)``
  42. A user's server permissions also contain the default values for it's channel permissions, so the channel permissions listed above are also valid flags for Server Permissions. There are also a few extra Server Permissions:
  43. ======================= ======= ==============
  44. Flag Type Description
  45. ======================= ======= ==============
  46. BanMembers Server Ban users from the server.
  47. KickMembers Server Kick users from the server. They can still rejoin.
  48. ManageRoles Server Manage roles on the server, and their permissions.
  49. ManageChannels Server Manage channels that exist on the server (add, remove them)
  50. ManageServer Server Manage the server settings.
  51. Roles
  52. -----
  53. Managing permissions for roles is much easier than for users in channels. For roles, just access the flag under `Role.Permissions`.
  54. Example
  55. -------
  56. .. literalinclude:: /samples/permissions.cs
  57. :language: csharp6
  58. :tab-width: 2