[Feature] Add PinMessages permission (#3178)
This commit is contained in:
@@ -207,5 +207,10 @@ namespace Discord
|
|||||||
/// Allows user-installed apps to send public responses.
|
/// Allows user-installed apps to send public responses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UseExternalApps = 1L << 50,
|
UseExternalApps = 1L << 50,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows pinning and unpinning messages.
|
||||||
|
/// </summary>
|
||||||
|
PinMessages = 1L << 51,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(0b110_110001_001111_110010_110011_111101_111111_111101_010001);
|
public static readonly ChannelPermissions Text = new(0b1110_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(0b111_110101_001010_001010_110011_111101_111111_111101_010001);
|
public static readonly ChannelPermissions Voice = new(0b0111_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_110100_000010_001110_010001_010101_111111_111001_010001);
|
public static readonly ChannelPermissions Stage = new(0b0110_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.
|
||||||
@@ -48,7 +48,7 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for forum channels.
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for forum channels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ChannelPermissions Forum = new(0b000001_001110_010010_110011_111101_111111_111101_010001);
|
public static readonly ChannelPermissions Forum = new(0b1000_000001_001110_010010_110011_111101_111111_111101_010001);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for media channels.
|
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for media channels.
|
||||||
@@ -158,6 +158,8 @@ namespace Discord
|
|||||||
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>
|
/// <summary> If <see langword="true"/>, a user-installed application can send public responses.</summary>
|
||||||
public bool UseExternalSounds => Permissions.GetValue(RawValue, ChannelPermission.UseExternalSounds);
|
public bool UseExternalSounds => Permissions.GetValue(RawValue, ChannelPermission.UseExternalSounds);
|
||||||
|
/// <summary> If <see langword="true"/>, a user can ping and unpin messages.</summary>
|
||||||
|
public bool PinMessages => Permissions.GetValue(RawValue, ChannelPermission.PinMessages);
|
||||||
|
|
||||||
/// <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; }
|
||||||
@@ -200,7 +202,8 @@ namespace Discord
|
|||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null,
|
bool? sendPolls = null,
|
||||||
bool? useExternalApps = null,
|
bool? useExternalApps = null,
|
||||||
bool? useExternalSounds = null)
|
bool? useExternalSounds = null,
|
||||||
|
bool? pinMessages = null)
|
||||||
{
|
{
|
||||||
ulong value = initialValue;
|
ulong value = initialValue;
|
||||||
|
|
||||||
@@ -242,6 +245,7 @@ namespace Discord
|
|||||||
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);
|
Permissions.SetValue(ref value, useExternalSounds, ChannelPermission.UseExternalSounds);
|
||||||
|
Permissions.SetValue(ref value, pinMessages, ChannelPermission.PinMessages);
|
||||||
|
|
||||||
RawValue = value;
|
RawValue = value;
|
||||||
}
|
}
|
||||||
@@ -285,12 +289,14 @@ namespace Discord
|
|||||||
bool setVoiceChannelStatus = false,
|
bool setVoiceChannelStatus = false,
|
||||||
bool sendPolls = false,
|
bool sendPolls = false,
|
||||||
bool useExternalApps = false,
|
bool useExternalApps = false,
|
||||||
bool useExternalSounds = false)
|
bool useExternalSounds = false,
|
||||||
|
bool pinMessages = 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, useExternalSounds)
|
startEmbeddedActivities, useSoundboard, createEvents, sendVoiceMessages, useClydeAI, setVoiceChannelStatus, sendPolls, useExternalApps,
|
||||||
|
useExternalSounds, pinMessages)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -332,7 +338,8 @@ namespace Discord
|
|||||||
bool? setVoiceChannelStatus = null,
|
bool? setVoiceChannelStatus = null,
|
||||||
bool? sendPolls = null,
|
bool? sendPolls = null,
|
||||||
bool? useExternalApps = null,
|
bool? useExternalApps = null,
|
||||||
bool? useExternalSounds = null)
|
bool? useExternalSounds = null,
|
||||||
|
bool? pinMessages = null)
|
||||||
=> new ChannelPermissions(RawValue,
|
=> new ChannelPermissions(RawValue,
|
||||||
createInstantInvite,
|
createInstantInvite,
|
||||||
manageChannel,
|
manageChannel,
|
||||||
@@ -371,7 +378,8 @@ namespace Discord
|
|||||||
setVoiceChannelStatus,
|
setVoiceChannelStatus,
|
||||||
sendPolls,
|
sendPolls,
|
||||||
useExternalApps,
|
useExternalApps,
|
||||||
useExternalSounds);
|
useExternalSounds,
|
||||||
|
pinMessages);
|
||||||
|
|
||||||
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);
|
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);
|
||||||
|
|
||||||
|
|||||||
@@ -302,5 +302,10 @@ namespace Discord
|
|||||||
/// Allows user-installed apps to send public responses.
|
/// Allows user-installed apps to send public responses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UseExternalApps = 1L << 50,
|
UseExternalApps = 1L << 50,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows pinning and unpinning messages.
|
||||||
|
/// </summary>
|
||||||
|
PinMessages = 1L << 51,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ namespace Discord
|
|||||||
public bool UserExternalSounds => Permissions.GetValue(RawValue, GuildPermission.UseExternalSounds);
|
public bool UserExternalSounds => Permissions.GetValue(RawValue, GuildPermission.UseExternalSounds);
|
||||||
/// <summary> If <see langword="true"/>, a user can create events.</summary>
|
/// <summary> If <see langword="true"/>, a user can create events.</summary>
|
||||||
public bool CreateEvents => Permissions.GetValue(RawValue, GuildPermission.CreateEvents);
|
public bool CreateEvents => Permissions.GetValue(RawValue, GuildPermission.CreateEvents);
|
||||||
|
/// <summary> If <see langword="true"/>, a user can ping and unpin messages.</summary>
|
||||||
|
public bool PinMessages => Permissions.GetValue(RawValue, GuildPermission.PinMessages);
|
||||||
|
|
||||||
/// <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; }
|
||||||
@@ -182,7 +184,8 @@ namespace Discord
|
|||||||
bool? sendPolls = null,
|
bool? sendPolls = null,
|
||||||
bool? useExternalApps = null,
|
bool? useExternalApps = null,
|
||||||
bool? useExternalSounds = null,
|
bool? useExternalSounds = null,
|
||||||
bool? createEvents = null)
|
bool? createEvents = null,
|
||||||
|
bool? pinMessages = null)
|
||||||
{
|
{
|
||||||
ulong value = initialValue;
|
ulong value = initialValue;
|
||||||
|
|
||||||
@@ -237,6 +240,7 @@ namespace Discord
|
|||||||
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, useExternalSounds, GuildPermission.UseExternalSounds);
|
||||||
Permissions.SetValue(ref value, createEvents, GuildPermission.CreateEvents);
|
Permissions.SetValue(ref value, createEvents, GuildPermission.CreateEvents);
|
||||||
|
Permissions.SetValue(ref value, pinMessages, GuildPermission.PinMessages);
|
||||||
|
|
||||||
RawValue = value;
|
RawValue = value;
|
||||||
}
|
}
|
||||||
@@ -293,7 +297,8 @@ namespace Discord
|
|||||||
bool sendPolls = false,
|
bool sendPolls = false,
|
||||||
bool useExternalApps = false,
|
bool useExternalApps = false,
|
||||||
bool useExternalSounds = false,
|
bool useExternalSounds = false,
|
||||||
bool createEvents = false)
|
bool createEvents = false,
|
||||||
|
bool pinMessages = false)
|
||||||
: this(0,
|
: this(0,
|
||||||
createInstantInvite: createInstantInvite,
|
createInstantInvite: createInstantInvite,
|
||||||
manageRoles: manageRoles,
|
manageRoles: manageRoles,
|
||||||
@@ -345,7 +350,8 @@ namespace Discord
|
|||||||
sendPolls: sendPolls,
|
sendPolls: sendPolls,
|
||||||
useExternalApps: useExternalApps,
|
useExternalApps: useExternalApps,
|
||||||
useExternalSounds: useExternalSounds,
|
useExternalSounds: useExternalSounds,
|
||||||
createEvents: createEvents)
|
createEvents: createEvents,
|
||||||
|
pinMessages: pinMessages)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -400,14 +406,15 @@ namespace Discord
|
|||||||
bool? sendPolls = null,
|
bool? sendPolls = null,
|
||||||
bool? useExternalApps = null,
|
bool? useExternalApps = null,
|
||||||
bool? useExternalSounds = null,
|
bool? useExternalSounds = null,
|
||||||
bool? createEvents = null)
|
bool? createEvents = null,
|
||||||
|
bool? pinMessages = 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, useExternalSounds, createEvents);
|
sendPolls, useExternalApps, useExternalSounds, createEvents, pinMessages);
|
||||||
|
|
||||||
/// <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
|
||||||
|
|||||||
@@ -97,7 +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);
|
AssertFlag(() => new ChannelPermissions(pinMessages: true), ChannelPermission.PinMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -168,6 +168,7 @@ namespace Discord
|
|||||||
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));
|
AssertUtil(ChannelPermission.UseExternalSounds, x => x.UseExternalSounds, (p, enable) => p.Modify(useExternalSounds: enable));
|
||||||
|
AssertUtil(ChannelPermission.PinMessages, x => x.PinMessages, (p, enable) => p.Modify(pinMessages: enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ namespace Discord
|
|||||||
AssertFlag(() => new GuildPermissions(useExternalApps: true), GuildPermission.UseExternalApps);
|
AssertFlag(() => new GuildPermissions(useExternalApps: true), GuildPermission.UseExternalApps);
|
||||||
AssertFlag(() => new GuildPermissions(useExternalSounds: true), GuildPermission.UseExternalSounds);
|
AssertFlag(() => new GuildPermissions(useExternalSounds: true), GuildPermission.UseExternalSounds);
|
||||||
AssertFlag(() => new GuildPermissions(createEvents: true), GuildPermission.CreateEvents);
|
AssertFlag(() => new GuildPermissions(createEvents: true), GuildPermission.CreateEvents);
|
||||||
|
AssertFlag(() => new GuildPermissions(pinMessages: true), GuildPermission.PinMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -197,6 +198,7 @@ namespace Discord
|
|||||||
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.UseExternalSounds, x => x.UserExternalSounds, (p, enable) => p.Modify(useExternalSounds: enable));
|
||||||
AssertUtil(GuildPermission.CreateEvents, x => x.CreateEvents, (p, enable) => p.Modify(createEvents: enable));
|
AssertUtil(GuildPermission.CreateEvents, x => x.CreateEvents, (p, enable) => p.Modify(createEvents: enable));
|
||||||
|
AssertUtil(GuildPermission.PinMessages, x => x.PinMessages, (p, enable) => p.Modify(pinMessages: enable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user