Audit Log Channel Update Event

With the code below, when I update a channel's parent, auditLog is undefined. Why?
module.exports = {
name: Events.ChannelUpdate,
on: true,
async execute(oldChannel, newChannel, client){
const guild = client.guilds.cache.get(newChannel.guildId)
if (!guild) return;
if (newChannel.type == ChannelType.DM || newChannel.type == ChannelType.GroupDM) return;
const auditLogs = await guild.fetchAuditLogs({
limit: 1,
type: AuditLogEvent.ChannelUpdate
});
--> const auditLog = auditLogs.entries.first()
module.exports = {
name: Events.ChannelUpdate,
on: true,
async execute(oldChannel, newChannel, client){
const guild = client.guilds.cache.get(newChannel.guildId)
if (!guild) return;
if (newChannel.type == ChannelType.DM || newChannel.type == ChannelType.GroupDM) return;
const auditLogs = await guild.fetchAuditLogs({
limit: 1,
type: AuditLogEvent.ChannelUpdate
});
--> const auditLog = auditLogs.entries.first()
1 Reply
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Want results from more Discord servers?
Add your server