I'm setting up a Discord bot, and I want it to send a message to the main channel of my server when I type node .. I typed:
client.on('ready', () => {
const Channel = client.channels.cache.get('<My.General.Channel.ID#>');
if (!Channel) return console.log('Wrong channel!');
else Channel.send('I am here');
});
I get "Wrong channel!". I should just insert the channel ID number, right? I've directly pasted from Discord's "Copy ID" and still get a problem.
Edit:
I updated my intents and my code. It now shows:
client.on('ready', message => {
client.channels.cache.get('channel-id').send('message.')
This resolved my issues.
if you're using v12 this must be work for your error.
client.on("message", function(message) {
const Channel = message.channel.id == <My.General.Channel.ID#>;
if (!Channel) return console.log('Wrong channel!');
else message.channel.send('I am here');
});