У меня полная ошибка:
(node:9352) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'push' of undefined
at Object.exports.run (C:\users\Cocoloco2005\Desktop\peterbot\commands\play.js:24:16)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:9352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9352) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Эта проблема произошла с моим созданием моего диска-диска с Discord.js в команде play
(полная команда здесь:
const ytdl = require('ytdl-core');
exports.run = async (client, message, args, ops) => {
if (!message.member.voiceChannel) return message.channel.send('Connectes toi à un salon vocal');
if (!args[0]) return message.channel.send('Entres une URL');
let validate = await ytdl.validateURL(args[0]);
if (!validate) {
let commandFile = require('./search.js');
return commandFile.run(client, message, args, ops);
}
let info = await ytdl.getInfo(args[0]);
let data = ops.active = (message.guild.id) || {};
if (!data.connection) data.connection = await message.member.voiceChannel.join();
if(!data.queue) data.queue = [];
data.guildID = message.guild.id;
data.queue.push[0]({
songTitle: info.title,
requester: message.author.tag,
url: args[0],
announceChannel: message.channel.id
});
if (!data.dispatcher) play(client, ops, data);
else {
message.channel.send(`Added to queue: ${info.title} | requested by: ${message.author.id}`)
}
ops.active.set(message.guild.id, data);
}
async function play(client, ops, data) {
client.channels.get(data.queue[0].announceChannel).send(`Now Playing: ${data.queue[0].songTitle} | Requested by: ${data.queue[0].requester}`);
data.dispatcher = await data.connection.playStream(ytdl(data.queue[0].url, {filter: 'audioonly'}));
data.dispatcher.guildID = data.guildID;
data.dispatcher.once('end', function() {
end(client, ops, this);
});
}
function end(client, ops, dispatcher){
let fetched = ops.active.get(dispatcher.guildID);
fetched.queue.shift();
if (fetched.queue.length > 0) {
ops.active.set(dispatcher.guildID, fetched);
play(client, ops, fetched);
} else {
ops.active.delete(dispatcher.guildID);
let vc = client.guilds.get(dispatcher.guildID).me.voiceChannel;
if (vc) vc.leave();
}
}
Я не знаю, что делать, я не пробовал ничего «особенного», потому что я новичок в Javascript.Я пытался искать, но я ничего не нашел о людях с моей ошибкой.