0
votes

I've tried all the solutions for this posted and none of them work. It could be because I'm running MacOS, BigSur. I have the latest discord.js and node.js. Here are two examples that didn't work.

("message", function (message) {
if (message.content === "!command")
return channel01 = bot.channel.cache.find(channel =>  channel.id === "channelID");
channel01.send("message")
                })

client.on('!command', client => {
                client.channels.get('channelID').send('message');
                })

I made a bot. It comes online and can return simple copycat messages in the personal messages between me and the bot. I want to be able to type the command anywhere in the server (it has several text channels) and have the message return in 1 specific text channel.

1

1 Answers

1
votes

Here's a simple snippet to react to a specific command and post a reply to that command in a specific channel.

client.on('message', message => {
if (message.content.startsWith('COMMAND')) {
const channel = member.guild.channels.cache.find(ch => ch.name === 'YOUR CHANNEL NAME HERE');
if (!channel) return;
channel.send('YOUR REPLY HERE');
}});

Or you can use this to send the message to a channel with a specific ID, not a name:

const channel = message.guild.channels.cache.get('YOUR ID HERE');