第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使只有具有特定角色的人才能使用命令。在discord.js v12+ 中

使只有具有特定角色的人才能使用命令。在discord.js v12+ 中

慕雪6442864 2023-10-14 09:48:36
我有一個(gè)機(jī)器人,如果您在非命令通道中使用命令,它會(huì)發(fā)送一條消息,它會(huì)告訴您僅在正確的通道中使用命令,但我希望它不會(huì)影響具有員工角色的人員,這是我得到的代碼這個(gè)錯(cuò)誤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
查看完整描述

2 回答

?
qq_笑_17

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果有人發(fā)現(xiàn)這個(gè)并正在尋找我使用過(guò) let allowedRole = message.guild.roles.cache.find(r => r.name === "Staff"); 并且對(duì)我有用的答案。



查看完整回答
反對(duì) 回復(fù) 2023-10-14
?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

您可以嘗試這樣的操作,以允許具有特定角色的成員使用您的命令:


let allowedRole = message.guild.roles.find("name", "Staff");

if (message.member.roles.has(allowedRole.id) {

    // allowed access to command

} else { //aka members who arent staff 

   // not allowed access

}


查看完整回答
反對(duì) 回復(fù) 2023-10-14
  • 2 回答
  • 0 關(guān)注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)