prefix command not working

I tried to add the commands in separate files, but it did not turn out to be comfortable for me, it also did not work, so I wanted to add them in the same index, it turns out that it does not work either, I chose to add a console.log to see if the client.on ('messageCreate') was executed correctly, someone help me?
const { Client, Collection, GatewayIntentBits, Partials, SlashCommandBuilder } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });

client.config = require('./config.json');

client.once('ready', async () => {
await client.user.setPresence({
activities: [{
name: 'game',
ActivityType: 'PLAYING'
}],
status: 'online'
});

console.log('Ready bot');

//commands Slash and register commands slash
});

client.on('interactionCreate', async (interaction) => {
const { commandName, options } = interaction;

// comands slash
});

const prefix = '!';

client.on('message', message =>{
//commands prefix
});
const { Client, Collection, GatewayIntentBits, Partials, SlashCommandBuilder } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });

client.config = require('./config.json');

client.once('ready', async () => {
await client.user.setPresence({
activities: [{
name: 'game',
ActivityType: 'PLAYING'
}],
status: 'online'
});

console.log('Ready bot');

//commands Slash and register commands slash
});

client.on('interactionCreate', async (interaction) => {
const { commandName, options } = interaction;

// comands slash
});

const prefix = '!';

client.on('message', message =>{
//commands prefix
});
13 Replies
d.js toolkit
d.js toolkit2y 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/luna2y ago
its messageCreate and you need the GuildMessages and MessageContent intent
Syjalo
Syjalo2y ago
You also need GuildMessage and MessageContent intents
treble/luna
treble/luna2y ago
and activity is set with the ActivityType enum, and iirc type property
HeartSpirit
HeartSpiritOP2y ago
the activity is fine
treble/luna
treble/luna2y ago
not really
d.js docs
d.js docs2y ago
method ClientUser#setActivity() Sets the activity the client user is playing.
HeartSpirit
HeartSpiritOP2y ago
How do I add that?
treble/luna
treble/luna2y ago
add them in your client cosntructor and enable them in the dev portal
HeartSpirit
HeartSpiritOP2y ago
like this?:
const client = new Client({ intents: [GatewayIntentBits.Guilds, GuildMessage, MessageContent], partials: [Partials.Channel] });
const client = new Client({ intents: [GatewayIntentBits.Guilds, GuildMessage, MessageContent], partials: [Partials.Channel] });
treble/luna
treble/luna2y ago
no, do it the same way you did for guilds this is basic js at this point
HeartSpirit
HeartSpiritOP2y ago
the code is exactly like this, how do I add? or where it is added?
treble/luna
treble/luna2y ago
GatewayIntentBits.<intent>
Want results from more Discord servers?
Add your server