Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Permission Checking Mechanisms for Moderation and Admin Commands #14

Open
NightSling opened this issue Mar 14, 2025 · 0 comments

Comments

@NightSling
Copy link

The GNOME Nepal Discord Bot currently lacks proper permission checking mechanisms for moderation and admin commands. This could potentially allow any user to execute commands that should be restricted to administrators or moderators only.

Details:
All commands within Moderation and System-Admin directory do not have proper checks to ensure that only users with appropriate roles can execute them.

Without these checks, there is a risk to abuse where unauthorized users can perform actions that could disrupt the server's operations and community.

Proposal:
To enhance the security and proper functioning of the GNOME Nepal Discord Bot, I recommend implementing permission checking mechanisms in the pre-command execution phase for both slash and normal commands. This involves creating new attributes necessaryRoles and necessaryPermissions for each command and integrating permission checks within the interaction and message listeners.

Steps for Implementation:

  1. Define New Attributes:
  • Add necessaryRoles and necessaryPermissions attributes to both slash commands and normal commands. These attributes will specify the roles and permissions required to execute each command.
    Example Definition:
// Example Slash Command Definition
module.exports = {
    data: new SlashCommandBuilder()
        .setName('adminhelp')
        .setDescription('Displays a list of available admin commands and their descriptions.'),
    necessaryRoles: ['Admin'], // Specify necessary roles
    necessaryPermissions: ['KICK_MEMBERS', 'BAN_MEMBERS'], // Specify necessary permissions
    async execute(interaction) {
        // Command execution logic
    },
};
  1. Update Interaction Listener:
  • Modify the interactionCreate and messageCreate event listener in index.js to check for the necessary roles and permissions before executing a command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant