This worked for me:
Command Coding
// Command coding
module.exports = {
name: 'giveallrole',
description: "giveallrole cmd!",
async execute(message, args) {
message.channel.bulkDelete(1);
//Does the person have moderator rank? - Just change the ID.
if(message.member.roles.cache.has('854013128928919552')){
// What role is it?
let role = message.mentions.roles.first()
// Do the command action include the role. (Change the message if you don't want it to be danish.)
if (!role) return message.channel.send(`**${message.author.username}**, rollen blev ikke funddet`)
// Giv the role.
message.guild.members.cache.filter(m => !m.user.bot).forEach(member => member.roles.add(role))
// Return message - just change the message, it's right now in danish.
message.channel.send(`**${message.author.username}**, rollen **${role.name}** blev tilføjet til alle medlemmer!`)
}else{
// Return message if the person doesn't have moderator.
message.reply("Du har ikke tilladelse til dette.");
}
} }
index.js / main.js coding
// Index.js / main.js coding
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command == 'giveallrole'){
client.commands.get('giveallrole').execute(message, args);
}
});