2017-09-13 4 views
0

最後に、Discordボットを "yt-dl"というライブラリを使用してYouTubeからオーディオを再生する方法を見つけました。曲の列を作成するDiscord.js

私はその曲を演奏するために必要なすべてのコマンドを作成しました。 再生、一時停止、停止(曲を終了)。

ユーザーから提供されたURLから、曲を再生するなどの簡単なコマンドを演奏しました。キューを作成するにはどうすればいいですか?そして、現在の曲が終わったら、キューの次の曲を再生させますか?

答えて

0

あなたの曲のリストを作成したり、リストを作成する方法をチェックしたりするには、このポストhereをチェックしてください。

を(また、あなたは単にあなたのキューがいかに長く制限したい場合に役立つ可能性がある、配列を使用することができます)(ジャバスクリプト用のリスト機能を作成した人もあり、それは.NETのジェネリックリストのように動作しますあなたはhereをチェックアウトすることができます。

あなたの曲の詳細をあなたのリストの中に保存するオブジェクトを作成することもできます。

+0

大丈夫です。 しかし、私は質問があります。私は毎回リストに何かを追加しましたか?コマンドを実行しますか? – Norby

+0

配列の場合、 'Array.push()'メソッドでは、 'list.add()'(メソッドのパスカルの場合)になります。 – WQYeo

+0

助けてくれてありがとう! – Norby

0
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(); 
関連する問題