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

Method unbanUser

src/services/moderationService.js:395–450  ·  view source on GitHub ↗
({
    guild,
    user,
    moderator,
    reason = 'No reason provided'
  })

Source from the content-addressed store, hash-verified

393 }
394
395 static async unbanUser({
396 guild,
397 user,
398 moderator,
399 reason = 'No reason provided'
400 }) {
401 try {
402 if (!guild || !user || !moderator) {
403 throw new TitanBotError(
404 'Missing required parameters',
405 ErrorTypes.VALIDATION,
406 'Guild, user, and moderator are required'
407 );
408 }
409
410 const bans = await guild.bans.fetch();
411 const banInfo = bans.get(user.id);
412
413 if (!banInfo) {
414 throw new TitanBotError(
415 'User not banned',
416 ErrorTypes.VALIDATION,
417 `${user.tag} is not currently banned from this server`
418 );
419 }
420
421 await guild.members.unban(user.id, reason);
422
423 const caseId = await logModerationAction({
424 client: guild.client,
425 guild,
426 event: {
427 action: 'Member Unbanned',
428 target: `${user.tag} (${user.id})`,
429 executor: `${moderator.user.tag} (${moderator.id})`,
430 reason,
431 metadata: {
432 userId: user.id,
433 moderatorId: moderator.id
434 }
435 }
436 });
437
438 logger.info(`User unbanned: ${user.tag} by ${moderator.user.tag} in ${guild.name}`);
439
440 return {
441 success: true,
442 caseId,
443 user: user.tag,
444 reason
445 };
446 } catch (error) {
447 logger.error('Error unbanning user:', error);
448 throw error;
449 }
450 }
451}

Callers 1

executeFunction · 0.80

Calls 2

logModerationActionFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected