最後に、Discordボットを "yt-dl"というライブラリを使用してYouTubeからオーディオを再生する方法を見つけました。曲の列を作成するDiscord.js
私はその曲を演奏するために必要なすべてのコマンドを作成しました。 再生、一時停止、停止(曲を終了)。
ユーザーから提供されたURLから、曲を再生するなどの簡単なコマンドを演奏しました。キューを作成するにはどうすればいいですか?そして、現在の曲が終わったら、キューの次の曲を再生させますか?
最後に、Discordボットを "yt-dl"というライブラリを使用して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.add()'(メソッドのパスカルの場合)になります。 –
WQYeo
助けてくれてありがとう! – Norby