[Feature] Add UseExternalApps permission (#2941)
This commit is contained in:
@@ -197,5 +197,10 @@ namespace Discord
|
|||||||
/// Allows sending polls.
|
/// Allows sending polls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SendPolls = 1L << 49,
|
SendPolls = 1L << 49,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows user-installed apps to send public responses.
|
||||||
|
/// </summary>
|
||||||
|
UseExternalApps = 1L << 50,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for text channels.
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for text channels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ChannelPermissions Text = new(0b10_110001_001111_110010_110011_111101_111111_111101_010001);
|
public static readonly ChannelPermissions Text = new(0b110_110001_001111_110010_110011_111101_111111_111101_010001);
|
||||||
|
|
||||||
/// <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(0b11_110001_001010_001010_110011_111101_111111_111101_010001);
|
public static readonly ChannelPermissions Voice = new(0b111_110001_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(0b10_110000_000010_001110_010001_010101_111111_111001_010001);
|
public static readonly ChannelPermissions Stage = new(0b110_110000_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.
|
||||||
@@ -154,6 +154,8 @@ namespace Discord
|
|||||||
public bool SetVoiceChannelStatus => Permissions.GetValue(RawValue, ChannelPermission.SetVoiceChannelStatus);
|
public bool SetVoiceChannelStatus => Permissions.GetValue(RawValue, ChannelPermission.SetVoiceChannelStatus);
|
||||||
/// <summary> If <see langword="true"/>, a user can send polls.</summary>
|
/// <summary> If <see langword="true"/>, a user can send polls.</summary>
|
||||||
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>
|
||||||
|
public bool UserExternalApps => Permissions.GetValue(RawValue, ChannelPermission.UseExternalApps);
|
||||||
|
|
||||||
/// <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; }
|
||||||
@@ -194,7 +196,8 @@ namespace Discord
|
|||||||
bool? sendVoiceMessages = null,
|
bool? sendVoiceMessages = null,
|
||||||
bool? useClydeAI = null,
|
bool? useClydeAI = null,
|
||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null)
|
bool? sendPolls = null,
|
||||||
|
bool? useExternalApps = null)
|
||||||
{
|
{
|
||||||
ulong value = initialValue;
|
ulong value = initialValue;
|
||||||
|
|
||||||
@@ -234,6 +237,7 @@ namespace Discord
|
|||||||
Permissions.SetValue(ref value, useClydeAI, ChannelPermission.UseClydeAI);
|
Permissions.SetValue(ref value, useClydeAI, ChannelPermission.UseClydeAI);
|
||||||
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);
|
||||||
|
|
||||||
RawValue = value;
|
RawValue = value;
|
||||||
}
|
}
|
||||||
@@ -275,12 +279,13 @@ namespace Discord
|
|||||||
bool sendVoiceMessages = false,
|
bool sendVoiceMessages = false,
|
||||||
bool useClydeAI = false,
|
bool useClydeAI = false,
|
||||||
bool setVoiceChannelStatus = false,
|
bool setVoiceChannelStatus = false,
|
||||||
bool sendPolls = false)
|
bool sendPolls = false,
|
||||||
|
bool useExternalApps = 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)
|
startEmbeddedActivities, useSoundboard, createEvents, sendVoiceMessages, useClydeAI, setVoiceChannelStatus, sendPolls, useExternalApps)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -320,7 +325,8 @@ namespace Discord
|
|||||||
bool? sendVoiceMessages = null,
|
bool? sendVoiceMessages = null,
|
||||||
bool? useClydeAI = null,
|
bool? useClydeAI = null,
|
||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null)
|
bool? sendPolls = null,
|
||||||
|
bool? useExternalApps = null)
|
||||||
=> new ChannelPermissions(RawValue,
|
=> new ChannelPermissions(RawValue,
|
||||||
createInstantInvite,
|
createInstantInvite,
|
||||||
manageChannel,
|
manageChannel,
|
||||||
@@ -357,7 +363,8 @@ namespace Discord
|
|||||||
sendVoiceMessages,
|
sendVoiceMessages,
|
||||||
useClydeAI,
|
useClydeAI,
|
||||||
setVoiceChannelStatus,
|
setVoiceChannelStatus,
|
||||||
sendPolls);
|
sendPolls,
|
||||||
|
useExternalApps);
|
||||||
|
|
||||||
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);
|
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);
|
||||||
|
|
||||||
|
|||||||
@@ -287,5 +287,10 @@ namespace Discord
|
|||||||
/// Allows sending polls.
|
/// Allows sending polls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SendPolls = 1L << 49,
|
SendPolls = 1L << 49,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows user-installed apps to send public responses.
|
||||||
|
/// </summary>
|
||||||
|
UseExternalApps = 1L << 50,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ namespace Discord
|
|||||||
public bool SetVoiceChannelStatus => Permissions.GetValue(RawValue, GuildPermission.SetVoiceChannelStatus);
|
public bool SetVoiceChannelStatus => Permissions.GetValue(RawValue, GuildPermission.SetVoiceChannelStatus);
|
||||||
/// <summary> If <see langword="true"/>, a user can send polls.</summary>
|
/// <summary> If <see langword="true"/>, a user can send polls.</summary>
|
||||||
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>
|
||||||
|
public bool UserExternalApps => Permissions.GetValue(RawValue, GuildPermission.UseExternalApps);
|
||||||
|
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -174,7 +176,8 @@ namespace Discord
|
|||||||
bool? useClydeAI = null,
|
bool? useClydeAI = null,
|
||||||
bool? createGuildExpressions = null,
|
bool? createGuildExpressions = null,
|
||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null)
|
bool? sendPolls = null,
|
||||||
|
bool? useExternalApps = null)
|
||||||
{
|
{
|
||||||
ulong value = initialValue;
|
ulong value = initialValue;
|
||||||
|
|
||||||
@@ -226,6 +229,7 @@ namespace Discord
|
|||||||
Permissions.SetValue(ref value, createGuildExpressions, GuildPermission.CreateGuildExpressions);
|
Permissions.SetValue(ref value, createGuildExpressions, GuildPermission.CreateGuildExpressions);
|
||||||
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);
|
||||||
|
|
||||||
RawValue = value;
|
RawValue = value;
|
||||||
}
|
}
|
||||||
@@ -279,7 +283,8 @@ namespace Discord
|
|||||||
bool useClydeAI = false,
|
bool useClydeAI = false,
|
||||||
bool createGuildExpressions = false,
|
bool createGuildExpressions = false,
|
||||||
bool setVoiceChannelStatus = false,
|
bool setVoiceChannelStatus = false,
|
||||||
bool sendPolls = false)
|
bool sendPolls = false,
|
||||||
|
bool useExternalApps = false)
|
||||||
: this(0,
|
: this(0,
|
||||||
createInstantInvite: createInstantInvite,
|
createInstantInvite: createInstantInvite,
|
||||||
manageRoles: manageRoles,
|
manageRoles: manageRoles,
|
||||||
@@ -328,7 +333,8 @@ namespace Discord
|
|||||||
useClydeAI: useClydeAI,
|
useClydeAI: useClydeAI,
|
||||||
createGuildExpressions: createGuildExpressions,
|
createGuildExpressions: createGuildExpressions,
|
||||||
setVoiceChannelStatus: setVoiceChannelStatus,
|
setVoiceChannelStatus: setVoiceChannelStatus,
|
||||||
sendPolls: sendPolls)
|
sendPolls: sendPolls,
|
||||||
|
useExternalApps: useExternalApps)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -380,14 +386,15 @@ namespace Discord
|
|||||||
bool? useClydeAI = null,
|
bool? useClydeAI = null,
|
||||||
bool? createGuildExpressions = null,
|
bool? createGuildExpressions = null,
|
||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null)
|
bool? sendPolls = null,
|
||||||
|
bool? useExternalApps = 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);
|
sendPolls, useExternalApps);
|
||||||
|
|
||||||
/// <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
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the behavior of the <see cref="Discord.ChannelPermissions"/> constructor for each
|
/// Tests the behavior of the <see cref="ChannelPermissions"/> constructor for each
|
||||||
/// of it's flags.
|
/// of it's flags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -96,10 +96,11 @@ namespace Discord
|
|||||||
AssertFlag(() => new ChannelPermissions(useClydeAI: true), ChannelPermission.UseClydeAI);
|
AssertFlag(() => new ChannelPermissions(useClydeAI: true), ChannelPermission.UseClydeAI);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the behavior of <see cref="Discord.ChannelPermissions.Modify"/>
|
/// Tests the behavior of <see cref="ChannelPermissions.Modify"/>
|
||||||
/// with each of the parameters.
|
/// with each of the parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -164,6 +165,7 @@ namespace Discord
|
|||||||
AssertUtil(ChannelPermission.UseClydeAI, x => x.UseClydeAI, (p, enable) => p.Modify(useClydeAI: enable));
|
AssertUtil(ChannelPermission.UseClydeAI, x => x.UseClydeAI, (p, enable) => p.Modify(useClydeAI: enable));
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -107,10 +107,11 @@ namespace Discord
|
|||||||
AssertFlag(() => new GuildPermissions(createGuildExpressions: true), GuildPermission.CreateGuildExpressions);
|
AssertFlag(() => new GuildPermissions(createGuildExpressions: true), GuildPermission.CreateGuildExpressions);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the behavior of <see cref="Discord.GuildPermissions.Modify(bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?, bool?)"/>
|
/// Tests the behavior of <see cref="GuildPermissions.Modify"/>
|
||||||
/// with each of the parameters.
|
/// with each of the parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -192,6 +193,7 @@ namespace Discord
|
|||||||
AssertUtil(GuildPermission.CreateGuildExpressions, x => x.CreateGuildExpressions, (p, enable) => p.Modify(createGuildExpressions: enable));
|
AssertUtil(GuildPermission.CreateGuildExpressions, x => x.CreateGuildExpressions, (p, enable) => p.Modify(createGuildExpressions: enable));
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user