There are two types of permissions: *Channel Permissions* and *Server Permissions*.
Permission Overrides
--------------------
Channel Permissions are expressed using an enum, ``PermValue``.
The three states are fairly straightforward -
``PermValue.Allow``: Allow the user to perform a permission.
``PermValue.Deny``: Deny the user to perform a permission.
``PermValue.Inherit``: The user will inherit the permission from its role.
Channel Permissions
-------------------
Channel Permissions are controlled using a set of flags:
@@ -31,27 +42,24 @@ Speak Voice Speak in a voice channel.
UseVoiceActivation Voice Use Voice Activation in a text channel (for large channels where PTT is preferred)
======================= ======= ==============
If a user has a permission, the value is true. Otherwise, it must be null.
Dual Channel Permissions
------------------------
You may also access a user's permissions in a channel with the DualChannelPermissions class.
Unlike normal ChannelPermissions, DualChannelPermissions hold three values:
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.
Each flag is a PermValue; see the section above.
Setting Channel Permissions
---------------------------
To set channel permissions, you may use either two ChannelPermissions, or one DualChannelPermissions.
To set channel permissions, create a new ``ChannelPermissionOverrides``, and specify the flags/values that you want to override.
Then, update the user, by doing ``Channel.AddPermissionsRule(_user, _overwrites);``
In the case of using two Channel Permissions, you must create one list of allowed permissions, and one list of denied permissions.
Otherwise, you can use a single DualChannelPermissions.
Roles
-----
Accessing/modifying permissions for roles is done the same way as user permissions, just using the overload for a Role. See above sections.
Server Permissions
------------------
Server Permissions can be accessed by ``Server.GetPermissions(User)``, and updated with ``Server.UpdatePermissions(User, ServerPermissions)``
Server Permissions can be viewed with ``User.ServerPermissions``, but **at the time of this writing** cannot be set.
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:
@@ -65,11 +73,6 @@ ManageChannels Server Manage channels that exist on the server (add, r
ManageServer Server Manage the server settings.
======================= ======= ==============
Roles
-----
Managing permissions for roles is much easier than for users in channels. For roles, just access the flag under `Role.Permissions`.
@@ -12,7 +22,7 @@ To use audio, you must install the AudioService to your DiscordClient.
_client.UsingAudio(x => // Opens an AudioConfigBuilder so we can configure our AudioService
{
x.Mode == AudioMode.Outgoing; // Tells the AudioService that we will only be sending audio
x.Mode = AudioMode.Outgoing; // Tells the AudioService that we will only be sending audio
});
Joining a Channel
@@ -96,7 +106,7 @@ You can `download NAudio from NuGet`_.
for (int i = byteCount; i < blockSize; i++)
buffer[i] = 0;
}
_vClient.Send(buffer, 0, blockSize) // Send the buffer to Discord
_vClient.Send(buffer, 0, blockSize); // Send the buffer to Discord
}
}
@@ -130,12 +140,12 @@ Broadcasting with FFmpeg
while (true) // Loop forever, so data will always be read
{
byteCount = process.StandardOutput.BaseStream // Access the underlying MemoryStream from the stdout of FFmpeg
.Read(buffer, 0, blockSize) // Read stdout into the buffer
.Read(buffer, 0, blockSize); // Read stdout into the buffer
if (byteCount == 0) // FFmpeg did not output anything
break; // Break out of the while(true) loop, since there was nothing to read.
_vClient.Send(buffer, 0, byteCount) // Send our data to Discord
_vClient.Send(buffer, 0, byteCount); // Send our data to Discord
}
_vClient.Wait(); // Wait for the Voice Client to finish sending data, as ffMPEG may have already finished buffering out a song, and it is unsafe to return now.
}
@@ -157,7 +167,7 @@ To prepare for Multi-Server Broadcasting, you must first enable it in your confi
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.