Just updated, confused about prefix commands

I just updated discord.js, and I don't know how it works now but I skimmed through the guide and only found information on how to make slash commands as far as I can tell. I tried using my old code and it didnt work. Do prefix commands not work anymore?
const Discord = require('discord.js');
const { Client, Events, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const prefix = "!"

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
})

client.on('message', async message => {

if (message.author.bot) return
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase();

if (command === 'test') {
await message.channel.send("test")
}
})

client.login([redacted]);
const Discord = require('discord.js');
const { Client, Events, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const prefix = "!"

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
})

client.on('message', async message => {

if (message.author.bot) return
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase();

if (command === 'test') {
await message.channel.send("test")
}
})

client.login([redacted]);
7 Replies
d.js toolkit
d.js toolkit8mo 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!
Banana
Banana8mo ago
they work, its just updated events its messageCreate
d.js docs
d.js docs8mo ago
If you aren't getting content, embeds or attachments of a message, make sure you have the MessageContent intent enabled in the Developer Portal and provide it to your client:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
duck
duck8mo ago
this as well
kill
killOP8mo ago
its just for my use and what im used to, ill learn slashif i ever make anything good so sorry for the stupid questions but i did update the intents in the code and the events but not sure how to fix it in the developer portal?
duck
duck8mo ago
you can enable privileged intents under the "Privileged Gateway Intents" section of the "Bot" tab of your application
kill
killOP8mo ago
It worked thank you so much for the help! Ive been so confused with all the new stuff
Want results from more Discord servers?
Add your server