Discord.js: Cannot read property 'id' of undefined

Created on 22 Jun 2020  Â·  4Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
When passing in the 'channel' param in the event, .id returns a error. I have gone to a help server and I am the only one with this issue

Include a reproducible code sample here, if possible:

// Place your code here
bot.on("channelDelete", (message, channel) => {
  const deletedChannel = channel.id;
  channel.guild.fetchAuditLogs({'type': 'CHANNEL_DELETE'})
  .then(logs => logs.entries.find(entry => entry.target.id == deletedChannel))
  .then(entry => {
    let author = entry.executor;

    let serverembed = new Discord.MessageEmbed()
    .setDescription("Channel Updated")
    .setColor("#db25db")
    .addField("Channel", channel)
    .addField("Moderator", author)

    message.guild.channels.cache.find(ch => ch.name == "staff-logs").send(serverembed);
  });
})

Further details:

  • discord.js version: 12.2.0
  • Node.js version: 10.21.0
  • Operating system: Ubuntu
  • Priority this issue should have – please be realistic and elaborate if possible: Serious/Moderately
  • [x] I have also tested the issue on latest master, commit hash:
unverified bug

All 4 comments

Client#channelDelete does not have a message parameter

This would have been easily spotted by anyone half-competent on the server.

Hi, thank you. I do not fully remember adding that code however I am getting a new error:
TypeError: fields.flat is not a function
It directs me to discord.js's MessageEmbed.js file

Discord.js v12 requires at least Node v12.

Duplicate of #3949, #3913, #3910, #3888, #3887, #3883 and #4341

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

Thank you so much for the help, I will move my error there!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LLamaFTL picture LLamaFTL  Â·  3Comments

kvn1351 picture kvn1351  Â·  3Comments

iCrawl picture iCrawl  Â·  3Comments

shukriadams picture shukriadams  Â·  3Comments

Alipoodle picture Alipoodle  Â·  3Comments