Answer the question
In order to leave comments, you need to log in
The music cuts out, about 30 seconds before the end. Where is the mistake?
Hello.
I'm trying to make a musical command for a bot. That is, you write the play command, the bot plays music through itself.
I ran into a problem, the bot leaves the voice channel without finishing the music + -30 seconds, which is too much.
The problem is not with modules.
Here is the whole code:
const Discord = require('discord.js');
const { Client, Collection } = require("discord.js");
const client = new Discord.Client();
const snekfetch = require("snekfetch");
const randomPuppy = require('random-puppy');
const YTDL = require("ytdl-core");
const getYouTubeID = require("get-youtube-id");
const fetchVideoInfo = require("youtube-info");
const servers = require("net");
const search = require("yt-search");
const fs = require("fs");
opusscript = require("opusscript");
module.exports = {
name: "play",
category: "info",
description: "Эта команда позволит Вам-воспроизвести музыку по названию.",
run: async (client, message, args, ops) => {
search(args.join(" "), function (err, res) {
if (!message.member.voiceChannel) {
const voiceerror = new Discord.RichEmbed()
.setAuthor("Error")
.setDescription(`Сначала Вам нужно посетить голосовой канал.`)
.setTimestamp()
.setFooter(`По просьбе ${message.author.tag}`)
.setColor(`#FF8C00`)
message.channel.send(voiceerror)
return;
}
if (err) return message.channel.send("Извините, что-то пошло не так, попробуйте еще раз.");
let videos = res.videos.slice(0, 5);
let resp = "";
for (var i in videos) {
resp += `**[${parseInt(i) + 1}]:** \`${videos[i].title}\`\n`;
}
resp += `\n** Выберите число:\`1-${videos.length}**\``;
message.channel.send(resp);
const filter = m => !isNaN(m.content) && m.content < videos.length + 1 && m.content > 0;
const collector = message.channel.createMessageCollector(filter);
collector.videos = videos;
collector.once('collect', function (m) {
let commandFile = require(`./play.js`);
commandFile.run(client, message, [this.videos[parseInt(m.content) - 1].url], ops);
});
});
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question