Hi all,
I have a problem, I want to let perform a command only if the user has a specific role but it gives me the error, unexpected { on this rule:
if (message.member.roles.has(allowedRole.id) {
Can someone help me with my problem?
<pre>let allowedRole = message.guild.roles.find("name", "rolename");
if (message.member.roles.has(allowedRole.id) {
client.on('message', message => {
if (!message.guild) return;
if (message.content.startsWith(prefix + 'kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick(' ')
.then(() => {
message.reply(`Successfully kicked ${user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to kick!");
}
}
});
} else {
console.log("You don't have the permission to kick users!")
})
edit:
I guess it is in this rule:
if (message.member.roles.has(allowedRole.id) {
With the first round bracket, it says that it is not ending but it is...
edit:
client.on('message', message => {
if (!message.guild) return;
if (message.content.startsWith('!kick')) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.kick('Optional reason that will display in the audit logs')
.then(() => {
message.reply(`Successfully kicked ${user.tag}`);
})
.catch(err => {
message.reply('I was unable to kick the member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to kick!");
}
}
});
Somewehere has to come that error message with you don't have the permission, but i don't know where..
Thanks,
Sam
What I have tried:
I tried to search internet but the solution that is provided is not working for me. Because I do something wrong but cannot figure out what!