1 回答
TA貢獻1820條經(jīng)驗 獲得超9個贊
這就是我根據(jù)這個問題想要發(fā)生的事情:
用戶:“!子 1“
機器人: * 將用戶分配到角色 1 *
如果這是你想做的,我會這樣繼續(xù):
您需要存儲您的角色 ID,以便以后可以分配它們。也可以使用角色名稱,但需要記住,如果不更新代碼,則無法更改它。
然后,您需要使用
GuildMember.roles.add()將角色添加到用戶。
下面是一個示例:
// I'll assume that you already have the command structure set up, so these variables will be set:
// - message: The message with the command (its content will be '!Sub 1' in this case)
let role = message.guild.roles.cache.find(r => r.name == 'Premium') // You can use you role's name here
let roleID = '1234...' // This would be your role ID
message.member.roles.add(role || roleID)
這將是添加角色的方法。您只需要根據(jù)用戶輸入的內(nèi)容切換角色名稱/ID,這將是您的第一個參數(shù)。
添加回答
舉報
