首页 > 解决方案 > 运行不和谐机器人后我无法输入终端

问题描述

问:我该怎么办?

这也发生在命令提示符下。我使用 Visual Studio 代码,机器人是用 javascript 编写的。

我目前正在 youtube 上关注本教程,而且我对 javascript 真的很陌生。 https://www.youtube.com/playlist?list=PLbbLC0BLaGjpyzN1rg-gK4dUqbn8eJQq4

主.js:


const client = new Discord.Client();

const prefix = '+';

const fs = require('fs');

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command);
}

client.once('ready', () => {
    console.log('Lama is online!');
});

client.on('message', message =>{
    if(!message.content.startsWith(prefix) || message.author.bot) return;

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

    if(command === 'kick'){
        client.commands.get('kick').execute(message, args);
    } else if(command === 'youtube'){
        client.commands.get('youtube').execute(message, args);
    }
});

client.login('token here');

我总是用“node”启动机器人。发不了图,不好意思。
并且在控制台发送“喇嘛在线!”之后 我不能在那里打字。

标签: javascriptterminaldiscord

解决方案


推荐阅读