【问题标题】:How to check who edited the channel on Discord through channelUpdate event如何通过 channelUpdate 事件检查谁在 Discord 上编辑了频道
【发布时间】:2020-10-28 12:23:48
【问题描述】:

我正在创建 updateChannel 事件,但是,当我浏览 Discord.JS 文档时,我似乎无法找到或弄清楚谁编辑了该频道;或者这甚至可能吗?我将在此消息下方提供当前代码。

Discord.JS:v12.2.0

client.on("channelUpdate", async(oldChannel, newChannel) => {
  if(oldChannel.type === "dm") return undefined;

    const embed = new Discord.MessageEmbed()
      .setAuthor("Channel Updated", oldChannel.guild.iconURL({ dynamic: true }))

    oldChannel.send(embed)
}); 

【问题讨论】:

  • 我认为您需要为此使用公会审核日志
  • @Giuliopime 也有人告诉我,从审计日志中获取信息。但是,我不完全确定如何做到这一点。

标签: javascript node.js bots discord discord.js


【解决方案1】:

是的,有可能,你需要fetch audit logs:

oldChannel.guild.fetchAuditLogs({ type: 11, limit: 1 }) // CHANNEL_UPDATE
  .then((logs) => {
     embed.setDescription(logs.entries.first().executor); // Get First from Collection of GuildAuditLogs, and its executor.
     oldChannel.send(embed);
  })
  .catch(console.error);

【讨论】:

  • 谢谢,但是,我收到一个错误:TypeError: Cannot read property 'executor' of undefined
猜你喜欢
  • 2015-12-22
  • 2018-06-20
  • 2019-03-07
  • 1970-01-01
  • 2014-03-27
  • 2019-04-03
  • 2018-01-07
  • 2021-08-16
  • 1970-01-01
相关资源
最近更新 更多