music.play: add --next
This commit is contained in:
		
							parent
							
								
									3897182797
								
							
						
					
					
						commit
						a29283721d
					
				
					 1 changed files with 23 additions and 5 deletions
				
			
		| 
						 | 
					@ -176,7 +176,8 @@ async function enqueue(
 | 
				
			||||||
  url,
 | 
					  url,
 | 
				
			||||||
  type,
 | 
					  type,
 | 
				
			||||||
  addedBy,
 | 
					  addedBy,
 | 
				
			||||||
  suppress = false
 | 
					  suppress = false,
 | 
				
			||||||
 | 
					  queueNext = false
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
  if (!url) return;
 | 
					  if (!url) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,7 +259,7 @@ async function enqueue(
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (connection.playing) {
 | 
					  if (connection.playing) {
 | 
				
			||||||
    connection._music_queue.push({
 | 
					    const queueItem = {
 | 
				
			||||||
      url,
 | 
					      url,
 | 
				
			||||||
      type,
 | 
					      type,
 | 
				
			||||||
      title,
 | 
					      title,
 | 
				
			||||||
| 
						 | 
					@ -266,12 +267,21 @@ async function enqueue(
 | 
				
			||||||
      addedBy,
 | 
					      addedBy,
 | 
				
			||||||
      stream,
 | 
					      stream,
 | 
				
			||||||
      id: Math.random().toString(16).substring(2),
 | 
					      id: Math.random().toString(16).substring(2),
 | 
				
			||||||
    });
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (queueNext === true) {
 | 
				
			||||||
 | 
					      connection._music_queue.splice(0, 0, queueItem);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      connection._music_queue.push(queueItem);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (suppress === false) {
 | 
					    if (suppress === false) {
 | 
				
			||||||
      textChannel.createMessage({
 | 
					      textChannel.createMessage({
 | 
				
			||||||
        embeds: [
 | 
					        embeds: [
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            title: `<:ms_tick:503341995348066313> Added to queue`,
 | 
					            title: `<:ms_tick:503341995348066313> Added to queue ${
 | 
				
			||||||
 | 
					              queueNext === true ? "(next up)" : ""
 | 
				
			||||||
 | 
					            }`,
 | 
				
			||||||
            color: 0x00cc00,
 | 
					            color: 0x00cc00,
 | 
				
			||||||
            fields: [
 | 
					            fields: [
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
| 
						 | 
					@ -423,6 +433,12 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
          argStr = argStr.replace(/--offset=(\d+)/, "").trim();
 | 
					          argStr = argStr.replace(/--offset=(\d+)/, "").trim();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let queueNext = false;
 | 
				
			||||||
 | 
					        if (argStr.match(/--next/)) {
 | 
				
			||||||
 | 
					          queueNext = true;
 | 
				
			||||||
 | 
					          argStr = argStr.replace(/--next/, "").trim();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let type;
 | 
					        let type;
 | 
				
			||||||
        let playlist = false;
 | 
					        let playlist = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -516,7 +532,9 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
              msg.channel.id,
 | 
					              msg.channel.id,
 | 
				
			||||||
              argStr,
 | 
					              argStr,
 | 
				
			||||||
              type,
 | 
					              type,
 | 
				
			||||||
              msg.author.id
 | 
					              msg.author.id,
 | 
				
			||||||
 | 
					              false,
 | 
				
			||||||
 | 
					              queueNext
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue