Reputation: 1
I made my Discord bot for Minecraft but i have command "satışilanı" I want this command to only use people with the role I specified, but I can't anyone can help me?
const Discord = require('discord.js');
const moment = require('moment');
const cooldown = new Set();
exports.run = async(client, message, ops) => {
let args = message.content.split(' ').slice(1).join(' ');
message.delete();
if (cooldown.has(message.author.id && message.guild.id)) {
return message.channel.send('**:x: [YAVAŞLA] :x:** Çok hızlı ilan gönderiyorsun! **5 Dakika** beklemelisin!');
}
if (args.length < 1) {
return message.channel.send(`**İlan detaylarını iletmelisin!** ${message.author}`);
}
if (message.member.roles.some(role => role.name === 'Whatever')) {
return message.channel.send(`**Ticaretçi rolüne sahip olman gerekiyor!**`);
}
cooldown.add(message.author.id && message.guild.id);
setTimeout(() => {
cooldown.delete(message.author.id && message.guild.id);
}, 300000);
let guild = message.guild;
const cnl = client.channels.get('613397862545358888');
message.channel.send(`**Hey, ${message.author}, biz satış ilanını yayınladık! :white_check_mark:`);
const embed2 = new Discord.RichEmbed()
.setAuthor(`MuzGO Pazar ${message.author.tag} tarafından kullanıldı!`, message.author.displayAvatarURL)
.addField('**MuzGO Satış İlanı :pencil: **', `**İlanı Gönderen: :speaking_head: ** ${message.author.tag}`,`İlanın Gönderildiği Kanal` , '#『💵』satılık-ürünler')
.setThumbnail(message.author.displayAvatarURL)
.setFooter(`${moment().format('MMMM Do YYYY, h:mm:ss a')}`)
.setColor("#ffd700");
};
Here is probably wrong i cant understand.
if (message.member.roles.some(role => role.name === 'Whatever')) {
return message.channel.send(`**Ticaretçi rolüne sahip olman gerekiyor!**`);
}
Upvotes: 0
Views: 48
Reputation: 3005
message.member.roles.some(role => role.name === 'Whatever')
This returns a Boolean, true
if the member has the role, false
if they don't have it. So, to send a message if the member doesn't have the role, you have to add a !
to inverse the condition:
if (!message.member.roles.some(role => role.name === 'Whatever')) {
// if the condition above is false, so the member doesn't have the role
return message.channel.send(`**Ticaretçi rolüne sahip olman gerekiyor!**`);
}
Upvotes: 1