(guild, roleId)
| 452 | } |
| 453 | |
| 454 | export 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 | |
| 496 | function evaluateAutoVerifyCriteria(member, autoVerifyConfig) { |
| 497 | const { criteria, accountAgeDays } = autoVerifyConfig; |
no test coverage detected