Add BypassSlowmode permission (#3228)

This commit is contained in:
Mihail Gribkov
2026-01-23 22:28:58 +03:00
committed by GitHub
parent 9c1db3f0f0
commit 0dea5bb4fd
6 changed files with 41 additions and 13 deletions

View File

@@ -212,5 +212,10 @@ namespace Discord
/// Allows pinning and unpinning messages.
/// </summary>
PinMessages = 1L << 51,
/// <summary>
/// Allows bypassing slowmode restrictions.
/// </summary>
BypassSlowmode = 1L << 52,
}
}

View File

@@ -18,17 +18,17 @@ namespace Discord
/// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for text channels.
/// </summary>
public static readonly ChannelPermissions Text = new(0b1110_110001_001111_110010_110011_111101_111111_111101_010001);
public static readonly ChannelPermissions Text = new(0b11110_110001_001111_110010_110011_111101_111111_111101_010001);
/// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for voice channels.
/// </summary>
public static readonly ChannelPermissions Voice = new(0b0111_110101_001010_001010_110011_111101_111111_111101_010001);
public static readonly ChannelPermissions Voice = new(0b10111_110101_001010_001010_110011_111101_111111_111101_010001);
/// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for stage channels.
/// </summary>
public static readonly ChannelPermissions Stage = new(0b0110_110100_000010_001110_010001_010101_111111_111001_010001);
public static readonly ChannelPermissions Stage = new(0b10110_110100_000010_001110_010001_010101_111111_111001_010001);
/// <summary>
/// Gets a <see cref="ChannelPermissions"/> that grants all permissions for category channels.
@@ -160,6 +160,8 @@ namespace Discord
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> If <see langword="true"/>, a user may bypass slowmode restrictions.</summary>
public bool BypassSlowmode => Permissions.GetValue(RawValue, ChannelPermission.BypassSlowmode);
/// <summary> Creates a new <see cref="ChannelPermissions"/> with the provided packed value.</summary>
public ChannelPermissions(ulong rawValue) { RawValue = rawValue; }
@@ -203,7 +205,8 @@ namespace Discord
bool? sendPolls = null,
bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? pinMessages = null)
bool? pinMessages = null,
bool? bypassSlowmode = null)
{
ulong value = initialValue;
@@ -246,6 +249,7 @@ namespace Discord
Permissions.SetValue(ref value, useExternalApps, ChannelPermission.UseExternalApps);
Permissions.SetValue(ref value, useExternalSounds, ChannelPermission.UseExternalSounds);
Permissions.SetValue(ref value, pinMessages, ChannelPermission.PinMessages);
Permissions.SetValue(ref value, bypassSlowmode, ChannelPermission.BypassSlowmode);
RawValue = value;
}
@@ -290,13 +294,14 @@ namespace Discord
bool sendPolls = false,
bool useExternalApps = false,
bool useExternalSounds = false,
bool pinMessages = false)
bool pinMessages = false,
bool bypassSlowmode = false)
: this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages,
embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect,
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks,
useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads,
startEmbeddedActivities, useSoundboard, createEvents, sendVoiceMessages, useClydeAI, setVoiceChannelStatus, sendPolls, useExternalApps,
useExternalSounds, pinMessages)
useExternalSounds, pinMessages, bypassSlowmode)
{ }
/// <summary> Creates a new <see cref="ChannelPermissions"/> from this one, changing the provided non-null permissions.</summary>
@@ -339,7 +344,8 @@ namespace Discord
bool? sendPolls = null,
bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? pinMessages = null)
bool? pinMessages = null,
bool? bypassSlowmode = null)
=> new ChannelPermissions(RawValue,
createInstantInvite,
manageChannel,
@@ -379,7 +385,8 @@ namespace Discord
sendPolls,
useExternalApps,
useExternalSounds,
pinMessages);
pinMessages,
bypassSlowmode);
public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);

View File

@@ -307,5 +307,10 @@ namespace Discord
/// Allows pinning and unpinning messages.
/// </summary>
PinMessages = 1L << 51,
/// <summary>
/// Allows bypassing slowmode restrictions.
/// </summary>
BypassSlowmode = 1L << 52,
}
}

View File

@@ -126,6 +126,8 @@ namespace Discord
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> If <see langword="true"/>, a user may bypass slowmode restrictions. </summary>
public bool BypassSlowmode => Permissions.GetValue(RawValue, GuildPermission.BypassSlowmode);
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary>
public GuildPermissions(ulong rawValue) { RawValue = rawValue; }
@@ -185,7 +187,8 @@ namespace Discord
bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? createEvents = null,
bool? pinMessages = null)
bool? pinMessages = null,
bool? bypassSlowmode = null)
{
ulong value = initialValue;
@@ -241,6 +244,7 @@ namespace Discord
Permissions.SetValue(ref value, useExternalSounds, GuildPermission.UseExternalSounds);
Permissions.SetValue(ref value, createEvents, GuildPermission.CreateEvents);
Permissions.SetValue(ref value, pinMessages, GuildPermission.PinMessages);
Permissions.SetValue(ref value, bypassSlowmode, GuildPermission.BypassSlowmode);
RawValue = value;
}
@@ -298,7 +302,8 @@ namespace Discord
bool useExternalApps = false,
bool useExternalSounds = false,
bool createEvents = false,
bool pinMessages = false)
bool pinMessages = false,
bool bypassSlowmode = false)
: this(0,
createInstantInvite: createInstantInvite,
manageRoles: manageRoles,
@@ -351,7 +356,8 @@ namespace Discord
useExternalApps: useExternalApps,
useExternalSounds: useExternalSounds,
createEvents: createEvents,
pinMessages: pinMessages)
pinMessages: pinMessages,
bypassSlowmode: bypassSlowmode)
{ }
/// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary>
@@ -407,14 +413,15 @@ namespace Discord
bool? useExternalApps = null,
bool? useExternalSounds = null,
bool? createEvents = null,
bool? pinMessages = null)
bool? pinMessages = null,
bool? bypassSlowmode = 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,
useApplicationCommands, requestToSpeak, manageEvents, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads,
startEmbeddedActivities, moderateMembers, useSoundboard, viewMonetizationAnalytics, sendVoiceMessages, useClydeAI, createGuildExpressions, setVoiceChannelStatus,
sendPolls, useExternalApps, useExternalSounds, createEvents, pinMessages);
sendPolls, useExternalApps, useExternalSounds, createEvents, pinMessages, bypassSlowmode);
/// <summary>
/// Returns a value that indicates if a specific <see cref="GuildPermission"/> is enabled

View File

@@ -98,6 +98,7 @@ namespace Discord
AssertFlag(() => new ChannelPermissions(sendPolls: true), ChannelPermission.SendPolls);
AssertFlag(() => new ChannelPermissions(useExternalApps: true), ChannelPermission.UseExternalApps);
AssertFlag(() => new ChannelPermissions(pinMessages: true), ChannelPermission.PinMessages);
AssertFlag(() => new ChannelPermissions(bypassSlowmode: true), ChannelPermission.BypassSlowmode);
}
/// <summary>
@@ -169,6 +170,7 @@ namespace Discord
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.PinMessages, x => x.PinMessages, (p, enable) => p.Modify(pinMessages: enable));
AssertUtil(ChannelPermission.BypassSlowmode, x => x.BypassSlowmode, (p, enable) => p.Modify(bypassSlowmode: enable));
}
/// <summary>

View File

@@ -110,6 +110,7 @@ namespace Discord
AssertFlag(() => new GuildPermissions(useExternalSounds: true), GuildPermission.UseExternalSounds);
AssertFlag(() => new GuildPermissions(createEvents: true), GuildPermission.CreateEvents);
AssertFlag(() => new GuildPermissions(pinMessages: true), GuildPermission.PinMessages);
AssertFlag(() => new GuildPermissions(bypassSlowmode: true), GuildPermission.BypassSlowmode);
}
/// <summary>
@@ -199,6 +200,7 @@ namespace Discord
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.PinMessages, x => x.PinMessages, (p, enable) => p.Modify(pinMessages: enable));
AssertUtil(GuildPermission.BypassSlowmode, x => x.BypassSlowmode, (p, enable) => p.Modify(bypassSlowmode: enable));
}
}
}