515 debug command#532
Conversation
…eloper-as-permission-levels senior dev and dev rank create
…ord-bot into 515-debug-command
|
The preview deployment failed. 🔴 Last updated at: 2025-06-13 18:47:18 CET |
|
yarn... |
|
Run these commands |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a debug command for developers to get bot information, adding new developer access levels and associated permissions. The changes introduce a new bot_info command that displays system metrics like CPU usage, memory consumption, and git commit information.
- Adds two new developer access levels (Dev and SeniorDev) to the permission system
- Creates a new bot_info slash command restricted to developers that shows system diagnostics
- Updates the illegal nickname handler to exempt senior developers from automatic nickname changes
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| stack.env | Adds environment variables for developer role IDs |
| src/custom_interactions/chat_input/bot_info.ts | Implements new bot_info command with system diagnostics |
| src/common/permissions.ts | Adds developer role validation and permission checks |
| src/common/managers/custom_interactions_manager.ts | Updates access level enum to include Dev and SeniorDev levels |
| src/common/handlers/illegal_nickname_handler.ts | Exempts senior developers from nickname enforcement |
| package.json | Adds process-top dependency for system monitoring |
| const cpu = topLoad.cpu(); | ||
| const memory = topLoad.memory(); | ||
|
|
||
| function toPorcentage (value: number): string { |
There was a problem hiding this comment.
Function name 'toPorcentage' has a spelling error. It should be 'toPercentage'.
| function toPorcentage (value: number): string { | |
| function toPercentage (value: number): string { |
| return execSync('git rev-parse HEAD').toString().trim(); | ||
| } catch (error) { | ||
| console.error('Error getting commit:', error); | ||
| return 'Error to get git commit'; |
There was a problem hiding this comment.
Error message has grammatical error. Should be 'Error getting git commit' or 'Failed to get git commit'.
| return 'Error to get git commit'; | |
| return 'Error getting git commit'; |
|
|
||
| function getCurrentCommit(): string { | ||
| try { | ||
| return execSync('git rev-parse HEAD').toString().trim(); |
There was a problem hiding this comment.
Using execSync with a hardcoded command is generally safe, but consider using a more secure alternative like a git library to avoid potential command injection if this pattern is used elsewhere with dynamic input.
|
|
||
| //------------------------------------------------------------// | ||
|
|
||
| const topLoad = top(); //Need load function for have register of CPU |
There was a problem hiding this comment.
Comment has grammatical errors. Should be 'Need to load function to register CPU' or 'Load function needed to register CPU usage'.
| const topLoad = top(); //Need load function for have register of CPU | |
| const topLoad = top(); //Load function needed to register CPU usage |
| if (await fetchHighestAccessLevelForUser(client, member.user) === CustomInteractionAccessLevel.Moderators) return; | ||
|
|
||
| const highest_access_level_for_user = await fetchHighestAccessLevelForUser(client, member.user); | ||
| if (highest_access_level_for_user === CustomInteractionAccessLevel.Moderators || highest_access_level_for_user === CustomInteractionAccessLevel.SeniorDev) return; |
There was a problem hiding this comment.
The logic only checks for exact equality with Moderators or SeniorDev, but since access levels are hierarchical (higher numbers = higher access), this should check if the user's access level is >= Moderators to include all higher-level roles.
| if (highest_access_level_for_user === CustomInteractionAccessLevel.Moderators || highest_access_level_for_user === CustomInteractionAccessLevel.SeniorDev) return; | |
| if (highest_access_level_for_user >= CustomInteractionAccessLevel.Moderators) return; |
No description provided.