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

Method validateHierarchy

src/services/moderationService.js:52–85  ·  view source on GitHub ↗
(moderator, target, action)

Source from the content-addressed store, hash-verified

50 }
51
52 static validateHierarchy(moderator, target, action) {
53 if (!moderator || !target) {
54 return { valid: false, error: 'Invalid moderator or target' };
55 }
56
57 if (moderator.guild?.ownerId === moderator.id) {
58 return { valid: true };
59 }
60
61 const modRole = getHighestRole(moderator);
62 const targetRole = getHighestRole(target);
63
64 if (!modRole || !targetRole) {
65 return {
66 valid: false,
67 error: 'Could not resolve role hierarchy. Try mentioning the user or use the slash command.',
68 };
69 }
70
71 if (modRole.position <= targetRole.position) {
72 return {
73 valid: false,
74 error: this.buildHierarchyMessage({
75 actor: 'moderator',
76 actorRole: modRole,
77 targetRole,
78 targetLabel: getTargetLabel(target),
79 action,
80 }),
81 };
82 }
83
84 return { valid: true };
85 }
86
87 static validateBotHierarchy(target, action) {
88 if (!target) {

Callers 4

executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80

Calls 3

buildHierarchyMessageMethod · 0.95
getHighestRoleFunction · 0.85
getTargetLabelFunction · 0.85

Tested by

no test coverage detected