I tried to run node index.js in terminal but this error came up: TypeError: Cannot read properties of undefined (reading 'Guilds'). The following is my code:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
if (interaction.commandName === '!help') {
await interaction.reply('I dont want to haelp u');
}
});
client.login('OTQ0NjQyMDQ3MTI0NTgyNTEw.YhEkdg.e2AspV6x5JtTqKkq24DkeMmDlSo');
Maybe there is an issue with the Intent. Since you have not provided the error output, I suggest you to use
const {Client, Intents, Collection} = require('discord.js')
const client = new Client({intents:[Intents.FLAGS.GUILDS,Intents.FLAGS.GUILD_MESSAGES]})
Replace this code with your first two lines of code which is :
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
And please don't share bot Token ever. Its like login Credentials for your bot. Please reset it on your discord developer console.