我目前正在为我的机器人做一些命令处理,但我遇到了这个错误,我似乎不明白为什么会发生
这里是错误:
(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)
有问题的行是 36,但它是定义的。我不知道该怎么办。
这是我的代码:
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`);
}
},
};