Discord Bot Can't Get Channel by Name

拈花ヽ惹草 提交于 2019-11-28 01:57:04

You should use the channnel id instead of it's name.

How to get the channel id of a channel:

  1. Open up your Discord Settings

  2. Go to Appearance

  3. Tick Developer Mode (And close the Discord settings)

  4. Right click on your desired channel

  5. 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.

Razboy20

You can also use

bot.channels.find("name","welcome").send("Welcome!")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!