1

每当用户加入我的服务器时,就会弹出如下消息:欢迎信息的图片

我需要我的机器人自动添加这些表情符号,但是在列出“guildMemberAdd”事件时,我无法收到此消息。IE。

client.on('guildMemberAdd', member => {
//Looked at docs, have no way to get this message
})

当有人加入时,我将如何查找这些消息?

4

1 回答 1

1

经过一番努力,我找到了一个解决您问题的方法:

在您已经看到之后,只要 DiscordguildMemberAdd公会所有者启用了事件,Discord 就会发送一些随机生成的消息。当然,这条消息有一个消息对象,我们可以简单地使用 方法获取.lastMessage它,它返回我们选择的频道中最新消息的对象。

使用它,我们可以很容易地找到一种方法来继续使用以下方法对 Discord 生成的消息做出反应:

setTimeout(() => {
    const message = member.guild.channels.cache.get('welcome channel id').lastMessage
    message.react('')
}, 500)
// Note: I have set a timeout of half a millisecond as it usually takes the bot longer to register 
// a message at the same time of another command.

从这里,机器人将从我们选择的频道获取最新消息,并添加我们选择的反应。

于 2021-01-05T16:49:06.643 回答