[英]Discord.JS Reaction Roles
我不知道為什么我的反應角色代碼不起作用。 如果有人可以幫助我,將不勝感激!
client.on('messageReactionAdd', async (reaction, person) => {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
};
};
if (reaction.emoji.name == ':tools:') {
if (reaction.message.id === '769855387394375681')
var server = client.guilds.cache.get('769100711593771038');
let personMember = server.members.cache.get(person);
const devRole = server.roles.cache.get('769428024609079319')
personMember.roles.add(devRole);
};
});
client.on('message', message => {
return; //For now, gotta code more stuff later
});
消息 function 用於緩存消息,以便機器人可以檢測對該消息的反應,Idk 如果真的需要的話。
也沒有錯誤,只是不會給我這個角色。
您需要在 if 語句中指定表情符號 ID,而不僅僅是:tools:
。 你可以通過在 Discord 中輸入表情符號,然后在它前面加上一個反斜杠來獲得它。 發送消息,你會得到類似<:tools:213812938712938713>
的信息。 數字部分是您的 ID。
編輯:你需要做if (reaction.emoji.id === 'IDHERE')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.