[英]Role Specific Commands for Discord.js v12
是的,我知道這個問題已經問了很多很多很多次了。 然而由於某種原因,我無法獲得適用於 discord.js v12 的角色特定命令。
我已經嘗試了幾乎所有方法,但由於某種原因它不會工作......
這是我當前的代碼:
bot.on('message', message=>{
if(message.content.includes('test')) {
if(message.member.roles.has(roleidgoeshere)) {
message.channel.send('Yay, the author of the message has the role!');
} else {
message.channel.send('Nope');
}
}
});
錯誤: message.member.roles.has is not a function
我對使用 JavaScript 進行編碼非常陌生,因此將不勝感激,如果我不夠清楚,我將盡我所能在評論中回答任何問題
由於 discord.js v12 您需要使用cache
訪問roles
集合,因此您的解決方案將是:
if(message.member.roles.cache.has(roleidgoeshere)) {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.