"yt-dl"라이브러리를 사용하여 Discord에서 YouTube 오디오를 재생할 수있는 방법을 알아 냈습니다.노래 큐 만들기 Discord.js
나는 노래를 연주하는 데 필요한 모든 명령을 만들었습니다. 재생, 일시 중지, 정지 (노래 끝내기).
사용자가 제공 한 URL에서 노래를 재생하는 등의 간단한 명령을했습니다. 어떻게 대기열을 만들 수 있습니까? 그런 다음 현재 노래가 끝나면 대기열에서 다음 노래를 재생하게 만드시겠습니까?
"yt-dl"라이브러리를 사용하여 Discord에서 YouTube 오디오를 재생할 수있는 방법을 알아 냈습니다.노래 큐 만들기 Discord.js
나는 노래를 연주하는 데 필요한 모든 명령을 만들었습니다. 재생, 일시 중지, 정지 (노래 끝내기).
사용자가 제공 한 URL에서 노래를 재생하는 등의 간단한 명령을했습니다. 어떻게 대기열을 만들 수 있습니까? 그런 다음 현재 노래가 끝나면 대기열에서 다음 노래를 재생하게 만드시겠습니까?
var servers = {}; //obj
var id = "HgzGwKwLmgM" //"something"
//need provide id^
//example if with array <inside play function>
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: [],
videodescription: [],
videolengh: [],
videotitle: [],
videothumbnailUrl: [],
videourl: []
};
server = servers[message.guild.id]; //method
//fetchVideoInfo is part of nmp [email protected]
//npm install youtube-info --save
server.queue.push(id);
fetchVideoInfo(id, function (err, videoInfo) {
if (err) throw new Error(err);
message.reply(' The song: **' + videoInfo.title + "** has been added to the queue list.");
server.videolengh.push(videoInfo.duration);//integer
server.videothumbnailUrl.push(videoInfo.thumbnailUrl);
server.videourl.push(videoInfo.url);
server.videotitle.push(videoInfo.title);
server.videodescription.push(videoInfo.description);
//(videoInfo.description in fetchVideoInfo) returning html
});
// |
//later you can call components V like but i will require method
console.log(server.queue[0] + "\n");
//or
console.log(server.videodescription[0]);
//also don't forget to "skip"
//example server.queue.shift();
좋습니다. 하지만 질문이 있습니다. 매번 목록에 항목을 추가하는 방법은 무엇입니까? – Norby
배열의 경우'Array.push ()'메소드는 list의 경우'list.add ()'(또는 메소드의 파스칼 케이스)가됩니다. –
WQYeo
도움을 주셔서 감사합니다! – Norby