我有一個機器人,如果您在非命令通道中使用命令,它會發送一條消息,它會告訴您僅在正確的通道中使用命令,但我希望它不會影響具有員工角色的人員,這是我得到的代碼這個錯誤TypeError: Cannot read property 'roles' of null 我的代碼:client.on('message', message => {if(!message.member.roles.cache.has(784236433975541771)) { if (message.content.startsWith("-")) { if (message.channel.id === '759066524605612108') return; if (message.channel.id === '775035651640918067') return; if (message.channel.id === '777287305580511262') return; message.channel.send('You have been pinged in the <#759066524605612108> channel with the results to your command. Please only use commands there.'); }else if (message.content.startsWith("!")) { if (message.channel.id === '759066524605612108') return; if (message.channel.id === '775035651640918067') return; if (message.channel.id === '777287305580511262') return; message.channel.send('Rank has been disabled in this channel. Please only use commands in the <#759066524605612108> channel.'); }}});我正在嘗試這樣做是discord.js v12
使只有具有特定角色的人才能使用命令。在discord.js v12+ 中
慕雪6442864
2023-10-14 09:48:36