Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我会听到一个错误,说;TypeError:无法读取属性';执行';“未定义”的定义;_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 为什么我会听到一个错误,说;TypeError:无法读取属性';执行';“未定义”的定义;

Javascript 为什么我会听到一个错误,说;TypeError:无法读取属性';执行';“未定义”的定义;,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我的问题是,在我的代码中,我有许多不同的client.commands.get('help').execute(消息、参数、版本、前缀)但在本例中(第43行),我得到一个错误。这是我的密码 const client = new Discord.Client(); const token = "Njg5MTcyMzc4NTcxMzc0NzE3.Xm_APA.EcT6EZS5OnhzLA3fUbddsfI63Xw"; const PREFIX = ";"; const version = 'Alph

我的问题是,在我的代码中,我有许多不同的
client.commands.get('help').execute(消息、参数、版本、前缀)但在本例中(第43行),我得到一个错误。这是我的密码

const client = new Discord.Client();
const token = "Njg5MTcyMzc4NTcxMzc0NzE3.Xm_APA.EcT6EZS5OnhzLA3fUbddsfI63Xw";
const PREFIX = ";";
const version = 'Alpha 1.0.1'

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.on('ready', () => {
    console.log("Ready!");
});

client.on('message', message => {
    let args = message.content.substring(PREFIX.length).split(" ");

    switch (args[0]) {
        case 'test':
            client.commands.get('test').execute(message, args, version);
            break;
        case 'help':
            client.commands.get('help').execute(message, args, version, PREFIX);
            break;
        case 'version':
            message.channel.send('Version: ' + version)
            break;
        case 'convoy':
            if (args[1] = 'sim1') {
                var server = 'Simulation 1 in ETS2'
            } else if (args[1] = 'promods') {
                var server = 'ProMods 1 in ETS2'
            } else if (args[1] = 'us') {
                var server = '[US] Simulation in ATS'
            }
            client.commands.get('convoy').execute(message, args, server);
            break;

        }
});

client.login(token);```

转到浏览器控制台中的控制台错误输出,并在调试程序中找到该行。我这样做了,我得到一个错误,错误是
TypeError:Discord.RichEmbed不是构造函数
@JackKoskie您泄漏了您的令牌!这意味着任何查看此问题的人都可以从任何计算机上获取此代码并控制您的机器人!请转到,选择您的机器人,单击左侧的“机器人”选项卡,然后单击令牌下的“重新生成”按钮重置您的令牌。确保像对待令牌一样对待令牌:用户名和密码的组合,一个允许完全不受限制地访问bot的字符串。除了您之外,任何人都不应该在任何上下文中访问它。
RichEmbed
在Discord.js版本12中被
MessageEmbed
取代。这可能是你的问题。更改为
MessageEmbed
进行升级,或运行
npm install discord。js@11.6.2
。有人说,去重置你的令牌。以后不要再发布了。谢谢你的帮助=)