Is there a quick and easy way to get a channels name by id?

this code drops an error so ig im doing it wrong
client.channels
   .fetch(message.channel)
   .then((ch) => console.log('channel name is: ' + ch.name))
   .catch(console.error);


DiscordAPIError[50035]: Invalid Form Body
channel_id[NUMBER_TYPE_COERCE]: Value "<" is not snowflake.
    at handleErrors (/home/j44/Downloads/themer/tut/node_modules/@discordjs/rest/dist/index.js:687:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (/home/j44/Downloads/themer/tut/node_modules/@discordjs/rest/dist/index.js:1072:23)
    at async SequentialHandler.queueRequest (/home/j44/Downloads/themer/tut/node_modules/@discordjs/rest/dist/index.js:913:14)
    at async _REST.request (/home/j44/Downloads/themer/tut/node_modules/@discordjs/rest/dist/index.js:1218:22)
    at async ChannelManager.fetch (/home/j44/Downloads/themer/tut/node_modules/discord.js/src/managers/ChannelManager.js:123:18) {
  requestBody: { files: undefined, json: undefined },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: { channel_id: [Object] }
  },
Was this page helpful?