Discord.js v12.5.3 有没有办法在交互中添加角色?

Discord.js v12.5.3 is there a way I could add role(s) on interaction?

我的应用程序系统已完成 90%,但我遗漏了一件事

我正在尝试在有人申请时添加角色, 我试着用这个

let teamRole = message.guild.roles.cache.find(role => role.id == "761996603434598460")

member.roles.add(teamRole)

但它没有添加角色(我没有收到任何错误)

有没有什么办法可以用下面的代码进行交互?

client.ws.on("INTERACTION_CREATE", async (interaction) => {
    // If component type is a button
    if (interaction.data.component_type === 2) {
        const guildId = interaction.guild_id;
        const userId = interaction.member.user.id;
        const buttonId = interaction.data.custom_id;
        const member = client.guilds.resolve(guildId).member(userId);
        if (buttonId == "send_application") {
            // Reply to an interaction, so we don't get "This interaction failed" error
            client.api.interactions(interaction.id, interaction.token).callback.post({
                data: {
                    type: 4,
                    data: {
                        content: "I have started the application process in your DM's.",
                        flags: 64 // make the message ephemeral
                    }
                }
            });

我将不胜感激

当您添加一个角色时,它应该是一个雪花值,所以您应该使用 ID 而不是角色本身来添加

不正确:

let teamRole = message.guild.roles.cache.find(role => role.id == "761996603434598460")

member.roles.add(teamRole)

正确:

// using the ID Directly
member.roles.add('761996603434598460')