如何知道机器人的邀请人? discord.js
How to know the inviter of the bot ? discord.js
我想知道机器人的邀请者是谁,但我在文档或论坛上找不到任何信息。
如果有人有想法:/
编辑
最近 discord 在公会审核日志中添加了一个条目,每次有人将机器人添加到服务器时都会记录下来,因此您可以使用它来了解谁添加了机器人。
示例:
// client needs to be instance of Discord.Client
// Listen to guildCreate event
client.on("guildCreate", async guild => {
// Fetch audit logs
const logs = await guild.fetchAuditLogs()
// Find a BOT_ADD log
const log = logs.entries.find(l => l.action === "BOT_ADD" && l.target.id === client.user.id)
// If the log exits, send message to it's executor
if(log) log.executor.send("Thanks for adding the bot")
})
老答案
discord API 不允许这样做。
但是,您可以使用 属性 guild.owner
向公会所有者发送消息以获取它
client.on('guildCreate', guild => {
guild.owner.send('Message here').catch(e => {
// Can't message to this user
})
})
我想知道机器人的邀请者是谁,但我在文档或论坛上找不到任何信息。 如果有人有想法:/
编辑
最近 discord 在公会审核日志中添加了一个条目,每次有人将机器人添加到服务器时都会记录下来,因此您可以使用它来了解谁添加了机器人。 示例:
// client needs to be instance of Discord.Client
// Listen to guildCreate event
client.on("guildCreate", async guild => {
// Fetch audit logs
const logs = await guild.fetchAuditLogs()
// Find a BOT_ADD log
const log = logs.entries.find(l => l.action === "BOT_ADD" && l.target.id === client.user.id)
// If the log exits, send message to it's executor
if(log) log.executor.send("Thanks for adding the bot")
})
老答案
discord API 不允许这样做。
但是,您可以使用 属性 guild.owner
向公会所有者发送消息以获取它
client.on('guildCreate', guild => {
guild.owner.send('Message here').catch(e => {
// Can't message to this user
})
})