feat(voice): add temporary voice channel manager

Joining the trigger channel must feel instant and never leave orphan channels behind, so the ownership is stored in SQLite, empty channels are deleted after a short grace period and a startup sweep cleans up whatever a restart left behind.
This commit is contained in:
BlackAngelTV committed 2026-09-15 14:51:17 +02:00
1 parent ef1bedbc65
commit 5191942d5a
12 files changed
+1277 -1

No files matched your search

+715
View File
@@ -0,0 +1,715 @@
import {
ActionRowBuilder,
ChannelType,
MessageFlags,
ModalBuilder,
PermissionFlagsBits,
TextInputBuilder,
TextInputStyle,
} from 'discord.js';
import { ACCESS_LEVELS, COLORS } from '../../config/constants.js';
import { env } from '../../config/env.js';
import { PermissionDeniedError, UserFacingError } from '../../core/errors.js';
import { createLogger } from '../../core/logger.js';
import { getAccessLevel } from '../../core/permissions.js';
import { logEvent } from '../../database/repositories/event-log-repository.js';
import { resolveSetting, setSetting } from '../../database/repositories/settings-repository.js';
import {
addVoiceChannel,
countVoiceChannels,
getVoiceChannel,
listOwnedVoiceChannels,
listVoiceChannels,
removeVoiceChannel,
setVoiceLimit,
setVoiceLocked,
setVoiceName,
setVoiceOwner,
} from '../../database/repositories/voice-repository.js';
import { voicePanelComponents } from '../../ui/buttons.js';
import { baseEmbed, successEmbed } from '../../ui/embeds.js';
const log = createLogger('voice');
export const DEFAULT_TEMPLATE = '🔊 Salon de {user}';
/** Discord caps the user limit of a voice channel at 99 (0 means unlimited). */
export const LIMIT_MAX = 99;
export const NAME_MAX = 100;
/** Delay before an empty temporary channel is deleted, so a quick move does not destroy it. */
const EMPTY_GRACE_MS = 5_000;
/** Creation in flight per member, to never create two channels for the same person (M14-T02). */
const pendingCreations = new Set();
/** Channel id -> panel message id, so buttons can be refreshed after a change (M14-T05). */
const panelMessages = new Map();
const VIEW = PermissionFlagsBits.ViewChannel;
const CONNECT = PermissionFlagsBits.Connect;
const SPEAK = PermissionFlagsBits.Speak;
const MEMBER_ALLOW = [VIEW, CONNECT, SPEAK];
const OWNER_ALLOW = [...MEMBER_ALLOW, PermissionFlagsBits.ManageChannels, PermissionFlagsBits.MoveMembers];
/** Named form required by `permissionOverwrites.edit()` (permission bits are not keys). */
const OWNER_OVERWRITE = Object.freeze({
ViewChannel: true,
Connect: true,
Speak: true,
ManageChannels: true,
MoveMembers: true,
});
/** Strips control characters without a control-character regex, then collapses spaces. */
const clean = (value) =>
[...String(value ?? '')]
.map((char) => {
const code = char.codePointAt(0);
return code <= 31 || code === 127 ? ' ' : char;
})
.join('')
.replace(/\s+/g, ' ')
.trim();
/** Channel names are normalised and truncated before they reach Discord (M14-T08). */
export function sanitizeChannelName(value) {
const name = clean(value);
if (!name) throw new UserFacingError('Le nom du salon ne peut pas être vide.');
return name.slice(0, NAME_MAX);
}
/** `🔊 Salon de {user}` -> the name of the channel created for a member. */
export function buildChannelName(template, member) {
const replaced = String(template || DEFAULT_TEMPLATE).replaceAll(
'{user}',
member.displayName ?? member.user?.username ?? '',
);
return clean(replaced).slice(0, NAME_MAX) || '🔊 Salon vocal';
}
/** `0` means unlimited; anything outside 0..99 is rejected or ignored (M14-T06). */
export function clampLimit(value, { strict = false } = {}) {
const limit = Number(value);
if (!Number.isInteger(limit) || limit < 0 || limit > LIMIT_MAX) {
if (strict) {
throw new UserFacingError(`La limite doit être un entier entre 0 (illimité) et ${LIMIT_MAX}.`);
}
return 0;
}
return limit;
}
/** Per-guild voice configuration, falling back to the environment (M14-T01). */
export function getVoiceSettings(guildId) {
return {
triggerId: resolveSetting(guildId, 'voice.trigger', env.channels.voiceTrigger),
categoryId: resolveSetting(guildId, 'voice.category', env.channels.voiceCategory),
template: resolveSetting(guildId, 'voice.template', DEFAULT_TEMPLATE) || DEFAULT_TEMPLATE,
defaultLimit: clampLimit(resolveSetting(guildId, 'voice.limit', 0)),
};
}
export function saveVoiceSettings(guildId, patch, updatedBy = null) {
const keys = {
trigger: 'voice.trigger',
category: 'voice.category',
template: 'voice.template',
limit: 'voice.limit',
};
for (const [name, key] of Object.entries(keys)) {
if (patch[name] !== undefined) setSetting(guildId, key, patch[name], updatedBy);
}
}
export function isStaff(member, roles = env.roles) {
return getAccessLevel(member, roles) >= ACCESS_LEVELS.STAFF;
}
export function isManagedChannel(channelId) {
return Boolean(getVoiceChannel(channelId));
}
/** Embed shown in the panel and by `/voice info` (M14-T05). */
export function voicePanelEmbed(channel, row) {
const ownerId = row?.owner_id ?? null;
return baseEmbed(COLORS.primary)
.setTitle(`Gestion de ${channel.name}`)
.setDescription(
'Les boutons ci-dessous agissent sur ce salon uniquement. Les commandes `/voice` offrent les mêmes options.',
)
.addFields(
{ name: 'Propriétaire', value: ownerId ? `<@${ownerId}>` : 'Personne', inline: true },
{ name: 'Statut', value: row?.locked ? '🔒 Verrouillé' : '🔓 Ouvert', inline: true },
{ name: 'Limite', value: row?.user_limit ? `${row.user_limit} places` : 'Illimitée', inline: true },
{
name: 'Membres',
value: row?.user_limit ? `${channel.members.size} / ${row.user_limit}` : String(channel.members.size),
inline: true,
},
);
}
export function voiceInfoEmbed(channel, row) {
const embed = baseEmbed(COLORS.primary)
.setTitle(channel.name)
.addFields(
{ name: 'Propriétaire', value: row?.owner_id ? `<@${row.owner_id}>` : 'Personne', inline: true },
{ name: 'Statut', value: row?.locked ? '🔒 Verrouillé' : '🔓 Ouvert', inline: true },
{ name: 'Limite', value: row?.user_limit ? `${row.user_limit} places` : 'Illimitée', inline: true },
{
name: 'Membres',
value:
channel.members.size === 0
? 'Aucun'
: channel.members
.first(10)
.map((member) => `<@${member.id}>`)
.join(', '),
},
)
.addFields({ name: 'Créé', value: `<t:${Math.floor(channel.createdTimestamp / 1000)}:R>`, inline: true });
if (row?.trigger_id) embed.setFooter({ text: `Salon temporaire · déclencheur ${row.trigger_id}` });
return embed;
}
/** Posts the control panel in the text chat of the voice channel (M14-T05). */
async function postPanel(channel, row) {
if (!channel.isSendable?.()) return;
const message = await channel
.send({
embeds: [voicePanelEmbed(channel, row)],
components: voicePanelComponents({ locked: Boolean(row.locked) }),
})
.catch((error) => {
log.warn('Could not post the voice panel', error);
return null;
});
if (message) panelMessages.set(channel.id, message.id);
}
/** Refreshes the panel buttons after a change, best effort (M14-T05). */
export async function refreshPanel(channel) {
const messageId = panelMessages.get(channel.id);
const row = getVoiceChannel(channel.id);
if (!messageId || !row || !channel.isSendable?.()) return;
const message = await channel.messages.fetch(messageId).catch(() => null);
await message
?.edit({
embeds: [voicePanelEmbed(channel, row)],
components: voicePanelComponents({ locked: Boolean(row.locked) }),
})
.catch(() => {});
}
async function findReusableChannel(guild, ownerId) {
for (const row of listOwnedVoiceChannels(guild.id, ownerId)) {
const channel = guild.channels.cache.get(row.channel_id);
if (!channel) {
removeVoiceChannel(row.channel_id);
panelMessages.delete(row.channel_id);
continue;
}
const full = channel.userLimit > 0 && channel.members.size >= channel.userLimit;
if (!full) return { channel, row };
}
return null;
}
function buildOverwrites(guild, client, ownerId) {
return [
{ id: guild.roles.everyone.id, allow: MEMBER_ALLOW },
{ id: ownerId, allow: OWNER_ALLOW },
{ id: client.user.id, allow: OWNER_ALLOW },
];
}
/**
* Called when a member joins the trigger channel: creates their channel (or moves them
* back into the one they already own) and hands it over (M14-T02 / M14-T03).
*/
export async function createFromTrigger(member) {
const settings = getVoiceSettings(member.guild.id);
if (!settings.triggerId || pendingCreations.has(member.id)) return null;
const reusable = await findReusableChannel(member.guild, member.id);
if (reusable) {
await member.voice
.setChannel(reusable.channel, 'Retour dans son salon vocal temporaire')
.catch((error) => log.warn('Could not move the member back into their channel', error));
return reusable.channel;
}
pendingCreations.add(member.id);
try {
const parent = settings.categoryId
? await member.guild.channels.fetch(settings.categoryId).catch(() => null)
: null;
const channel = await member.guild.channels.create({
name: buildChannelName(settings.template, member),
type: ChannelType.GuildVoice,
userLimit: settings.defaultLimit,
...(parent?.type === ChannelType.GuildCategory && { parent: parent.id }),
reason: `Salon vocal temporaire de ${member.user.tag}`,
permissionOverwrites: buildOverwrites(member.guild, member.client, member.id),
});
addVoiceChannel({
channelId: channel.id,
guildId: member.guild.id,
ownerId: member.id,
triggerId: settings.triggerId,
name: channel.name,
userLimit: settings.defaultLimit,
});
await member.voice
.setChannel(channel, 'Salon vocal temporaire créé')
.catch((error) => log.warn('Could not move the member into their new channel', error));
await postPanel(channel, getVoiceChannel(channel.id));
logEvent({
guildId: member.guild.id,
type: 'voice.created',
actorId: member.id,
payload: { channelId: channel.id, ownerId: member.id },
});
return channel;
} finally {
pendingCreations.delete(member.id);
}
}
/** Deletes a temporary channel and forgets it. */
export async function deleteVoiceChannel(channel, reason = 'Salon vocal temporaire supprimé') {
removeVoiceChannel(channel.id);
panelMessages.delete(channel.id);
return channel.delete(reason).catch((error) => log.warn('Could not delete the voice channel', error));
}
/**
* Deletes an empty temporary channel after a short grace period, so that a member
* moving between channels does not lose their channel (M14-T04).
*/
export async function cleanupVoiceChannel(guild, channelId) {
const row = getVoiceChannel(channelId);
if (!row) return;
const channel =
guild.channels.cache.get(channelId) ?? (await guild.channels.fetch(channelId).catch(() => null));
if (!channel) {
removeVoiceChannel(channelId);
return;
}
if (channel.members.size > 0) return;
setTimeout(async () => {
try {
const fresh =
guild.channels.cache.get(channelId) ?? (await guild.channels.fetch(channelId).catch(() => null));
if (!fresh || fresh.members.size > 0) return;
await deleteVoiceChannel(fresh, 'Salon vocal temporaire vide').catch(() => {});
logEvent({ guildId: guild.id, type: 'voice.deleted', payload: { channelId } });
} catch (error) {
log.warn('Could not clean up an empty voice channel', error);
}
}, EMPTY_GRACE_MS).unref();
}
/** Startup sweep: forget deleted channels, remove the ones left empty by a restart (M14-T07). */
export async function sweepVoiceChannels(client) {
for (const guild of client.guilds.cache.values()) {
let rows = [];
try {
rows = listVoiceChannels(guild.id);
} catch (error) {
log.warn('Could not read the stored voice channels', error);
continue;
}
for (const row of rows) {
const channel =
guild.channels.cache.get(row.channel_id) ??
(await guild.channels.fetch(row.channel_id).catch(() => null));
if (!channel) {
removeVoiceChannel(row.channel_id);
panelMessages.delete(row.channel_id);
continue;
}
if (channel.members.size === 0) {
await deleteVoiceChannel(channel, 'Salon vocal temporaire vide après redémarrage');
}
}
}
}
export function activeChannelCount(guildId) {
return countVoiceChannels(guildId);
}
/** Channel of the interaction itself, when it is a temporary voice channel (panel buttons and modals). */
function managedChannelOf(interaction) {
return interaction.channelId && isManagedChannel(interaction.channelId) ? interaction.channelId : null;
}
/**
* Resolves the temporary channel an action applies to: the explicit option first, then the
* channel the interaction happened in (panel, modal), then the voice channel of the caller (M14-T05).
*/
export async function resolveManagedChannel(interaction, { channelId = null } = {}) {
const id = channelId ?? managedChannelOf(interaction) ?? interaction.member?.voice?.channelId ?? null;
const row = id ? getVoiceChannel(id) : null;
if (!row) {
throw new UserFacingError(
'Rejoins ton salon vocal temporaire pour le gérer, ou précise l’option `channel`.',
);
}
if (channelId && channelId !== interaction.member?.voice?.channelId && !isStaff(interaction.member)) {
// An explicit channel is a staff convenience only: a member manages their own channel.
throw new PermissionDeniedError('Seul le staff peut cibler le salon d’un autre membre.');
}
const channel = await interaction.guild.channels.fetch(row.channel_id).catch(() => null);
if (!channel) {
removeVoiceChannel(row.channel_id);
throw new UserFacingError('Ce salon vocal n’existe plus.');
}
return { channel, row };
}
/** Only the owner may manage a channel; staff can always step in (M14-T06). */
export function assertVoiceOwner(interaction, row, action = 'gérer ce salon') {
if (row.owner_id === interaction.user.id || isStaff(interaction.member)) return;
throw new PermissionDeniedError(`Seul le propriétaire du salon (ou le staff) peut ${action}.`);
}
const ephemeral = (payload) => ({ ...payload, flags: MessageFlags.Ephemeral });
export async function renameChannel(interaction, name) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'renommer le salon');
const sanitized = sanitizeChannelName(name);
await channel.setName(sanitized, `Renommé par ${interaction.user.tag}`);
setVoiceName(channel.id, sanitized);
await refreshPanel(channel);
await interaction.reply(ephemeral({ embeds: [successEmbed(`Salon renommé en **${sanitized}**.`)] }));
}
export async function setChannelLimit(interaction, limit) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'changer la limite');
const value = clampLimit(limit, { strict: true });
await channel.setUserLimit(value, `Limite modifiée par ${interaction.user.tag}`);
setVoiceLimit(channel.id, value);
await refreshPanel(channel);
await interaction.reply(
ephemeral({
embeds: [
successEmbed(
value === 0 ? 'Le salon redevient **sans limite** de places.' : `Limite : **${value} places**.`,
),
],
}),
);
}
export async function toggleLock(interaction, { locked = null } = {}) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'verrouiller le salon');
const next = locked === null ? !row.locked : Boolean(locked);
if (next === Boolean(row.locked)) {
throw new UserFacingError(next ? 'Le salon est déjà verrouillé.' : 'Le salon est déjà déverrouillé.');
}
await channel.permissionOverwrites.edit(
interaction.guild.roles.everyone.id,
{ Connect: next ? false : null },
{ reason: `${next ? 'Verrouillé' : 'Déverrouillé'} par ${interaction.user.tag}` },
);
setVoiceLocked(channel.id, next);
await refreshPanel(channel);
await interaction.reply(
ephemeral({
embeds: [
successEmbed(
next
? '🔒 Salon verrouillé : seuls les membres autorisés peuvent le rejoindre.'
: '🔓 Salon déverrouillé : tout le monde peut rejoindre.',
),
],
}),
);
}
export async function permitUser(interaction, userId) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'autoriser un membre');
await channel.permissionOverwrites.edit(
userId,
{ ViewChannel: true, Connect: true },
{
reason: `Autorisé par ${interaction.user.tag}`,
},
);
await interaction.reply(ephemeral({ embeds: [successEmbed(`<@${userId}> peut rejoindre le salon.`)] }));
}
export async function rejectUser(interaction, userId) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'refuser un membre');
await channel.permissionOverwrites.edit(
userId,
{ ViewChannel: false, Connect: false },
{
reason: `Refusé par ${interaction.user.tag}`,
},
);
const member = channel.members.get(userId);
await member?.voice.disconnect(`Refusé par ${interaction.user.tag}`).catch(() => {});
await interaction.reply(
ephemeral({ embeds: [successEmbed(`<@${userId}> ne peut plus rejoindre le salon.`)] }),
);
}
export async function kickUser(interaction, userId) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'exclure un membre');
const member = channel.members.get(userId);
if (!member) throw new UserFacingError('Ce membre n’est pas dans le salon.');
if (member.id === row.owner_id) throw new UserFacingError('Le propriétaire ne peut pas être exclu.');
await member.voice.disconnect(`Exclu par ${interaction.user.tag}`);
await interaction.reply(ephemeral({ embeds: [successEmbed(`<@${userId}> a été exclu du salon.`)] }));
}
export async function transferOwnership(interaction, userId) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'transférer le salon');
const member = channel.members.get(userId);
if (!member) throw new UserFacingError('Le nouveau propriétaire doit déjà être dans le salon.');
if (member.id === row.owner_id) throw new UserFacingError('Ce membre est déjà propriétaire du salon.');
await channel.permissionOverwrites
.edit(row.owner_id, { ManageChannels: null, MoveMembers: null }, { reason: 'Nouveau propriétaire' })
.catch(() => {});
await channel.permissionOverwrites.edit(member.id, OWNER_OVERWRITE, {
reason: `Salon transféré par ${interaction.user.tag}`,
});
setVoiceOwner(channel.id, member.id);
await refreshPanel(channel);
logEvent({
guildId: interaction.guildId,
type: 'voice.transferred',
actorId: interaction.user.id,
payload: { channelId: channel.id, ownerId: member.id },
});
await interaction.reply(
ephemeral({
embeds: [successEmbed(`<@${member.id}> est désormais propriétaire de **${channel.name}**.`)],
}),
);
}
/** A member may take over a channel whose owner is gone (M14-T03). */
export async function claimOwnership(interaction) {
const { channel, row } = await resolveManagedChannel(interaction);
if (row.owner_id === interaction.user.id) {
throw new UserFacingError('Tu es déjà propriétaire de ce salon.');
}
if (channel.members.has(row.owner_id)) {
throw new UserFacingError('Le propriétaire est toujours dans le salon.');
}
if (!channel.members.has(interaction.user.id)) {
throw new UserFacingError('Rejoins d’abord le salon pour en réclamer la propriété.');
}
await channel.permissionOverwrites.edit(interaction.user.id, OWNER_OVERWRITE, {
reason: `Salon réclamé par ${interaction.user.tag}`,
});
setVoiceOwner(channel.id, interaction.user.id);
await refreshPanel(channel);
logEvent({
guildId: interaction.guildId,
type: 'voice.claimed',
actorId: interaction.user.id,
payload: { channelId: channel.id },
});
await interaction.reply(ephemeral({ embeds: [successEmbed('Tu es désormais propriétaire de ce salon.')] }));
}
export async function removeChannel(interaction, { channelId = null } = {}) {
const { channel, row } = await resolveManagedChannel(interaction, { channelId });
assertVoiceOwner(interaction, row, 'supprimer le salon');
await interaction.reply(
ephemeral({ embeds: [successEmbed(`Le salon **${channel.name}** va être supprimé.`)] }),
);
logEvent({
guildId: interaction.guildId,
type: 'voice.deleted',
actorId: interaction.user.id,
payload: { channelId: channel.id },
});
setTimeout(
() => deleteVoiceChannel(channel, `Supprimé par ${interaction.user.tag}`).catch(() => {}),
3_000,
).unref();
}
export async function showInfo(interaction, { channelId = null } = {}) {
const { channel, row } = await resolveManagedChannel(interaction, { channelId });
await interaction.reply(ephemeral({ embeds: [voiceInfoEmbed(channel, row)] }));
}
/** Posts the "join to create" panel in the trigger channel (M14-T01). */
export async function postSetupPanel(interaction) {
const settings = getVoiceSettings(interaction.guildId);
if (!settings.triggerId) {
throw new UserFacingError('Aucun salon vocal déclencheur n’est configuré : lance `/voice setup`.');
}
const trigger = await interaction.guild.channels.fetch(settings.triggerId).catch(() => null);
if (!trigger?.isVoiceBased?.()) {
throw new UserFacingError('Le salon déclencheur configuré n’est pas un salon vocal.');
}
const embed = baseEmbed(COLORS.primary)
.setTitle('🎧 Salons vocaux temporaires')
.setDescription(
`Rejoins ${trigger} pour obtenir ton propre salon vocal.\n\n` +
'Tu en deviens le propriétaire : renomme-le, limite le nombre de places, verrouille-le, ' +
'autorise ou exclus des membres, ou transfère-le — depuis les boutons du salon ou les commandes `/voice`.',
)
.addFields({ name: 'Limite par défaut', value: settings.defaultLimit || 'Illimitée', inline: true });
if (!trigger.isSendable()) {
throw new UserFacingError('Je n’ai pas la permission d’écrire dans le salon déclencheur.');
}
await trigger.send({ embeds: [embed] });
await interaction.reply(ephemeral({ embeds: [successEmbed('Panneau publié dans le salon déclencheur.')] }));
}
/** Button and select menu routing (M14-T05). */
export async function handleVoiceComponent(interaction) {
const action = interaction.customId.split(':')[1];
if (interaction.isUserSelectMenu()) {
const userId = interaction.values[0];
switch (action) {
case 'permit':
await permitUser(interaction, userId);
return;
case 'kick':
await kickUser(interaction, userId);
return;
case 'transfer':
await transferOwnership(interaction, userId);
return;
default:
log.debug(`Ignored voice select ${interaction.customId}`);
return;
}
}
switch (action) {
case 'rename':
await openRenameModal(interaction);
return;
case 'limit':
await openLimitModal(interaction);
return;
case 'lock':
await toggleLock(interaction);
return;
case 'claim':
await claimOwnership(interaction);
return;
case 'info':
await showInfo(interaction);
return;
case 'delete':
await removeChannel(interaction);
return;
default:
log.debug(`Ignored voice component ${interaction.customId}`);
}
}
async function openRenameModal(interaction) {
const { channel, row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'renommer le salon');
await interaction.showModal(
new ModalBuilder()
.setCustomId('voice:rename:modal')
.setTitle('Renommer le salon')
.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('name')
.setLabel('Nouveau nom')
.setStyle(TextInputStyle.Short)
.setMaxLength(NAME_MAX)
.setValue(channel.name.slice(0, NAME_MAX))
.setRequired(true),
),
),
);
}
async function openLimitModal(interaction) {
const { row } = await resolveManagedChannel(interaction);
assertVoiceOwner(interaction, row, 'changer la limite');
await interaction.showModal(
new ModalBuilder()
.setCustomId('voice:limit:modal')
.setTitle('Limite de places')
.addComponents(
new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('limit')
.setLabel(`Entre 0 (illimité) et ${LIMIT_MAX}`)
.setStyle(TextInputStyle.Short)
.setMaxLength(2)
.setValue(String(row.user_limit ?? 0))
.setRequired(true),
),
),
);
}
/** Modal submissions opened from the panel (M14-T05). */
export async function handleVoiceModal(interaction) {
if (interaction.customId === 'voice:rename:modal') {
await renameChannel(interaction, interaction.fields.getTextInputValue('name'));
return;
}
if (interaction.customId === 'voice:limit:modal') {
const raw = interaction.fields.getTextInputValue('limit').trim();
const limit = Number.parseInt(raw, 10);
if (!/^\d{1,2}$/.test(raw)) {
throw new UserFacingError(`Indique un nombre entier entre 0 (illimité) et ${LIMIT_MAX}.`);
}
await setChannelLimit(interaction, limit);
return;
}
log.debug(`Ignored voice modal ${interaction.customId}`);
}