javascript - 如果玩家有角色(discord.js)
问题描述
所以我制作了一个不和谐的机器人,我想制作一个只有在使用该命令的人有一个名为“colorm”的角色时才有效的命令
这是这个代码
client.on('message', msg => {
if (msg.content === '!setupcolors'){
if(msg.guild.roles.find(role => role.name === "colorm")){
console.log("cmd: !setupcolors >> Command used.");
msg.reply(String('Hi! this command is under constuction'));
}
else{
msg.reply(String('Hi! you need to have a rank called "colorm" to acces this command.'));
console.log("Error[cmd: !setupcolors] >> No perms.");
}
}
});
谢谢!:D
解决方案
尝试使用这个 -if(!msg.member.roles.cache.some(role => role.name === 'colorm'))
推荐阅读
- php - php - 通过 CURLOPT_POSTFIELDS 发布数组
- python - fig.axes 返回的轴比我启动的要多。(python matplotlib)
- python - ModuleNotFoundError:没有在 Python 中命名的模块
- html - 有没有办法让在调整窗口大小时动态创建的复选框粘在另一个元素上?
- sql-server - Azure Sql 服务器上的 Dacpac 部署:“无法执行删除操作,因为以下范围已锁定”
- shell - shell脚本的Groovy参数
- vim - vim:映射引用之间的冲突
- docker - 如何将 docker 容器中的 jar 文件创建的文件用作卷
- r - 按数据框中的百分比填充ggplot中的geom_bar
- javascript - 如何将 currentapple 变量传递给这个函数?