Add missing permissions (#3006)

* yes

* no way tests actually save the day
This commit is contained in:
Mihail Gribkov
2024-09-14 19:48:42 +03:00
committed by GitHub
parent 682d87e62b
commit 6b92cc2b08
6 changed files with 54 additions and 13 deletions

View File

@@ -178,6 +178,11 @@ namespace Discord
/// </summary> /// </summary>
CreateEvents = 1L << 44, CreateEvents = 1L << 44,
/// <summary>
/// Allows the usage of custom soundboard sounds from other servers.
/// </summary>
UseExternalSounds = 1L << 45,
/// <summary> /// <summary>
/// Allows sending voice messages. /// Allows sending voice messages.
/// </summary> /// </summary>

View File

@@ -23,12 +23,12 @@ namespace Discord
/// <summary> /// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for voice channels. /// Gets a <see cref="ChannelPermissions"/> that grants all permissions for voice channels.
/// </summary> /// </summary>
public static readonly ChannelPermissions Voice = new(0b111_110001_001010_001010_110011_111101_111111_111101_010001); public static readonly ChannelPermissions Voice = new(0b111_110101_001010_001010_110011_111101_111111_111101_010001);
/// <summary> /// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for stage channels. /// Gets a <see cref="ChannelPermissions"/> that grants all permissions for stage channels.
/// </summary> /// </summary>
public static readonly ChannelPermissions Stage = new(0b110_110000_000010_001110_010001_010101_111111_111001_010001); public static readonly ChannelPermissions Stage = new(0b110_110100_000010_001110_010001_010101_111111_111001_010001);
/// <summary> /// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels. /// Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels.
@@ -156,6 +156,8 @@ namespace Discord
public bool SendPolls => Permissions.GetValue(RawValue, ChannelPermission.SendPolls); public bool SendPolls => Permissions.GetValue(RawValue, ChannelPermission.SendPolls);
/// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary> /// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary>
public bool UserExternalApps => Permissions.GetValue(RawValue, ChannelPermission.UseExternalApps); public bool UserExternalApps => Permissions.GetValue(RawValue, ChannelPermission.UseExternalApps);
/// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary>
public bool UseExternalSounds => Permissions.GetValue(RawValue, ChannelPermission.UseExternalSounds);
/// <summary> Creates a new <see cref="ChannelPermissions"/> with the provided packed value.</summary> /// <summary> Creates a new <see cref="ChannelPermissions"/> with the provided packed value.</summary>
public ChannelPermissions(ulong rawValue) { RawValue = rawValue; } public ChannelPermissions(ulong rawValue) { RawValue = rawValue; }
@@ -197,7 +199,8 @@ namespace Discord
bool? useClydeAI = null, bool? useClydeAI = null,
bool? setVoiceChannelStatus = null, bool? setVoiceChannelStatus = null,
bool? sendPolls = null, bool? sendPolls = null,
bool? useExternalApps = null) bool? useExternalApps = null,
bool? useExternalSounds = null)
{ {
ulong value = initialValue; ulong value = initialValue;
@@ -238,6 +241,7 @@ namespace Discord
Permissions.SetValue(ref value, setVoiceChannelStatus, ChannelPermission.SetVoiceChannelStatus); Permissions.SetValue(ref value, setVoiceChannelStatus, ChannelPermission.SetVoiceChannelStatus);
Permissions.SetValue(ref value, sendPolls, ChannelPermission.SendPolls); Permissions.SetValue(ref value, sendPolls, ChannelPermission.SendPolls);
Permissions.SetValue(ref value, useExternalApps, ChannelPermission.UseExternalApps); Permissions.SetValue(ref value, useExternalApps, ChannelPermission.UseExternalApps);
Permissions.SetValue(ref value, useExternalSounds, ChannelPermission.UseExternalSounds);
RawValue = value; RawValue = value;
} }
@@ -280,12 +284,13 @@ namespace Discord
bool useClydeAI = false, bool useClydeAI = false,
bool setVoiceChannelStatus = false, bool setVoiceChannelStatus = false,
bool sendPolls = false, bool sendPolls = false,
bool useExternalApps = false) bool useExternalApps = false,
bool useExternalSounds = false)
: this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, : this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages,
embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect,
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks,
useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads,
startEmbeddedActivities, useSoundboard, createEvents, sendVoiceMessages, useClydeAI, setVoiceChannelStatus, sendPolls, useExternalApps) startEmbeddedActivities, useSoundboard, createEvents, sendVoiceMessages, useClydeAI, setVoiceChannelStatus, sendPolls, useExternalApps, useExternalSounds)
{ } { }
/// <summary> Creates a new <see cref="ChannelPermissions"/> from this one, changing the provided non-null permissions.</summary> /// <summary> Creates a new <see cref="ChannelPermissions"/> from this one, changing the provided non-null permissions.</summary>
@@ -326,7 +331,8 @@ namespace Discord
bool? useClydeAI = null, bool? useClydeAI = null,
bool? setVoiceChannelStatus = null, bool? setVoiceChannelStatus = null,
bool? sendPolls = null, bool? sendPolls = null,
bool? useExternalApps = null) bool? useExternalApps = null,
bool? useExternalSounds = null)
=> new ChannelPermissions(RawValue, => new ChannelPermissions(RawValue,
createInstantInvite, createInstantInvite,
manageChannel, manageChannel,
@@ -364,7 +370,8 @@ namespace Discord
useClydeAI, useClydeAI,
setVoiceChannelStatus, setVoiceChannelStatus,
sendPolls, sendPolls,
useExternalApps); useExternalApps,
useExternalSounds);
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission); public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);

View File

@@ -268,6 +268,16 @@ namespace Discord
/// </summary> /// </summary>
CreateGuildExpressions = 1L << 43, CreateGuildExpressions = 1L << 43,
/// <summary>
/// Allows members to edit and cancel events in this channel.
/// </summary>
CreateEvents = 1L << 44,
/// <summary>
/// Allows the usage of custom soundboard sounds from other servers.
/// </summary>
UseExternalSounds = 1L << 45,
/// <summary> /// <summary>
/// Allows sending voice messages. /// Allows sending voice messages.
/// </summary> /// </summary>

View File

@@ -120,7 +120,10 @@ namespace Discord
public bool SendPolls => Permissions.GetValue(RawValue, GuildPermission.SendPolls); public bool SendPolls => Permissions.GetValue(RawValue, GuildPermission.SendPolls);
/// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary> /// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary>
public bool UserExternalApps => Permissions.GetValue(RawValue, GuildPermission.UseExternalApps); public bool UserExternalApps => Permissions.GetValue(RawValue, GuildPermission.UseExternalApps);
/// <summary> If <see langword="true"/>, a user can send soundboard sounds from other servers.</summary>
public bool UserExternalSounds => Permissions.GetValue(RawValue, GuildPermission.UseExternalSounds);
/// <summary> If <see langword="true"/>, a user can create events.</summary>
public bool CreateEvents => Permissions.GetValue(RawValue, GuildPermission.CreateEvents);
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary> /// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary>
public GuildPermissions(ulong rawValue) { RawValue = rawValue; } public GuildPermissions(ulong rawValue) { RawValue = rawValue; }
@@ -177,7 +180,9 @@ namespace Discord
bool? createGuildExpressions = null, bool? createGuildExpressions = null,
bool? setVoiceChannelStatus = null, bool? setVoiceChannelStatus = null,
bool? sendPolls = null, bool? sendPolls = null,
bool? useExternalApps = null) bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? createEvents = null)
{ {
ulong value = initialValue; ulong value = initialValue;
@@ -230,6 +235,8 @@ namespace Discord
Permissions.SetValue(ref value, setVoiceChannelStatus, GuildPermission.SetVoiceChannelStatus); Permissions.SetValue(ref value, setVoiceChannelStatus, GuildPermission.SetVoiceChannelStatus);
Permissions.SetValue(ref value, sendPolls, GuildPermission.SendPolls); Permissions.SetValue(ref value, sendPolls, GuildPermission.SendPolls);
Permissions.SetValue(ref value, useExternalApps, GuildPermission.UseExternalApps); Permissions.SetValue(ref value, useExternalApps, GuildPermission.UseExternalApps);
Permissions.SetValue(ref value, useExternalSounds, GuildPermission.UseExternalSounds);
Permissions.SetValue(ref value, createEvents, GuildPermission.CreateEvents);
RawValue = value; RawValue = value;
} }
@@ -284,7 +291,9 @@ namespace Discord
bool createGuildExpressions = false, bool createGuildExpressions = false,
bool setVoiceChannelStatus = false, bool setVoiceChannelStatus = false,
bool sendPolls = false, bool sendPolls = false,
bool useExternalApps = false) bool useExternalApps = false,
bool useExternalSounds = false,
bool createEvents = false)
: this(0, : this(0,
createInstantInvite: createInstantInvite, createInstantInvite: createInstantInvite,
manageRoles: manageRoles, manageRoles: manageRoles,
@@ -334,7 +343,9 @@ namespace Discord
createGuildExpressions: createGuildExpressions, createGuildExpressions: createGuildExpressions,
setVoiceChannelStatus: setVoiceChannelStatus, setVoiceChannelStatus: setVoiceChannelStatus,
sendPolls: sendPolls, sendPolls: sendPolls,
useExternalApps: useExternalApps) useExternalApps: useExternalApps,
useExternalSounds: useExternalSounds,
createEvents: createEvents)
{ } { }
/// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary> /// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary>
@@ -387,14 +398,16 @@ namespace Discord
bool? createGuildExpressions = null, bool? createGuildExpressions = null,
bool? setVoiceChannelStatus = null, bool? setVoiceChannelStatus = null,
bool? sendPolls = null, bool? sendPolls = null,
bool? useExternalApps = null) bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? createEvents = null)
=> new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions,
viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers,
useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers,
useApplicationCommands, requestToSpeak, manageEvents, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, useApplicationCommands, requestToSpeak, manageEvents, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads,
startEmbeddedActivities, moderateMembers, useSoundboard, viewMonetizationAnalytics, sendVoiceMessages, useClydeAI, createGuildExpressions, setVoiceChannelStatus, startEmbeddedActivities, moderateMembers, useSoundboard, viewMonetizationAnalytics, sendVoiceMessages, useClydeAI, createGuildExpressions, setVoiceChannelStatus,
sendPolls, useExternalApps); sendPolls, useExternalApps, useExternalSounds, createEvents);
/// <summary> /// <summary>
/// Returns a value that indicates if a specific <see cref="GuildPermission"/> is enabled /// Returns a value that indicates if a specific <see cref="GuildPermission"/> is enabled

View File

@@ -97,6 +97,7 @@ namespace Discord
AssertFlag(() => new ChannelPermissions(setVoiceChannelStatus: true), ChannelPermission.SetVoiceChannelStatus); AssertFlag(() => new ChannelPermissions(setVoiceChannelStatus: true), ChannelPermission.SetVoiceChannelStatus);
AssertFlag(() => new ChannelPermissions(sendPolls: true), ChannelPermission.SendPolls); AssertFlag(() => new ChannelPermissions(sendPolls: true), ChannelPermission.SendPolls);
AssertFlag(() => new ChannelPermissions(useExternalApps: true), ChannelPermission.UseExternalApps); AssertFlag(() => new ChannelPermissions(useExternalApps: true), ChannelPermission.UseExternalApps);
AssertFlag(() => new ChannelPermissions(useExternalSounds: true), ChannelPermission.UseExternalSounds);
} }
/// <summary> /// <summary>
@@ -166,6 +167,7 @@ namespace Discord
AssertUtil(ChannelPermission.SetVoiceChannelStatus, x => x.SetVoiceChannelStatus, (p, enable) => p.Modify(setVoiceChannelStatus: enable)); AssertUtil(ChannelPermission.SetVoiceChannelStatus, x => x.SetVoiceChannelStatus, (p, enable) => p.Modify(setVoiceChannelStatus: enable));
AssertUtil(ChannelPermission.SendPolls, x => x.SendPolls, (p, enable) => p.Modify(sendPolls: enable)); AssertUtil(ChannelPermission.SendPolls, x => x.SendPolls, (p, enable) => p.Modify(sendPolls: enable));
AssertUtil(ChannelPermission.UseExternalApps, x => x.UserExternalApps, (p, enable) => p.Modify(useExternalApps: enable)); AssertUtil(ChannelPermission.UseExternalApps, x => x.UserExternalApps, (p, enable) => p.Modify(useExternalApps: enable));
AssertUtil(ChannelPermission.UseExternalSounds, x => x.UseExternalSounds, (p, enable) => p.Modify(useExternalSounds: enable));
} }
/// <summary> /// <summary>

View File

@@ -108,6 +108,8 @@ namespace Discord
AssertFlag(() => new GuildPermissions(setVoiceChannelStatus: true), GuildPermission.SetVoiceChannelStatus); AssertFlag(() => new GuildPermissions(setVoiceChannelStatus: true), GuildPermission.SetVoiceChannelStatus);
AssertFlag(() => new GuildPermissions(sendPolls: true), GuildPermission.SendPolls); AssertFlag(() => new GuildPermissions(sendPolls: true), GuildPermission.SendPolls);
AssertFlag(() => new GuildPermissions(useExternalApps: true), GuildPermission.UseExternalApps); AssertFlag(() => new GuildPermissions(useExternalApps: true), GuildPermission.UseExternalApps);
AssertFlag(() => new GuildPermissions(useExternalSounds: true), GuildPermission.UseExternalSounds);
AssertFlag(() => new GuildPermissions(createEvents: true), GuildPermission.CreateEvents);
} }
/// <summary> /// <summary>
@@ -194,6 +196,8 @@ namespace Discord
AssertUtil(GuildPermission.SetVoiceChannelStatus, x => x.SetVoiceChannelStatus, (p, enable) => p.Modify(setVoiceChannelStatus: enable)); AssertUtil(GuildPermission.SetVoiceChannelStatus, x => x.SetVoiceChannelStatus, (p, enable) => p.Modify(setVoiceChannelStatus: enable));
AssertUtil(GuildPermission.SendPolls, x => x.SendPolls, (p, enable) => p.Modify(sendPolls: enable)); AssertUtil(GuildPermission.SendPolls, x => x.SendPolls, (p, enable) => p.Modify(sendPolls: enable));
AssertUtil(GuildPermission.UseExternalApps, x => x.UserExternalApps, (p, enable) => p.Modify(useExternalApps: enable)); AssertUtil(GuildPermission.UseExternalApps, x => x.UserExternalApps, (p, enable) => p.Modify(useExternalApps: enable));
AssertUtil(GuildPermission.UseExternalSounds, x => x.UserExternalSounds, (p, enable) => p.Modify(useExternalSounds: enable));
AssertUtil(GuildPermission.CreateEvents, x => x.CreateEvents, (p, enable) => p.Modify(createEvents: enable));
} }
} }
} }