我想创建一个if
语句,以检测消息作者是否具有名为System Control Authority - 50
的角色。如果是这样,他们将无法使用该命令。我该怎么办?
const sys10 = client.guilds.cache
.get('745816516238245888')
.roles.cache.find((role) => role.name === 'System Control Authority - 10');
if (cmd == 'aerial') {
message.delete({ timeout: 10 });
if (!sys10 && !devRole && !adminRole && !qgRole && !qgtsRole) {
return func.Loi(
'You cannot use this command.\nRequire role: **System Control Authority - 10**'
);
}
const takelinda = message.mentions.members.first().id;
if (takelinda == '669723732708687882') {
return func.Loi(message, 'You cannot use this command to me =)))');
}
return message.channel.send(
'*<@' +
message.author.id +
'>:*\nSystem Call.\nGenerate Aerial Element.\nBurst Element!\n*<@' +
takelinda +
'>: ahhhhh*\n*System: <@' +
takelinda +
'> has been defeated.*'
);
}
答案 0 :(得分:0)
您可以使用Collection#some
方法。
// get the member's roles, check if any of them pass the name test
if (message.member.roles.cache.some(role => role.name === 'System Control Authority - 10')
return func.Loi(message, 'You have the System Control Authority - 10 role, so you cannot use this command')