【发布时间】:2020-11-07 20:47:17
【问题描述】:
bot.on('channelCreate', async channel => {
if (!channel.guild) return;
const fetchedLogs = await channel.guild.fetchAuditLogs({
limit: 1,
type: 'CHANNEL_CREATE',
});
const logbook = channel.guild.channels.cache.get("ChannelID")
const deletionLog = fetchedLogs.entries.first();
if (!deletionLog) return logbook.send(`A channel was updated but no relevant autid logs were found`);
const { executor, user } = deletionLog;
if (user.id) {
logbook.send(`${executor.tag} created a channel`);
} else {
logbook.send(`A channel was created but idk who did.`);
}
});
在通过Discord Audit Logs 获取操作时,我是新手;所以我正在试验,并以某种方式想出了这段代码。但是,当我创建频道时,它不会发送任何消息说频道已由@user 创建。我不知道我的下一步是什么。我只想知道是谁创建了这个频道。
Discord.JS:v12.2.0
【问题讨论】:
-
您是否在控制台中遇到任何错误?
-
@Jakye 不,我没有收到任何错误。我只是忘了添加
try...catch
标签: javascript node.js discord bots discord.js