fix: allow rate_limit_per_user on channel creation (#1401)

This commit is contained in:
Jiralite authored and GitHub committed 2026-07-13 21:57:07 +00:00
1 parent 04da3e6a6c
commit 6ebb43d10d
4 files changed
+58 -24

No files matched your search

@@ -155,7 +155,7 @@ export class ChannelOperationsService {
nsfw: requestedNsfwOverride,
content_warning_level: requestedContentWarningLevel,
content_warning_text: requestedContentWarningText,
rate_limit_per_user: 0,
rate_limit_per_user: params.data.rate_limit_per_user ?? 0,
bitrate: params.data.type === ChannelTypes.GUILD_VOICE ? (params.data.bitrate ?? 64000) : null,
user_limit: params.data.type === ChannelTypes.GUILD_VOICE ? (params.data.user_limit ?? 0) : null,
voice_connection_limit:
@@ -98,6 +98,24 @@ describe('Guild Channel Management', () => {
});
});
describe('Channel Slowmode (rate_limit_per_user)', () => {
test('should set slowmode when creating a channel', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'We go slow');
const channel = await createBuilder<ChannelResponse>(harness, account.token)
.post(`/guilds/${guild.id}/channels`)
.body({name: 'slooooow', type: ChannelTypes.GUILD_TEXT, rate_limit_per_user: 60})
.execute();
expect(channel.rate_limit_per_user).toBe(60);
});
test('should reject invalid slowmode when creating a channel', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Test Guild');
await createBuilder(harness, account.token)
.post(`/guilds/${guild.id}/channels`)
.body({name: 'too-fast-omg', type: ChannelTypes.GUILD_TEXT, rate_limit_per_user: Number.MAX_SAFE_INTEGER})
.expect(HTTP_STATUS.BAD_REQUEST)
.execute();
});
test('should set slowmode on text channel', async () => {
const account = await createTestAccount(harness);
const guild = await createGuild(harness, account.token, 'Test Guild');