本文介紹了使用最新的 discord.js 將用戶添加到角色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在 node.js 中使用最新的 discord.js,我正在嘗試將用戶添加到角色,但似乎 bot.addUserToRole() 已被刪除.
當我只知道等級名稱而不知道它的ID時,我該怎么辦?
解決方案
這對我有用,希望對你有幫助!
var role= member.guild.roles.cache.find(role => role.name === "角色名稱");member.roles.add(角色);
這里是它的官方文檔.p>
i'm using newest discord.js in node.js and i'm trying to add user to role, but it seems bot.addUserToRole() was removed.
How can I do it when I know only rank name, not it's ID?
解決方案
Here's what worked for me, hope this helps!
var role= member.guild.roles.cache.find(role => role.name === "role name");
member.roles.add(role);
Here is the official documentation on it.
這篇關于使用最新的 discord.js 將用戶添加到角色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!