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

Function validateBotCanAssignRole

src/services/verificationService.js:454–494  ·  view source on GitHub ↗
(guild, roleId)

Source from the content-addressed store, hash-verified

452}
453
454export async function validateBotCanAssignRole(guild, roleId) {
455 const role = guild.roles.cache.get(roleId);
456
457 if (!role) {
458 logger.warn('Cannot assign role - role not found', {
459 guildId: guild.id,
460 roleId
461 });
462 return false;
463 }
464
465 const botMember = guild.members.me;
466 if (!botMember) {
467 logger.warn('Cannot assign role - bot member not found in guild cache', {
468 guildId: guild.id,
469 roleId
470 });
471 return false;
472 }
473
474 if (!botMember.permissions.has(PermissionFlagsBits.ManageRoles)) {
475 logger.warn('Cannot assign role - missing ManageRoles permission', {
476 guildId: guild.id,
477 roleId
478 });
479 return false;
480 }
481
482 const botHighest = botMember.roles.highest;
483 if (role.position >= botHighest.position) {
484 logger.warn('Cannot assign role - role hierarchy issue', {
485 guildId: guild.id,
486 roleId,
487 rolePosition: role.position,
488 botHighestPosition: botHighest.position
489 });
490 return false;
491 }
492
493 return true;
494}
495
496function evaluateAutoVerifyCriteria(member, autoVerifyConfig) {
497 const { criteria, accountAgeDays } = autoVerifyConfig;

Callers 3

verifyUserFunction · 0.85
autoVerifyOnJoinFunction · 0.85
removeVerificationFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected