How to keep listening to messages from a specific channel?

I've tried two ways but I cannot get any message:
// on messageCreate
module.exports = {
name: Events.MessageCreate,
async execute(m) {
logger.info(m);
},
};

// and on ready
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
logger.info("Ready!") // this work
const channel = client.channels.cache.get(process.env.LISTEN_CHANNEL);
const collector = channel.createMessageCollector();
collector.on("collect", (m) => {
logger.info(m);
});
},
};
// on messageCreate
module.exports = {
name: Events.MessageCreate,
async execute(m) {
logger.info(m);
},
};

// and on ready
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
logger.info("Ready!") // this work
const channel = client.channels.cache.get(process.env.LISTEN_CHANNEL);
const collector = channel.createMessageCollector();
collector.on("collect", (m) => {
logger.info(m);
});
},
};
do I need to add more permissions or intents?
3 Replies
d.js toolkit
d.js toolkit14mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna14mo ago
you are missing the GuildMessages and/or MessageContent intent
PurifiedWater
PurifiedWaterOP14mo ago
It works! Thank you very much!
Want results from more Discord servers?
Add your server