【发布时间】:2018-06-05 20:31:25
【问题描述】:
我的代码目前是:
if (message.content == ",test") {
if (message.member.roles.find("name", "images")) {
message.channel.send( {
file: "http://www.drodd.com/images14/black11.jpg" // Or replace with FileOptions object
});
}
if (!message.member.roles.find("name", "images")) { // This checks to see if they DONT have it, the "!" inverts the true/false
message.reply('You need the \`images\` role to use this command.')
.then(msg => {
msg.delete(5000)
})
}
message.delete(100); //Supposed to delete message
return; // this returns the code, so the rest doesn't run.
}
如果用户具有“图像”角色,我希望机器人在他们说“,测试”时发送图像,并且我希望在几秒钟后删除用户的“,测试”消息。但是,这似乎不起作用。
我已尝试在不检查角色的情况下发送图像,并且有效。
我该如何解决这个问题?
【问题讨论】:
标签: javascript node.js bots discord discord.js