如何获取添加了机器人的用户



我目前正在开发一个Discord.js机器人,我希望获得将该机器人添加到公会的用户的id或名称。

我希望添加机器人的人得到一个DM。

谢谢你的回答!

client.on("guildCreate", guild => { // This event fires when a guild is created or when the bot is added to a guild.
guild.fetchAuditLogs({type: "BOT_ADD", limit: 1}).then(log => { // Fetching 1 entry from the AuditLogs for BOT_ADD.
log.entries.first().executor.send(`Thank you for adding me to ${guild.name}!`).catch(e => console.error(e)); // Sending the message to the executor.
});
});

最新更新