require(‘dotenv’).config();
const { Client, GatewayIntentBits } = require(‘discord.js’);
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
],
});client.login(process.env.BOT_TOKEN);
client.on(‘ready’, () => {
console.log(“Bot has logged in.”);
});client.on(‘message’, async message => {
if(message.author.bot) return;
if(message.content.toLowerCase() === ‘?listen’) {message.channel.send(‘bot is collecting messages now…’);
let filter = m => !m.author.bot;
let collector = new discord.MessageCollector(message.channel, filter);
let destination = client.channels.get(‘1235316261081190491’);
collector.on(‘collect’, (m, col) => {
console.log(“Collected message: ” + m.content);
if(destination) {
if(m.content.toLowerCase() === ‘?stop’ && (message.author.id === m.author.id)) {
console.log(“Stopping collector.”);
collector.stop();
}
else {
let embed = new discord.RichEmbed()
.setTitle(“New Message”)
.setDescription(m.content)
.setTimestamp()
.setAuthor(m.author.tag, m.author.displayAvatarURL)
.setColor(‘#FFAB32’)
destination.send(embed);
}
}
});
collector.on(‘end’, collected => {
console.log(“Messages collected: ” + collected.size);}
});
as you can see from CMD pic when I typed ?listen on Discord channel there is nothing happen.
CMD
any one could help ?
I would like to get messages from discord channel when user using command, thank you in advance for helping me
Muted NFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.