Discord Bot Can't Get Channel by Name
You should use the channnel id instead of it's name.
How to get the channel id of a channel:
Open up your Discord Settings
Go to
Appearance
Tick
Developer Mode
(And close the Discord settings)Right click on your desired channel
Now there's an option
Copy ID
to copy the channel id
Also checkout the discord.js documentation for (channel) collections
Furthermore your approach won't work because .get
wants a channel id (see the linked documentation above). In case you REALLY want to get an channel by its name, use .find
instead for that.
This is however a really bad idea in case your bot runs on more than one server since channel names can now occur multiple times.
You can also use
bot.channels.find("name","welcome").send("Welcome!")
I tried a lot with the same error, and that's how I fixed it. I used client as my Client().
client.channels.cache.get("18NUMBERIDHERE").send("Welcome!");