Вы уверены, что используете версию Discord v12? для Discord v12 вы можете использовать:
if (!message.member.roles.cache.has('ROLE ID')) return message.reply('You has no permission for this')
if (!message.member.roles.cache.some(role => ['ID','ID2'].includes(role.id))) return message.reply('You has no permission for this')
для Discord v11 вы можете использовать:
if (!message.member.roles.has('ROLE ID')) return message.reply('You has no permission for this')
if (!message.member.roles.some(role => ['ID','ID2'].includes(role.id))) return message.reply('You has no permission for this')
V2
bot.on('message', function(message) {
/* If message content not start with prefix stop function. Better do negative check, because it will avoid nesting. */
if(!message.content.startsWith(PREFIX)) return
/* if message startsWiht prefix declarate a command */
let command = message.content.substring(message.content.indexOf(" ") + 1, message.content.length);
/* Now we can check user role */
if (!message.member.roles.cache.has('691441168000483409')) {
/* if Message.member has no target role stop function, send error message, and delete after 5s */
message.reply('You has no permission for this').then(msg => {
msg.delete({ timeout: 2000 });
});
return;
}
/* Now you can enter code whats you need */
});
V3
bot.on('message', message => {
if (message.channel.type === 'dm') return
let args = message.content.substring(PREFIX.length).split(" ");
/* If message content not start with prefix stop function. Better do negative check, because it will avoid nesting. */
if(!message.content.startsWith(PREFIX)) return
/* if message startsWiht prefix declarate a command */
let command = message.content.substring(message.content.indexOf(" ") + 1, message.content.length);
/* Now we can check user role */
if (!message.member.roles.cache.has('691441168000483409')) {
/* if Message.member has no target role stop function, send error message, and delete after 5s */
message.reply('You has no permission for this').then(msg => {
msg.delete({ timeout: 2000 });
});
return;
}
switch(args[0].toLowerCase()) {
case "aa1":
bot.commands.get('aa1').execute(message, args);
break;
case "aa2":
bot.commands.get('aa2').execute(message, args);
break;
}
});