Reputation: 1
I have a Discord Bot, it turns on, but it doesn't answer to commands. Here's my code
const Discord = require("discord.js");
const client = new Discord.Client( {intents: 32767}, );
{
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'USER', 'GUILD_MEMBER']
}
client.on('ready', () => {
console.log('Estoy ON')
client.user.setActivity('Ark Survival Evolved', { type: "PLAYING"});
});
client.once('message', (message) => {
if(message.content.startsWith('ping')) {
message.channel.send(`pong 🏓!!`);
}
});
client.login('MY TOKEN');
I need help. I tried to do everything, but it doesn't work. I'm in the latest version of node.js and in the latest version in discord.js I have tried in 5 versions, but I can't do anything.
I tried to use a prefix, without prefix... But it dont works. I have tried 3 codes and nothing.
Upvotes: 0
Views: 142
Reputation: 320
This is quite obviously because you're using the magical "all" intents code. Consider replacing it with the proper intents instead of using 32767
. The use above is also correct as the message
event is deprecated and no longer logs any errors.
And as for whatever reason the partials is completely out of the Discord.Client
options, I do not know.
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.MessageContent
],
partials: [
Discord.Partials.User,
Discord.Partials.Message
Discord.Partials.Channel
Discord.Partials.Reaction
Discord.Partials.GuildMember
]
});
client.on('ready', () => {
console.log('Estoy ON');
client.user.setActivity('Ark Survival Evolved', { type: "PLAYING"});
});
client.once('messageCreate', (message) => {
if(message.content.startsWith('ping')) {
message.channel.send(`pong 🏓!!`);
}
});
client.login('token');
I've changed message
to messageCreate
and rearranged the intents and partials into the new discord.js@v14 versions and changed the "magical intents" to a proper intent array.
Also please ensure that you have the message privileged intents enabled in the developer portal
Upvotes: 2
Reputation: 604
This worked for me
client.on('messageCreate', message => {
if(message.content.startsWith('ping')) {
message.channel.send(`pong 🏓!!`);
}
});
Upvotes: 0