The bot has started, but does not respond to the standard command (!ping)

I installed all the required resources, node.js, discord.js library, latest versions. The bot has enabled intents on the Discord Developers website. The bot is turned on, it is online, but does not respond to the only ping command. Code:
const { Client, IntentsBitField } = require('discord.js');
const myIntents = new IntentsBitField();
myIntents.add(IntentsBitField.Flags.GuildPresences, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.MessageContent);
const client = new Client({ intents: myIntents });

client.on('ready', () => {
console.log(Запустился как ${client.user.tag}!);
});

client.on('message', msg => {
if (msg.content === '!ping') {
msg.reply('Pong');
}
});

client.login('token');
const { Client, IntentsBitField } = require('discord.js');
const myIntents = new IntentsBitField();
myIntents.add(IntentsBitField.Flags.GuildPresences, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.MessageContent);
const client = new Client({ intents: myIntents });

client.on('ready', () => {
console.log(Запустился как ${client.user.tag}!);
});

client.on('message', msg => {
if (msg.content === '!ping') {
msg.reply('Pong');
}
});

client.login('token');
The token is valid. Help me please
8 Replies
d.js toolkit
d.js toolkit11mo 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!
d.js docs
d.js docs11mo ago
Suggestion for @ost: :guide: Popular Topics: Gateway Intents - Enabling Intents read more
Toast
Toast11mo ago
Your "message" event is invalid, should be messageCreate, did you ask AI to make it for you?
ost
ostOP11mo ago
Oh, thank you! I was stupid. However, the bot is still not responding. @mallusrgreat I have already read this information
duck
duck11mo ago
then did you take note of the first bullet point where it mentions what intents you'll need for the messageCreate event?
ost
ostOP11mo ago
If you need your bot to receive messages (MESSAGE_CREATE - "messageCreate" in discord.js), you need the Guilds and GuildMessages intent, plus the MessageContent privileged intent to receive the content, attachments, embeds and components fields of the message.
IntentsBitField.Flags.Guilds ? I changed the code snippet this way, but the result hasn't changed: myIntents.add(IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildPresences, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.MessageContent);
mallusrgreat
mallusrgreat11mo ago
If you need your bot to receive messages (MESSAGE_CREATE - "messageCreate" in discord.js), you need the Guilds and GuildMessages intent, plus the MessageContent privileged intent to receive the content, attachments, embeds and components fields of the message.
ost
ostOP11mo ago
Thank you very much!!! :dogeHaHa:
Want results from more Discord servers?
Add your server