({
guild,
member,
moderator,
durationMs,
reason = 'No reason provided'
})
| 266 | } |
| 267 | |
| 268 | static async timeoutUser({ |
| 269 | guild, |
| 270 | member, |
| 271 | moderator, |
| 272 | durationMs, |
| 273 | reason = 'No reason provided' |
| 274 | }) { |
| 275 | try { |
| 276 | if (!guild || !member || !moderator || !durationMs) { |
| 277 | throw new TitanBotError( |
| 278 | 'Missing required parameters', |
| 279 | ErrorTypes.VALIDATION, |
| 280 | 'Guild, member, moderator, and duration are required' |
| 281 | ); |
| 282 | } |
| 283 | |
| 284 | this.assertModerationHierarchy(moderator, member, 'timeout'); |
| 285 | |
| 286 | if (!member.moderatable) { |
| 287 | const targetLabel = getTargetLabel(member); |
| 288 | throw new TitanBotError( |
| 289 | 'Cannot timeout member', |
| 290 | ErrorTypes.PERMISSION, |
| 291 | `I cannot timeout **${targetLabel}**. They may have **Administrator** permission or a managed/integration role. ` + |
| 292 | 'Ensure my bot role is above theirs in **Server Settings → Roles** and that they do not have Admin.' |
| 293 | ); |
| 294 | } |
| 295 | |
| 296 | await member.timeout(durationMs, reason); |
| 297 | |
| 298 | const durationMinutes = Math.floor(durationMs / 60000); |
| 299 | const caseId = await logModerationAction({ |
| 300 | client: guild.client, |
| 301 | guild, |
| 302 | event: { |
| 303 | action: 'Member Timed Out', |
| 304 | target: `${member.user.tag} (${member.id})`, |
| 305 | executor: `${moderator.user.tag} (${moderator.id})`, |
| 306 | reason, |
| 307 | duration: `${durationMinutes} minutes`, |
| 308 | metadata: { |
| 309 | userId: member.id, |
| 310 | moderatorId: moderator.id, |
| 311 | durationMs |
| 312 | } |
| 313 | } |
| 314 | }); |
| 315 | |
| 316 | logger.info(`User timed out: ${member.user.tag} by ${moderator.user.tag} in ${guild.name}`); |
| 317 | |
| 318 | return { |
| 319 | success: true, |
| 320 | caseId, |
| 321 | user: member.user.tag, |
| 322 | duration: durationMinutes, |
| 323 | reason |
| 324 | }; |
| 325 | } catch (error) { |
no test coverage detected