Why I'm unable to send messages in Announcement type channels?

module.exports = {
name: 'msg',
description: "",
run: async (client, message, args) => {

var chan = message.mentions.channels.first();
var msg;

if (!chan) {
chan = message.channel;
msg = args.join(" ");
} else {
msg = args.slice(1).join(" ");
}

try {
await chan.send({ content: `${msg}` });
} catch (error) {
console.error(error);
message.reply({ content: 'An error occurred while sending the message. Please try again later.'});
}
await message.delete();
}
}
module.exports = {
name: 'msg',
description: "",
run: async (client, message, args) => {

var chan = message.mentions.channels.first();
var msg;

if (!chan) {
chan = message.channel;
msg = args.join(" ");
} else {
msg = args.slice(1).join(" ");
}

try {
await chan.send({ content: `${msg}` });
} catch (error) {
console.error(error);
message.reply({ content: 'An error occurred while sending the message. Please try again later.'});
}
await message.delete();
}
}
7 Replies
d.js toolkit
d.js toolkit13mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
treble/luna
treble/luna13mo ago
does the bot have permission to send messages in that channel, and do you have any errors
! Murali Anand
! Murali Anand13mo ago
no errors and bot has the required perms too
treble/luna
treble/luna13mo ago
does your trigger message get deleted?
! Murali Anand
! Murali Anand13mo ago
no this issue only occurs when i try to send message at announcement type channel and works perfectly in normal text type
treble/luna
treble/luna13mo ago
i'd also recommend using let or const instead of vars, but try logging the channel when you send it to an announcement channel. and how are you sending it, are you sending it by mentioning the channel, or by running the command in the channel oh wait i think i might see the issue not sure though but i assume your args is an array? or nvm
! Murali Anand
! Murali Anand13mo ago
yes, i've found that message prefix commands doesnt work at announcement type channels is this normal? but in the slash command "Hello World" I'm unable to type messages like these. I mean line by line think I think, I gotta use some brain. thx