无法读取属性';设置';未定义的| JavaScript | Discord.js v12

无法读取属性';设置';未定义的| JavaScript | Discord.js v12,javascript,discord.js,Javascript,Discord.js,我目前正在为我的机器人做一些命令处理,我遇到了这个错误,我似乎无法理解它为什么会发生 以下是错误: (node:10136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'set' of undefined at Object.execute (D:\Chest\Projects\Discord\terminalv2\commands\music\execute.js:36:28) at runMicrota

我目前正在为我的机器人做一些命令处理,我遇到了这个错误,我似乎无法理解它为什么会发生

以下是错误:

(node:10136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'set' of undefined
at Object.execute (D:\Chest\Projects\Discord\terminalv2\commands\music\execute.js:36:28)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

这个错误意味着
外部.queue
未定义的
我完全理解它的意思,我不理解它定义时为什么会发生。你怎么知道
外部.queue
是在代码中的那个点定义的?你试过记录
外部.queue
吗?我刚刚做了,它返回未定义的。我从
const external=require('./../../externalCommands')获取外部命令和队列来自
const queue=new Map();exports.queue=队列在我的外部命令模块中
const external = require('./../../externalCommands');
const ytdl = require("ytdl-core");

module.exports = {
name: 'play',
aliases: ['p'],

async execute(message) {
    const args = message.content.split(" ");
    const voiceChannel = message.member.voice.channel;

    if (!voiceChannel) {
        return message.channel.send("You need to be in a voice channel to play music! *bap*");
    }

    if (!args[1]) {
        return message.channel.send("You need to specify a youtube link! *bap*");
    }

    const songInfo = await ytdl.getInfo(args[1]);
    const song = {
        title: songInfo.videoDetails.title,
        url: songInfo.videoDetails.video_url,
    };

    if (!external.serverQueue) {
        const queueContruct = {
            textChannel: message.channel,
            voiceChannel: voiceChannel,
            connection: null,
            songs: [],
            volume: 25,
            playing: true,
        };

        external.queue.set(message.guild.id, queueContruct);
        queueContruct.songs.push(song);
        
        var connection = await voiceChannel.join();
        queueContruct.connection = connection;
        external.play(message.guild, queueContruct.songs[0]);
    } else {
        external.serverQueue.songs.push(song);
        return message.channel.send(`I added **${song.title}** to the queue UwU`);
    }
},
};