// Parses simple duration strings ("30s", "10m", "2h", "1d") to milliseconds. // Returns null for anything unparseable. Discord's own timeout API caps at 28 // days — callers should clamp to MAX_TIMEOUT_MS rather than trust user input. const UNIT_MS = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 } const MAX_TIMEOUT_MS = 28 * 86_400_000 function parseDuration(input) { if (!input) return null const match = /^(\d+)\s*([smhd])$/i.exec(input.trim()) if (!match) return null const [, amount, unit] = match return Number(amount) * UNIT_MS[unit.toLowerCase()] } module.exports = { parseDuration, MAX_TIMEOUT_MS }