ESN Docs

Docs › Help › Error fixes

Fix "Cannot read properties of undefined (reading 'send')" in discord.js

2 min readUpdated Nov 4, 2026

Your code tried to send to a channel that discord.js couldn't find. Wait for the bot to be ready, fetch the channel, and check the ID and permissions.

The error #

TypeError: Cannot read properties of undefined (reading 'send')

Often from a line like this:

client.channels.cache.get("123456789012345678").send("Hello!");

Why it happens #

client.channels.cache.get(id) returned undefined, so there was nothing to call .send on. That happens when:

  • The bot isn't ready yet. The code runs before the ClientReady event, when the cache is still empty.
  • The ID is wrong or is a number instead of a string (big IDs lose digits as numbers).
  • The bot can't see the channel: it's not in that server, or the channel is hidden from its role.
  • The channel isn't cached, for example a thread or a DM channel.

How to fix it #

1. Wait for ready, and fetch instead of relying on the cache:

client.once(Events.ClientReady, async () => {
  const channel = await client.channels.fetch("123456789012345678").catch(() => null);
  if (!channel || !channel.isTextBased()) {
    console.log("Channel not found or not a text channel. Check the ID and the bot's access.");
    return;
  }
  await channel.send("Hello!");
});

2. Keep IDs as strings. Copy them with Developer Mode on (User Settings → Advanced → Developer Mode, then right-click the channel → Copy Channel ID), and put them in quotes.

3. Check access. The bot's role needs View Channel and Send Messages in that channel. Without it, you'll get Missing Access (50001) or Missing Permissions (50013) once the channel is found.

Same error, other names #

The same cause shows up as reading 'roles', reading 'members' or reading 'id': something you expected to exist was undefined. Log the value right before the line that crashes to see which one.

Stop one error from crashing the bot #

On ESN the server restarts your bot if it crashes, but it's better not to crash. Wrap risky calls in try/catch (or .catch()) and add a last-resort handler:

process.on("unhandledRejection", (error) => {
  console.error("Unhandled promise rejection:", error);
});

The full error still shows in your Console.

FAQ #

Why does it work sometimes? #

The cache fills up as the bot runs. Code that runs early, or right after a restart, finds an empty cache. Fetching avoids that.

Is this a discord.js bug? #

No. It means a value was undefined. In discord.js v14, fetching or checking for undefined is the normal fix.

What is the discord.py version of this? #

In discord.py, bot.get_channel(id) returns None and you get AttributeError: 'NoneType' object has no attribute 'send'. Use await bot.fetch_channel(id) after the bot is ready.

Host your bot 24/7 from $0.50/month →

Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 4, 2026.