简体   繁体   中英

discord.js error: Cannot read properties of undefined (reading 'client')

i have a problem with discord bot. I just triing to get it working, but i cannot figure out where this error is.

const {discord,  Intents} = require('discord.js');
const client = new discord.client();

client.on('ready', () => {
     console.log(client.user.tag);
});

client.login("token");

This is my entire code without package.json

Error message looks like this: Cannot read properties of undefined (reading 'client')

Thanks for help.

Methods you are using seem to be deprecated on Discord.js v13 and posterior.

You could instead use:

const { Client } = require('discord.js');

const client = new Client({ intents: 32767 });

client.on('ready', () => {
     console.log('We are up!');
});

client.login(process.env.SUPER_SECRET_TOKEN);

If you need help moving your entire codebase to Discord.js v13 or v14, you can always check the docs and the official guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM