Browse Source

Added SendMessagesInThreads and StartEmbeddedActivities. (#175)

* Added SendMessagesInThreads and StartEmbeddedActivities.

Adjusted owner perms.
Change UsePublicThreads -> CreatePublicThreads
Change UsePrivateThreads -> CreatePrivateThreads

* removed extra ///

* Added UsePublicThreads and UsePrivateThreads back with Obsolete Attribute

* removed 'false' from Obsolete Attribute
pull/1923/head
drobbins329 GitHub 3 years ago
parent
commit
5987af766a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 23 deletions
  1. +23
    -5
      src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs
  2. +33
    -18
      src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs

+ 23
- 5
src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs View File

@@ -192,17 +192,35 @@ namespace Discord
/// </remarks>
ManageThreads = 0x04_00_00_00_00,
/// <summary>
/// Allows for creating and participating in threads.
/// Allows for creating public threads.
/// </summary>
UsePublicThreads = 0x08_00_00_00_00,
CreatePublicThreads = 0x08_00_00_00_00,
/// <summary>
/// Allows for creating and participating in private threads.
/// Allows for creating private threads.
/// </summary>
UsePrivateThreads = 0x10_00_00_00_00,
CreatePrivateThreads = 0x10_00_00_00_00,
/// <summary>
/// Allows for creating public threads.
/// </summary>
[Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads")]
UsePublicThreads = 0x08_00_00_00_00,
/// <summary>
/// Allows for creating private threads.
/// </summary>
[Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads")]
UsePrivateThreads = 0x10_00_00_00_00,
/// <summary>
/// Allows the usage of custom stickers from other servers.
/// </summary>
UseExternalStickers = 0x20_00_00_00_00
UseExternalStickers = 0x20_00_00_00_00,
/// <summary>
/// Allows for sending messages in threads.
/// </summary>
SendMessagesInThreads = 0x40_00_00_00_00,
/// <summary>
/// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel.
/// </summary>
StartEmbeddedActivities = 0x80_00_00_00_00

}
}

+ 33
- 18
src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs View File

@@ -12,7 +12,7 @@ namespace Discord
/// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions for webhook users. </summary>
public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000);
/// <summary> Gets a <see cref="GuildPermissions"/> that grants all guild permissions. </summary>
public static readonly GuildPermissions All = new GuildPermissions(0b11111111_11111_1111111_1111111111111_11111);
public static readonly GuildPermissions All = new GuildPermissions(0b1111111111_11111_1111111_1111111111111_11111);

/// <summary> Gets a packed value representing all the permissions in this <see cref="GuildPermissions"/>. </summary>
public ulong RawValue { get; }
@@ -90,11 +90,15 @@ namespace Discord
/// <summary> If <c>true</c>, a user may manage threads in this guild. </summary>
public bool ManageThreads => Permissions.GetValue(RawValue, GuildPermission.ManageThreads);
/// <summary> If <c>true</c>, a user may create public threads in this guild. </summary>
public bool UsePublicThreads => Permissions.GetValue(RawValue, GuildPermission.UsePublicThreads);
public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads);
/// <summary> If <c>true</c>, a user may create private threads in this guild. </summary>
public bool UsePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.UsePrivateThreads);
public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads);
/// <summary> If <c>true</c>, a user may use external stickers in this guild. </summary>
public bool UseExternalStickers => Permissions.GetValue(RawValue, GuildPermission.UseExternalStickers);
/// <summary> If <c>true</c>, a user may send messages in threads in this guild. </summary>
public bool SendMessagesInThreads => Permissions.GetValue(RawValue, GuildPermission.SendMessagesInThreads);
/// <summary> If <c>true</c>, a user launch application activites in voice channels in this guild. </summary>
public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, GuildPermission.StartEmbeddedActivities);

/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary>
public GuildPermissions(ulong rawValue) { RawValue = rawValue; }
@@ -137,9 +141,11 @@ namespace Discord
bool? useSlashCommands = null,
bool? requestToSpeak = null,
bool? manageThreads = null,
bool? usePublicThreads = null,
bool? usePrivateThreads = null,
bool? useExternalStickers = null)
bool? createPublicThreads = null,
bool? createPrivateThreads = null,
bool? useExternalStickers = null,
bool? sendMessagesInThreads = null,
bool? startEmbeddedActivities = null)
{
ulong value = initialValue;

@@ -177,9 +183,11 @@ namespace Discord
Permissions.SetValue(ref value, useSlashCommands, GuildPermission.UseSlashCommands);
Permissions.SetValue(ref value, requestToSpeak, GuildPermission.RequestToSpeak);
Permissions.SetValue(ref value, manageThreads, GuildPermission.ManageThreads);
Permissions.SetValue(ref value, usePublicThreads, GuildPermission.UsePublicThreads);
Permissions.SetValue(ref value, usePrivateThreads, GuildPermission.UseExternalStickers);
Permissions.SetValue(ref value, createPublicThreads, GuildPermission.CreatePublicThreads);
Permissions.SetValue(ref value, createPrivateThreads, GuildPermission.CreatePrivateThreads);
Permissions.SetValue(ref value, useExternalStickers, GuildPermission.UseExternalStickers);
Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads);
Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities);

RawValue = value;
}
@@ -220,9 +228,11 @@ namespace Discord
bool useSlashCommands = false,
bool requestToSpeak = false,
bool manageThreads = false,
bool usePublicThreads = false,
bool usePrivateThreads = false,
bool useExternalStickers = false)
bool createPublicThreads = false,
bool createPrivateThreads = false,
bool useExternalStickers = false,
bool sendMessagesInThreads = false,
bool startEmbeddedActivities = false)
: this(0,
createInstantInvite: createInstantInvite,
manageRoles: manageRoles,
@@ -258,9 +268,11 @@ namespace Discord
useSlashCommands: useSlashCommands,
requestToSpeak: requestToSpeak,
manageThreads: manageThreads,
usePublicThreads: usePublicThreads,
usePrivateThreads: usePrivateThreads,
useExternalStickers: useExternalStickers)
createPublicThreads: createPublicThreads,
createPrivateThreads: createPrivateThreads,
useExternalStickers: useExternalStickers,
sendMessagesInThreads: sendMessagesInThreads,
startEmbeddedActivities: startEmbeddedActivities)
{ }

/// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary>
@@ -299,14 +311,17 @@ namespace Discord
bool? useSlashCommands = null,
bool? requestToSpeak = null,
bool? manageThreads = null,
bool? usePublicThreads = null,
bool? usePrivateThreads = null,
bool? useExternalStickers = null)
bool? createPublicThreads = null,
bool? createPrivateThreads = null,
bool? useExternalStickers = null,
bool? sendMessagesInThreads = null,
bool? startEmbeddedActivities = null)
=> new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions,
viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers,
useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers,
useSlashCommands, requestToSpeak, manageThreads, usePublicThreads, usePrivateThreads, useExternalStickers);
useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads,
startEmbeddedActivities);

/// <summary>
/// Returns a value that indicates if a specific <see cref="GuildPermission"/> is enabled


Loading…
Cancel
Save