几天前,我编写了一个代码来提及用户加入不和谐服务器时的代码,这是我当前拥有的代码:

bot.on( "guildMemberAdd", member => {
let textChannel = member.guild.channels.find(channel => channel.id === '569582472812298240');

if (textChannel){
        var messages = [
            `Brace yourselves. <@${member.user.id}> just joined the server.`,
            `Challenger approaching - <@${member.user.id}> has appeared`,
            `Welcome <@${member.user.id}>. Leave your weapon by the door.`,
            `Big <@${member.user.id}> showed up!`,
            `<@${member.user.id}> just joined... or did they?`,
            `Ready player <@${member.user.id}>`,
            `<@${member.user.id}> hopped into the server. Kangaroo!!`,
            `<@${member.user.id}> joined. You must construct additional pylons.`,
            `Hello. Is it <@${member.user.id}> you're looking for?`,
            `Where's <@${member.user.id}> in the server!`,
            `It's dangerous to go alone, take <@${member.user.id}>`
        ]

        textChannel.send({embed: {
            color: 3447003,
            description: messages[ Math.floor( Math.random() * 11 ) ],
            timestamp: new Date(),
        }
        });
    }
});



问题?有时我会在这张照片中看到正确的昵称,但有时我只能得到数字,甚至无法单击该“链接” ...

正确方法:

他们是可点击的,我可以看到他们的个人资料。

javascript - Discord.js在欢迎中提及玩家-LMLPHP

错误的方式:

我无法点击他们的ID,因此无法执行任何操作。

javascript - Discord.js在欢迎中提及玩家-LMLPHP

不知道为什么会随机发生,将不胜感激。

最佳答案

如果有人加入服务器然后离开,并且您没有其他相互的服务器并且不是他们的朋友,那么它只会显示他们的用户ID。这是客户端的事情,实际上并没有任何真正的解决办法。但是,您可以选择仅发送其用户名而不是提及。

关于javascript - Discord.js在欢迎中提及玩家,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55978239/

10-11 12:14