music: add queue removal
This commit is contained in:
		
							parent
							
								
									306ad496fa
								
							
						
					
					
						commit
						902b3f77f9
					
				
					 1 changed files with 53 additions and 6 deletions
				
			
		| 
						 | 
					@ -308,7 +308,7 @@ async function enqueue(
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await connection.play(media, {inlineVolume: true, voiceDataTimeout: -1});
 | 
					    await connection.play(media, {voiceDataTimeout: -1});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    textChannel.createMessage({
 | 
					    textChannel.createMessage({
 | 
				
			||||||
      embeds: [
 | 
					      embeds: [
 | 
				
			||||||
| 
						 | 
					@ -398,8 +398,8 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
    case "p":
 | 
					    case "p":
 | 
				
			||||||
      if (msg.member?.voiceState?.channelID) {
 | 
					      if (msg.member?.voiceState?.channelID) {
 | 
				
			||||||
        if (voiceStorage.has(msg.guildID)) {
 | 
					        if (voiceStorage.has(msg.guildID)) {
 | 
				
			||||||
          const conn = voiceStorage.get(msg.guildID);
 | 
					          const connection = voiceStorage.get(msg.guildID);
 | 
				
			||||||
          if (conn.channelID != msg.member.voiceState.channelID) {
 | 
					          if (connection.channelID != msg.member.voiceState.channelID) {
 | 
				
			||||||
            return "You are in a different voice channel than the bot.";
 | 
					            return "You are in a different voice channel than the bot.";
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -520,7 +520,7 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          const url = await youtubeSearch(msg, argStr);
 | 
					          const url = await youtubeSearch(msg, argStr);
 | 
				
			||||||
          if (url != "Canceled" && url != "Request timed out") {
 | 
					          if (url.startsWith("https://youtu.be/")) {
 | 
				
			||||||
            await enqueue(
 | 
					            await enqueue(
 | 
				
			||||||
              msg.guildID,
 | 
					              msg.guildID,
 | 
				
			||||||
              msg.member.voiceState.channelID,
 | 
					              msg.member.voiceState.channelID,
 | 
				
			||||||
| 
						 | 
					@ -653,17 +653,64 @@ command.callback = async function (msg, line) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return {
 | 
					      return {
 | 
				
			||||||
        embed: {
 | 
					        embed: {
 | 
				
			||||||
          title: "Currently Queued",
 | 
					          title: ":inbox_tray: Currently Queued",
 | 
				
			||||||
          color: 0x0088cc,
 | 
					          color: 0x0088cc,
 | 
				
			||||||
          fields,
 | 
					          fields,
 | 
				
			||||||
          footer: {
 | 
					          footer: {
 | 
				
			||||||
            text: queue.length > 9 ? `Showing 9/${queue.length}` : "",
 | 
					            text: queue.length > 9 ? `Showing 9/${queue.length} items` : "",
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case "remove":
 | 
					    case "remove":
 | 
				
			||||||
    case "qr":
 | 
					    case "qr":
 | 
				
			||||||
 | 
					      if (msg.member?.voiceState?.channelID) {
 | 
				
			||||||
 | 
					        const connection = voiceStorage.get(msg.guildID);
 | 
				
			||||||
 | 
					        if (voiceStorage.has(msg.guildID)) {
 | 
				
			||||||
 | 
					          if (connection.channelID != msg.member.voiceState.channelID) {
 | 
				
			||||||
 | 
					            return "You are in a different voice channel than the bot.";
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let queue = connection._music_queue;
 | 
				
			||||||
 | 
					        if (queue.length === 0) return "Nothing else is currently queued";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const hasManageMessages = msg.member.permissions.has("manageMessages");
 | 
				
			||||||
 | 
					        if (!hasManageMessages)
 | 
				
			||||||
 | 
					          queue = queue.filter((item) => item.addedBy == msg.member.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (queue.length === 0) return "You currently have nothing queued";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const toRemove = await selectionMessage(
 | 
				
			||||||
 | 
					          msg,
 | 
				
			||||||
 | 
					          "Choose items to remove",
 | 
				
			||||||
 | 
					          queue.slice(0, 25).map((item) => {
 | 
				
			||||||
 | 
					            const user = hf.bot.users.get(item.addedBy);
 | 
				
			||||||
 | 
					            return {
 | 
				
			||||||
 | 
					              key: item.url,
 | 
				
			||||||
 | 
					              display: (item.title ?? item.url).substr(0, 100),
 | 
				
			||||||
 | 
					              description:
 | 
				
			||||||
 | 
					                hasManageMessages &&
 | 
				
			||||||
 | 
					                `Added by: ${user.username}#${user.discriminator}`,
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					          }),
 | 
				
			||||||
 | 
					          30000,
 | 
				
			||||||
 | 
					          25
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (Array.isArray(toRemove)) {
 | 
				
			||||||
 | 
					          for (const removedItem of toRemove) {
 | 
				
			||||||
 | 
					            connection._music_queue = connection._music_queue.filter(
 | 
				
			||||||
 | 
					              (item) => item.url !== removedItem
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          return `Removed ${toRemove.length} item(s).`;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          return toRemove;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        return "You are not in a voice channel";
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    case "lock":
 | 
					    case "lock":
 | 
				
			||||||
    case "unlock":
 | 
					    case "unlock":
 | 
				
			||||||
      return "TODO";
 | 
					      return "TODO";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue