я пишу несколько служебных / musi c ботов для сервера Discord, но примерно на полпути песни он перестает играть, и в терминале написано (пожалуйста, не обращайте внимания на плохой код, я новый, сделайте это, но я очень энтузиазм c)
Error: input stream: Status code: 416
at ClientRequest.<anonymous> (C:\Users\Owner\Desktop\Comrade Nicolai\node_modules\miniget\dist\index.js:156:27)
at Object.onceWrapper (events.js:417:26)
at ClientRequest.emit (events.js:310:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:476:22)
at TLSSocket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at TLSSocket.Readable.push (_stream_readable.js:209:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)
кто-нибудь знает, как я могу это исправить?
вот мой код, если он помогает:
//the constants that make the whole thing work//
const Discord = require('discord.js');
const RichEmbed = require('discord.js');
const bot = new Discord.Client();
const bot2 = new Discord.Client();
const token = '';
const token2 = '';
const PREFIX = '!';
const PREFIX2 = '.';
const cheerio = require('cheerio');
const request = require('request');
const fs = require('fs');
const ms = require('ms');
const nbx = require('noblox.js');
const ytdl = require("ytdl-core");
const queue = new Map();
//command files manager//
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
// ready messages//
bot.on('ready', () =>{
console.log('Nicolai reporting for duty');
})
bot2.on('ready', () =>{
console.log('Mr Syldavia are you secure');
})
//comrade nicolai commands//
//prefix checker//
bot.on('message', message=>{
if(!message.content.startsWith(PREFIX)) return;
const serverQueue = queue.get(message.guild.id);
let args = message.content.substring(PREFIX.length).split(" ");
//commands//
switch(args[0]){
case "ping":
bot.commands.get('ping').execute(message, args);
break;
case "play":
execute(message, serverQueue);
break;
case "skip":
skip(message, serverQueue);
break;
case "stop":
stop(message, serverQueue);
break;
//help command//
case 'cmds':
bot.commands.get('im not sure yet').execute(message, args);
break;
case 'help':
bot.commands.get('help').execute(message, args);
break;
}
})
//mr syldavia commands//
//prefix checker//
bot2.on('message', message=>{
if(!message.content.startsWith(PREFIX2)) return;
let args = message.content.substring(PREFIX2.length).split(" ");
//commands//
switch(args[0]){
case "ping":
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do not have permission to do that!')
bot.commands.get('ping').execute(message, args);
break;
//help command//
case 'cmds':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
bot.commands.get('im not sure yet').execute(message, args);
break;
case 'help':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
bot.commands.get('help').execute(message, args);
break;
//create poll command//
case 'poll':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
bot.commands.get('poll command').execute(message, args);
break;
// create announcement command//
case 'announcement':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
bot.commands.get('poll').execute(message, args);
break;
case 'iannouncement':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
bot.commands.get('iannouncement').execute(message, args);
break;
case 'clear':
if (!message.member.roles.cache.find(r => r.name === "Moderator")) return
message.channel.send('You do do
not have permission to do that!')
let msgArgs = args.slice(1).join(" ");
message.channel.bulkDelete(msgArgs)
.then(messages => message.channel.send(`Bulk deleted ${messages.size} messages`))
.then(msg => msg.delete({timeout: 1000}));
break;
}
})
async function execute(message, serverQueue) {
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!"
);
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has("CONNECT") || !permissions.has("SPEAK")) {
}
const songInfo = await ytdl.getInfo(args[1]);
const song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url
};
if (!serverQueue) {
const queueContruct = {
textChannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(message.guild.id, queueContruct);
queueContruct.songs.push(song);
try {
var connection = await voiceChannel.join();
queueContruct.connection = connection;
play(message.guild, queueContruct.songs[0]);
} catch (err) {
console.log(err);
queue.delete(message.guild.id);
return message.channel.send(err);
}
} else {
serverQueue.songs.push(song);
return message.channel.send(`${song.title} has been added to the queue!`);
}
}
function skip(message, serverQueue) {
if (!message.member.voice.channel)
return message.channel.send(
"You have to be in a voice channel to stop the music!"
);
if (!serverQueue)
return message.channel.send("There is no song that I could skip!");
serverQueue.connection.dispatcher.finish();
}
function stop(message, serverQueue) {
if (!message.member.voice.channel)
return message.channel.send(
"You have to be in a voice channel to stop the music!"
);
serverQueue.songs = [];
serverQueue.connection.dispatcher.end();
}
function play(guild, song) {
const serverQueue = queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.play(ytdl(song.url))
.on("finish", () => {
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
.on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
serverQueue.textChannel.send(`Start playing: **${song.title}**`);
}
//idk the point of this i just know i need it//
bot2.login(token2);
bot.login(token);