fix: voice perms not retaining text perms. (#2329)
* Init * Fix switch casting as text and not as voice * rearrange to have voice fall through the switch first Co-authored-by: Quin Lynch <lynchquin@gmail.com>
This commit is contained in:
@@ -7,30 +7,55 @@ namespace Discord
|
|||||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
public struct ChannelPermissions
|
public struct ChannelPermissions
|
||||||
{
|
{
|
||||||
/// <summary> Gets a blank <see cref="ChannelPermissions"/> that grants no permissions.</summary>
|
/// <summary>
|
||||||
/// <returns> A <see cref="ChannelPermissions"/> structure that does not contain any set permissions.</returns>
|
/// Gets a blank <see cref="ChannelPermissions"/> that grants no permissions.
|
||||||
public static readonly ChannelPermissions None = new ChannelPermissions();
|
/// </summary>
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for text channels.</summary>
|
/// <returns>
|
||||||
public static readonly ChannelPermissions Text = new ChannelPermissions(0b0_11111_0101100_0000000_1111111110001_010001);
|
/// A <see cref="ChannelPermissions"/> structure that does not contain any set permissions.
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for voice channels.</summary>
|
/// </returns>
|
||||||
public static readonly ChannelPermissions Voice = new ChannelPermissions(0b1_00000_0000100_1111110_0000000011100_010001);
|
public static readonly ChannelPermissions None = new();
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for stage channels.</summary>
|
|
||||||
public static readonly ChannelPermissions Stage = new ChannelPermissions(0b0_00000_1000100_0111010_0000000010000_010001);
|
/// <summary>
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels.</summary>
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for text channels.
|
||||||
public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001);
|
/// </summary>
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for direct message channels.</summary>
|
public static readonly ChannelPermissions Text = new(0b0_11111_0101100_0000000_1111111110001_010001);
|
||||||
public static readonly ChannelPermissions DM = new ChannelPermissions(0b00000_1000110_1011100110001_000000);
|
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for group channels.</summary>
|
/// <summary>
|
||||||
public static readonly ChannelPermissions Group = new ChannelPermissions(0b00000_1000110_0001101100000_000000);
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for voice channels.
|
||||||
/// <summary> Gets a <see cref="ChannelPermissions"/> that grants all permissions for a given channel type.</summary>
|
/// </summary>
|
||||||
|
public static readonly ChannelPermissions Voice = new(0b1_11111_0101100_1111110_1111111111101_010001); // (0b1_00000_0000100_1111110_0000000011100_010001 (<- voice only perms) |= Text)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for stage channels.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ChannelPermissions Stage = new(0b0_00000_1000100_0111010_0000000010000_010001);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ChannelPermissions Category = new(0b01100_1111110_1111111110001_010001);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for direct message channels.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ChannelPermissions DM = new(0b00000_1000110_1011100110001_000000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for group channels.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ChannelPermissions Group = new(0b00000_1000110_0001101100000_000000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for a given channel type.
|
||||||
|
/// </summary>
|
||||||
/// <exception cref="ArgumentException">Unknown channel type.</exception>
|
/// <exception cref="ArgumentException">Unknown channel type.</exception>
|
||||||
public static ChannelPermissions All(IChannel channel)
|
public static ChannelPermissions All(IChannel channel)
|
||||||
{
|
{
|
||||||
return channel switch
|
return channel switch
|
||||||
{
|
{
|
||||||
ITextChannel _ => Text,
|
|
||||||
IStageChannel _ => Stage,
|
IStageChannel _ => Stage,
|
||||||
IVoiceChannel _ => Voice,
|
IVoiceChannel _ => Voice,
|
||||||
|
ITextChannel _ => Text,
|
||||||
ICategoryChannel _ => Category,
|
ICategoryChannel _ => Category,
|
||||||
IDMChannel _ => DM,
|
IDMChannel _ => DM,
|
||||||
IGroupChannel _ => Group,
|
IGroupChannel _ => Group,
|
||||||
|
|||||||
Reference in New Issue
Block a user