Answer the question
In order to leave comments, you need to log in
How to make the bot display the channel name?
I want to make a chat logger bot. So far, I've implemented sending a message when a pin is updated in a channel. But there is one thing... The bot sends a message with the channel ID when I need it to unsubscribe its name.
const Discord = require("discord.js");
const client = new Discord.Client();
const logger = require("discordjs-logger");
logger.all(client);
const {MessageEmbed} = require('discord.js');
client.on("channelPinsUpdate", function (channel, time) {
let logchannel = client.channels.cache.get("829024037397200926");
let PinsUpdateEmbed = new MessageEmbed()
.setTitle("Обновление закрепленных сообщений")
.setColor("#FFFF00")
.setDescription('Обновлен закреп в канале\n' + channel + '\nв ' + time)
logchannel.send(PinsUpdateEmbed)
});
client.login("");
Answer the question
In order to leave comments, you need to log in
When this event fires , the transmitted channel can be a DMChannel (private messages) or a TextChannel (a text channel on the server). In the first case, you can't get the channel name because these are private messages. In the second case, you need to get the name field ( channel.name ).
You will get something like:
.setDescription('Обновлен закреп в канале\n' + channel.name + '\nв ' + time)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question