简体   繁体   中英

node . when i press run nothing happens (discord.js)

Why isn't it working? I tried reinstall the app and re-install the npm install discord.js and iI'm still facing it ?

When I press node, nothing happens:

当我按下节点时。没发生什么事

index.js

const { Client, Intents } = require('discord.js');
const { token, prefix } = require('./config.json');

const client = new Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
    ]
});

client.on('ready', () => {
    console.log('the bot is ready')
})

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

    if (message.content === prefix + 'hi') {
        message.reply('hello')
    }

})

client.login(token);

config.json

{
    "token": "TOKEN",
    "prefix": "$"
}

That probably is because you havent provided a valid bot token in config.json am I right or did you type TOKEN in the token field to redact it.

This is the only issue I can find as of now

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