More music/sound work
This commit is contained in:
		
							parent
							
								
									59c2c230fb
								
							
						
					
					
						commit
						8e5c0aa2ac
					
				
					 17 changed files with 26 additions and 21 deletions
				
			
		| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/boi.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/boi.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["boy", "neutron", "hugh"];
 | 
					exports.aliases = ["boy", "neutron", "hugh"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/boom.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/boom.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["thud", "vine"];
 | 
					exports.aliases = ["thud", "vine"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/bruh.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/bruh.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["bro"];
 | 
					exports.aliases = ["bro"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/explosion.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/explosion.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.category = 6;
 | 
					exports.category = 6;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/ping.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/ping.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["notification", "notif"];
 | 
					exports.aliases = ["notification", "notif"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/fart.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/fart.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["toot"];
 | 
					exports.aliases = ["toot"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/fbi.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/fbi.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["openup"];
 | 
					exports.aliases = ["openup"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/mail.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/mail.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["yougotmail", "youvegotmail", "aol"];
 | 
					exports.aliases = ["yougotmail", "youvegotmail", "aol"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  soundPlayer.playing(message);
 | 
					  await soundPlayer.playing(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["playing", "np"];
 | 
					exports.aliases = ["playing", "np"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/oof.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/oof.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["roblox", "commitdie"];
 | 
					exports.aliases = ["roblox", "commitdie"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  soundPlayer.pause(message);
 | 
					  await soundPlayer.pause(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["resume"];
 | 
					exports.aliases = ["resume"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,12 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					const urlRegex = /(?:\w+:)?\/\/(\S+)/;
 | 
				
			||||||
 | 
					const searchRegex = /^(sc|yt)search:/;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message, args) => {
 | 
					exports.run = async (message, args) => {
 | 
				
			||||||
  if (!args[0]) return `${message.author.mention}, you need to provide what you want to play!`;
 | 
					  if (!args[0]) return `${message.author.mention}, you need to provide what you want to play!`;
 | 
				
			||||||
  soundPlayer.play(encodeURIComponent(args.join(" ").trim()), message, true);
 | 
					  const query = args.join(" ").trim();
 | 
				
			||||||
 | 
					  const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
 | 
				
			||||||
 | 
					  await soundPlayer.play(encodeURIComponent(search), message, true);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["p"];
 | 
					exports.aliases = ["p"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  soundPlayer.queue(message);
 | 
					  await soundPlayer.queue(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["q"];
 | 
					exports.aliases = ["q"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  soundPlayer.skip(message);
 | 
					  await soundPlayer.skip(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.category = 7;
 | 
					exports.category = 7;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  soundPlayer.stop(message);
 | 
					  await soundPlayer.stop(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["disconnect"];
 | 
					exports.aliases = ["disconnect"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  return soundPlayer.play("./assets/audio/winxp.ogg", message);
 | 
					  return await soundPlayer.play("./assets/audio/winxp.ogg", message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["windows", "xp"];
 | 
					exports.aliases = ["windows", "xp"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,14 +51,14 @@ exports.play = async (sound, message, music = false) => {
 | 
				
			||||||
  if (!music && this.manager.voiceStates.has(message.channel.guild.id) && this.players.get(message.channel.guild.id).type === "music") return client.createMessage(message.channel.id, `${message.author.mention}, I can't play a sound effect while playing music!`);
 | 
					  if (!music && this.manager.voiceStates.has(message.channel.guild.id) && this.players.get(message.channel.guild.id).type === "music") return client.createMessage(message.channel.id, `${message.author.mention}, I can't play a sound effect while playing music!`);
 | 
				
			||||||
  const node = this.manager.idealNodes[0];
 | 
					  const node = this.manager.idealNodes[0];
 | 
				
			||||||
  const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
 | 
					  const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
 | 
				
			||||||
 | 
					  const oldQueue = queues.get(voiceChannel.guild.id);
 | 
				
			||||||
 | 
					  if (tracks.length === 0) return client.createMessage(message.channel.id, `${message.author.mention}, I couldn't find that song!`);
 | 
				
			||||||
 | 
					  queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]);
 | 
				
			||||||
  const connection = await this.manager.join({
 | 
					  const connection = await this.manager.join({
 | 
				
			||||||
    guild: voiceChannel.guild.id,
 | 
					    guild: voiceChannel.guild.id,
 | 
				
			||||||
    channel: voiceChannel.id,
 | 
					    channel: voiceChannel.id,
 | 
				
			||||||
    node: node.id
 | 
					    node: node.id
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  const oldQueue = queues.get(voiceChannel.guild.id);
 | 
					 | 
				
			||||||
  console.log(tracks);
 | 
					 | 
				
			||||||
  queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (oldQueue) {
 | 
					  if (oldQueue) {
 | 
				
			||||||
    client.createMessage(message.channel.id, `${message.author.mention}, your tune has been added to the queue!`);
 | 
					    client.createMessage(message.channel.id, `${message.author.mention}, your tune has been added to the queue!`);
 | 
				
			||||||
| 
						 | 
					@ -113,7 +113,7 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel)
 | 
				
			||||||
      this.manager.leave(voiceChannel.guild.id);
 | 
					      this.manager.leave(voiceChannel.guild.id);
 | 
				
			||||||
      this.players.delete(voiceChannel.guild.id);
 | 
					      this.players.delete(voiceChannel.guild.id);
 | 
				
			||||||
      queues.delete(voiceChannel.guild.id);
 | 
					      queues.delete(voiceChannel.guild.id);
 | 
				
			||||||
      await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
 | 
					      if (music) await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const track = await fetch(`http://${connection.node.host}:${connection.node.port}/decodetrack?track=${encodeURIComponent(newQueue[0])}`, { headers: { Authorization: connection.node.password } }).then(res => res.json());
 | 
					      const track = await fetch(`http://${connection.node.host}:${connection.node.port}/decodetrack?track=${encodeURIComponent(newQueue[0])}`, { headers: { Authorization: connection.node.password } }).then(res => res.json());
 | 
				
			||||||
      this.nextSong(message, connection, newQueue[0], track, music, voiceChannel);
 | 
					      this.nextSong(message, connection, newQueue[0], track, music, voiceChannel);
 | 
				
			||||||
| 
						 | 
					@ -209,6 +209,7 @@ exports.queue = async (message) => {
 | 
				
			||||||
  const groups = trackList.map((item, index) => {
 | 
					  const groups = trackList.map((item, index) => {
 | 
				
			||||||
    return index % pageSize === 0 ? trackList.slice(index, index + pageSize) : null;
 | 
					    return index % pageSize === 0 ? trackList.slice(index, index + pageSize) : null;
 | 
				
			||||||
  }).filter(Boolean);
 | 
					  }).filter(Boolean);
 | 
				
			||||||
 | 
					  if (groups.length === 0) groups.push("del");
 | 
				
			||||||
  for (const [i, value] of groups.entries()) {
 | 
					  for (const [i, value] of groups.entries()) {
 | 
				
			||||||
    embeds.push({
 | 
					    embeds.push({
 | 
				
			||||||
      "embed": {
 | 
					      "embed": {
 | 
				
			||||||
| 
						 | 
					@ -225,7 +226,7 @@ exports.queue = async (message) => {
 | 
				
			||||||
          "value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : moment.duration(firstTrack.info.length).format("m:ss", { trim: false })})`
 | 
					          "value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : moment.duration(firstTrack.info.length).format("m:ss", { trim: false })})`
 | 
				
			||||||
        }, {
 | 
					        }, {
 | 
				
			||||||
          "name": "🗒️ Queue",
 | 
					          "name": "🗒️ Queue",
 | 
				
			||||||
          "value": value.join("\n")
 | 
					          "value": value !== "del" ? value.join("\n") : "There's nothing in the queue!"
 | 
				
			||||||
        }]
 | 
					        }]
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue