Skip to content

Commit

Permalink
core: add PrioritySpeaker to Permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
foxbot committed Aug 1, 2018
1 parent 5dad0fa commit c1d7818
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
@@ -1,4 +1,4 @@
using System;
using System;

namespace Discord
{
Expand Down Expand Up @@ -30,6 +30,7 @@ public enum ChannelPermission : ulong
DeafenMembers = 0x00_80_00_00,
MoveMembers = 0x01_00_00_00,
UseVAD = 0x02_00_00_00,
PrioritySpeaker = 0x00_00_01_00,

// More General
ManageRoles = 0x10_00_00_00,
Expand Down
11 changes: 9 additions & 2 deletions src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs
Expand Up @@ -12,7 +12,7 @@ public struct ChannelPermissions
/// <summary> Gets a ChannelPermissions that grants all permissions for text channels. </summary>
public static readonly ChannelPermissions Text = new ChannelPermissions(0b01100_0000000_1111111110001_010001);
/// <summary> Gets a ChannelPermissions that grants all permissions for voice channels. </summary>
public static readonly ChannelPermissions Voice = new ChannelPermissions(0b00100_1111110_0000000010000_010001);
public static readonly ChannelPermissions Voice = new ChannelPermissions(0b00100_1111110_0000000010100_010001);
/// <summary> Gets a ChannelPermissions that grants all permissions for category channels. </summary>
public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001);
/// <summary> Gets a ChannelPermissions that grants all permissions for direct message channels. </summary>
Expand Down Expand Up @@ -78,6 +78,8 @@ public static ChannelPermissions All(IChannel channel)
public bool MoveMembers => Permissions.GetValue(RawValue, ChannelPermission.MoveMembers);
/// <summary> If True, a user may use voice-activity-detection rather than push-to-talk. </summary>
public bool UseVAD => Permissions.GetValue(RawValue, ChannelPermission.UseVAD);
/// <summary> If True, a user may use priority speaker in a voice channel. </summary>
public bool PrioritySpeaker => Permissions.GetValue(RawValue, ChannelPermission.PrioritySpeaker);

/// <summary> If True, a user may adjust role permissions. This also implictly grants all other permissions. </summary>
public bool ManageRoles => Permissions.GetValue(RawValue, ChannelPermission.ManageRoles);
Expand Down Expand Up @@ -106,6 +108,7 @@ public static ChannelPermissions All(IChannel channel)
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? prioritySpeaker = null,
bool? manageRoles = null,
bool? manageWebhooks = null)
{
Expand All @@ -129,6 +132,7 @@ public static ChannelPermissions All(IChannel channel)
Permissions.SetValue(ref value, deafenMembers, ChannelPermission.DeafenMembers);
Permissions.SetValue(ref value, moveMembers, ChannelPermission.MoveMembers);
Permissions.SetValue(ref value, useVoiceActivation, ChannelPermission.UseVAD);
Permissions.SetValue(ref value, prioritySpeaker, ChannelPermission.PrioritySpeaker);
Permissions.SetValue(ref value, manageRoles, ChannelPermission.ManageRoles);
Permissions.SetValue(ref value, manageWebhooks, ChannelPermission.ManageWebhooks);

Expand All @@ -155,11 +159,12 @@ public static ChannelPermissions All(IChannel channel)
bool deafenMembers = false,
bool moveMembers = false,
bool useVoiceActivation = false,
bool prioritySpeaker = false,
bool manageRoles = false,
bool manageWebhooks = false)
: this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages,
embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect,
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks)
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, manageRoles, manageWebhooks)
{ }

/// <summary> Creates a new ChannelPermissions from this one, changing the provided non-null permissions. </summary>
Expand All @@ -182,6 +187,7 @@ public static ChannelPermissions All(IChannel channel)
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? prioritySpeaker = null,
bool? manageRoles = null,
bool? manageWebhooks = null)
=> new ChannelPermissions(RawValue,
Expand All @@ -203,6 +209,7 @@ public static ChannelPermissions All(IChannel channel)
deafenMembers,
moveMembers,
useVoiceActivation,
prioritySpeaker,
manageRoles,
manageWebhooks);

Expand Down
Expand Up @@ -35,6 +35,7 @@ public enum GuildPermission : ulong
DeafenMembers = 0x00_80_00_00,
MoveMembers = 0x01_00_00_00,
UseVAD = 0x02_00_00_00,
PrioritySpeaker = 0x00_00_01_00,

// General 2
ChangeNickname = 0x04_00_00_00,
Expand Down
11 changes: 9 additions & 2 deletions src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
Expand Up @@ -12,7 +12,7 @@ public struct GuildPermissions
/// <summary> Gets a GuildPermissions that grants all guild permissions for webhook users. </summary>
public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000);
/// <summary> Gets a GuildPermissions that grants all guild permissions. </summary>
public static readonly GuildPermissions All = new GuildPermissions(0b11111_1111110_1111111110011_111111);
public static readonly GuildPermissions All = new GuildPermissions(0b11111_1111110_1111111110111_111111);

/// <summary> Gets a packed value representing all the permissions in this GuildPermissions. </summary>
public ulong RawValue { get; }
Expand Down Expand Up @@ -69,6 +69,8 @@ public struct GuildPermissions
public bool MoveMembers => Permissions.GetValue(RawValue, GuildPermission.MoveMembers);
/// <summary> If True, a user may use voice-activity-detection rather than push-to-talk. </summary>
public bool UseVAD => Permissions.GetValue(RawValue, GuildPermission.UseVAD);
/// <summary> If True, a user may use priority speaker in a voice channel. </summary>
public bool PrioritySpeaker => Permissions.GetValue(RawValue, ChannelPermission.PrioritySpeaker);

/// <summary> If True, a user may change their own nickname. </summary>
public bool ChangeNickname => Permissions.GetValue(RawValue, GuildPermission.ChangeNickname);
Expand Down Expand Up @@ -108,6 +110,7 @@ public struct GuildPermissions
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? prioritySpeaker = null,
bool? changeNickname = null,
bool? manageNicknames = null,
bool? manageRoles = null,
Expand Down Expand Up @@ -139,6 +142,7 @@ public struct GuildPermissions
Permissions.SetValue(ref value, deafenMembers, GuildPermission.DeafenMembers);
Permissions.SetValue(ref value, moveMembers, GuildPermission.MoveMembers);
Permissions.SetValue(ref value, useVoiceActivation, GuildPermission.UseVAD);
Permissions.SetValue(ref value, prioritySpeaker, GuildPermission.PrioritySpeaker);
Permissions.SetValue(ref value, changeNickname, GuildPermission.ChangeNickname);
Permissions.SetValue(ref value, manageNicknames, GuildPermission.ManageNicknames);
Permissions.SetValue(ref value, manageRoles, GuildPermission.ManageRoles);
Expand Down Expand Up @@ -173,6 +177,7 @@ public struct GuildPermissions
bool deafenMembers = false,
bool moveMembers = false,
bool useVoiceActivation = false,
bool prioritySpeaker = false,
bool changeNickname = false,
bool manageNicknames = false,
bool manageRoles = false,
Expand Down Expand Up @@ -203,6 +208,7 @@ public struct GuildPermissions
deafenMembers: deafenMembers,
moveMembers: moveMembers,
useVoiceActivation: useVoiceActivation,
prioritySpeaker: prioritySpeaker,
changeNickname: changeNickname,
manageNicknames: manageNicknames,
manageWebhooks: manageWebhooks,
Expand Down Expand Up @@ -234,6 +240,7 @@ public struct GuildPermissions
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? prioritySpeaker = null,
bool? changeNickname = null,
bool? manageNicknames = null,
bool? manageRoles = null,
Expand All @@ -242,7 +249,7 @@ public struct GuildPermissions
=> new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions,
viewAuditLog, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers,
useVoiceActivation, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojis);
useVoiceActivation, prioritySpeaker, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojis);

public bool Has(GuildPermission permission) => Permissions.GetValue(RawValue, permission);

Expand Down

0 comments on commit c1d7818

Please sign in to comment.