-
Notifications
You must be signed in to change notification settings - Fork 1
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
RBAC system commands. #9
Comments
An improvement has been added to the feedback of the! Info command. |
Working in the RBAC system for commands according to the role / permission of the user. PermissionsPermission FlagsSome commands should only be used by someone with certain permissions. const { Command } = require('discord-akairo');
class BanCommand extends Command {
constructor() {
super('ban', {
aliases: ['ban'],
args: [
{
id: 'member',
type: 'member'
}
],
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'],
channel: 'guild'
});
}
async exec(message, args) {
if (!args.member) {
return message.reply('No member found with that name.');
}
await args.member.ban();
return message.reply(`${args.member} was banned!`);
}
}
module.exports = BanCommand; This now checks for the required permissions for the client, then the user. Dynamic PermissionsSometimes, you may want to check for a role instead of permission flags. The return value is the const { Command } = require('discord-akairo');
class BanCommand extends Command {
constructor() {
super('ban', {
aliases: ['ban'],
args: [
{
id: 'member',
type: 'member'
}
],
clientPermissions: ['BAN_MEMBERS'],
channel: 'guild'
});
}
userPermissions(message) {
if (!message.member.roles.cache.some(role => role.name === 'Moderator')) {
return 'Moderator';
}
return null;
}
async exec(message, args) {
if (!args.member) {
return message.reply('No member found with that name.');
}
await args.member.ban();
return message.reply(`${args.member} was banned!`);
}
}
module.exports = BanCommand; Origin: |
Description
A role system must be implemented for the available commands.
If a user has moderator permissions, he can see and execute the commands with the tag, Moderation Commands and Public Commands for example. Whereas a normal user without moderator roles could only execute and view public commands.
It should be noted that when talking about displaying commands, it is referred to that the normal role user executes the "help" command, only the commands available to his role should be shown.
Progress
The text was updated successfully, but these errors were encountered: