MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / removeTimeoutUser

Method removeTimeoutUser

src/services/moderationService.js:331–393  ·  view source on GitHub ↗
({
    guild,
    member,
    moderator,
    reason = 'Timeout removed by moderator'
  })

Source from the content-addressed store, hash-verified

329 }
330
331 static async removeTimeoutUser({
332 guild,
333 member,
334 moderator,
335 reason = 'Timeout removed by moderator'
336 }) {
337 try {
338 if (!guild || !member || !moderator) {
339 throw new TitanBotError(
340 'Missing required parameters',
341 ErrorTypes.VALIDATION,
342 'Guild, member, and moderator are required'
343 );
344 }
345
346 this.assertModerationHierarchy(moderator, member, 'remove the timeout from');
347
348 if (!member.moderatable) {
349 const targetLabel = getTargetLabel(member);
350 throw new TitanBotError(
351 'Cannot modify member',
352 ErrorTypes.PERMISSION,
353 `I cannot modify **${targetLabel}**. They may have **Administrator** permission or a managed/integration role. ` +
354 'Ensure my bot role is above theirs in **Server Settings → Roles**.'
355 );
356 }
357
358 if (!member.isCommunicationDisabled()) {
359 throw new TitanBotError(
360 'User not timed out',
361 ErrorTypes.VALIDATION,
362 `${member.user.tag} is not currently timed out`
363 );
364 }
365
366 await member.timeout(null, reason);
367
368 await logModerationAction({
369 client: guild.client,
370 guild,
371 event: {
372 action: 'Member Untimeouted',
373 target: `${member.user.tag} (${member.id})`,
374 executor: `${moderator.user.tag} (${moderator.id})`,
375 reason,
376 metadata: {
377 userId: member.id,
378 moderatorId: moderator.id
379 }
380 }
381 });
382
383 logger.info(`Timeout removed: ${member.user.tag} by ${moderator.user.tag} in ${guild.name}`);
384
385 return {
386 success: true,
387 user: member.user.tag
388 };

Callers 1

executeFunction · 0.80

Calls 3

logModerationActionFunction · 0.90
getTargetLabelFunction · 0.85

Tested by

no test coverage detected