O
O
Oleg2020-08-21 15:45:47
Node.js
Oleg, 2020-08-21 15:45:47

Is it possible to change the name of the channel by its ID in discord (without using the name)?

In manuals and on the Internet they write like this:

client.guilds.get(GUILD_ID).channels.get(746324211768885318).setName("Проба");

BUT it doesn't work because:
TypeError: Cannot read property 'setName' of undefined


In the discord API, I also did not find (or badly looked for) a method for sending by ID.
If to send using the NAME, then works.
guild.channels.find(channel => CHANNEL_NAME === channel.name);


But in my case, the "NAME" of the channel will change dynamically.
I don't understand how to decide.

Thanks in advance.

A QUICK SOLUTION, so as not to search in a bunch of comments for a heated discussion ....
const guild = bot.guilds.cache.get("id_гильдии")
const channel = guild.channels.cache.find(channel => channel.id === "id_канала")
channel.setName("members")


It is very important to send an ID of type STRING. Those. right in quotes)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-08-21
@VDT2

Is it possible to send a message to a channel ID in discord (without using a name)?

Yes.
use:
client.channels.cache.get('id_канала').send('сообщение');

method .sendcan also be replaced by any other method .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question