Some tweaks to music player commands, added loop, renamed existing loop command to unfreeze
This commit is contained in:
		
							parent
							
								
									df5ed094a8
								
							
						
					
					
						commit
						0566dca06d
					
				
					 9 changed files with 88 additions and 57 deletions
				
			
		| 
						 | 
					@ -1,22 +1,10 @@
 | 
				
			||||||
const magick = require("../utils/image.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  return await soundPlayer.loop(message);
 | 
				
			||||||
  const image = await require("../utils/imagedetect.js")(message);
 | 
					 | 
				
			||||||
  if (image === undefined) return `${message.author.mention}, you need to provide a GIF to loop!`;
 | 
					 | 
				
			||||||
  const { buffer, type } = await magick.run({
 | 
					 | 
				
			||||||
    cmd: "freeze",
 | 
					 | 
				
			||||||
    path: image.path,
 | 
					 | 
				
			||||||
    loop: true,
 | 
					 | 
				
			||||||
    onlyGIF: true
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
 | 
					 | 
				
			||||||
  return {
 | 
					 | 
				
			||||||
    file: buffer,
 | 
					 | 
				
			||||||
    name: `loop.${type}`
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["unfreeze"];
 | 
					exports.aliases = ["toggleloop", "repeat"];
 | 
				
			||||||
exports.category = 5;
 | 
					exports.category = 7;
 | 
				
			||||||
exports.help = "Makes a GIF loop endlessly";
 | 
					exports.help = "Loops the music";
 | 
				
			||||||
 | 
					exports.requires = "sound";
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
const soundPlayer = require("../utils/soundplayer.js");
 | 
					const soundPlayer = require("../utils/soundplayer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  await soundPlayer.playing(message);
 | 
					  return 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) => {
 | 
				
			||||||
  await soundPlayer.pause(message);
 | 
					  return await soundPlayer.pause(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["resume"];
 | 
					exports.aliases = ["resume"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ 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!`;
 | 
				
			||||||
  const query = args.join(" ").trim();
 | 
					  const query = args.join(" ").trim();
 | 
				
			||||||
  const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
 | 
					  const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
 | 
				
			||||||
  await soundPlayer.play(encodeURIComponent(search), message, true);
 | 
					  return 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) => {
 | 
				
			||||||
  await soundPlayer.queue(message);
 | 
					  return 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) => {
 | 
				
			||||||
  await soundPlayer.skip(message);
 | 
					  return 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) => {
 | 
				
			||||||
  await soundPlayer.stop(message);
 | 
					  return await soundPlayer.stop(message);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.aliases = ["disconnect"];
 | 
					exports.aliases = ["disconnect"];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								commands/unfreeze.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								commands/unfreeze.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					const magick = require("../utils/image.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.run = async (message) => {
 | 
				
			||||||
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
 | 
					  const image = await require("../utils/imagedetect.js")(message);
 | 
				
			||||||
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide a GIF to unfreeze!`;
 | 
				
			||||||
 | 
					  const { buffer, type } = await magick.run({
 | 
				
			||||||
 | 
					    cmd: "freeze",
 | 
				
			||||||
 | 
					    path: image.path,
 | 
				
			||||||
 | 
					    loop: true,
 | 
				
			||||||
 | 
					    onlyGIF: true
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					  if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
 | 
				
			||||||
 | 
					  return {
 | 
				
			||||||
 | 
					    file: buffer,
 | 
				
			||||||
 | 
					    name: `unfreeze.${type}`
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.category = 5;
 | 
				
			||||||
 | 
					exports.help = "Unfreezes a GIF";
 | 
				
			||||||
| 
						 | 
					@ -47,22 +47,22 @@ exports.connect = async () => {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.play = async (sound, message, music = false) => {
 | 
					exports.play = async (sound, message, music = false) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I can't join this voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return `${message.author.mention}, I can't join this voice channel!`;
 | 
				
			||||||
  const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
 | 
					  const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
 | 
				
			||||||
  if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I don't have permission to join this voice channel!`);
 | 
					  if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return `${message.author.mention}, I don't have permission to join this voice channel!`;
 | 
				
			||||||
  const player = this.players.get(message.channel.guild.id);
 | 
					  const player = this.players.get(message.channel.guild.id);
 | 
				
			||||||
  if (!music && this.manager.voiceStates.has(message.channel.guild.id) && (player && player.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) && (player && player.type === "music")) return `${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 = this.queues.get(voiceChannel.guild.id);
 | 
					  const oldQueue = this.queues.get(voiceChannel.guild.id);
 | 
				
			||||||
  if (tracks.length === 0) return client.createMessage(message.channel.id, `${message.author.mention}, I couldn't find that song!`);
 | 
					  if (tracks.length === 0) return `${message.author.mention}, I couldn't find that song!`;
 | 
				
			||||||
  if (music) {
 | 
					  if (music) {
 | 
				
			||||||
    this.queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]); 
 | 
					    this.queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]); 
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  let connection;
 | 
					  let connection;
 | 
				
			||||||
  if (player) {
 | 
					  if (player) {
 | 
				
			||||||
    connection = player;
 | 
					    connection = player.player;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    connection = await this.manager.join({
 | 
					    connection = await this.manager.join({
 | 
				
			||||||
      guild: voiceChannel.guild.id,
 | 
					      guild: voiceChannel.guild.id,
 | 
				
			||||||
| 
						 | 
					@ -72,13 +72,14 @@ exports.play = async (sound, message, music = false) => {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (oldQueue && music) {
 | 
					  if (oldQueue && music) {
 | 
				
			||||||
    client.createMessage(message.channel.id, `${message.author.mention}, your tune has been added to the queue!`);
 | 
					    return `${message.author.mention}, your tune has been added to the queue!`;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    this.nextSong(message, connection, tracks[0].track, tracks[0].info, music, voiceChannel);
 | 
					    this.nextSong(message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false);
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.nextSong = async (message, connection, track, info, music, voiceChannel, inQueue = false) => {
 | 
					exports.nextSong = async (message, connection, track, info, music, voiceChannel, loop = false, inQueue = false) => {
 | 
				
			||||||
  const parts = Math.floor((0 / info.length) * 10);
 | 
					  const parts = Math.floor((0 / info.length) * 10);
 | 
				
			||||||
  const playingMessage = await client.createMessage(message.channel.id, !music ? "🔊 Playing sound..." : {
 | 
					  const playingMessage = await client.createMessage(message.channel.id, !music ? "🔊 Playing sound..." : {
 | 
				
			||||||
    "embed": {
 | 
					    "embed": {
 | 
				
			||||||
| 
						 | 
					@ -106,7 +107,7 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  await connection.play(track);
 | 
					  await connection.play(track);
 | 
				
			||||||
  this.players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel });
 | 
					  this.players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel, loop: loop });
 | 
				
			||||||
  if (inQueue && connection.listeners("error").length === 0) {
 | 
					  if (inQueue && connection.listeners("error").length === 0) {
 | 
				
			||||||
    connection.on("error", (error) => {
 | 
					    connection.on("error", (error) => {
 | 
				
			||||||
      if (playingMessage.channel.messages.get(playingMessage.id)) playingMessage.delete();
 | 
					      if (playingMessage.channel.messages.get(playingMessage.id)) playingMessage.delete();
 | 
				
			||||||
| 
						 | 
					@ -121,7 +122,14 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
 | 
				
			||||||
    connection.on("end", async (data) => {
 | 
					    connection.on("end", async (data) => {
 | 
				
			||||||
      if (data.reason === "REPLACED") return;
 | 
					      if (data.reason === "REPLACED") return;
 | 
				
			||||||
      const queue = this.queues.get(voiceChannel.guild.id);
 | 
					      const queue = this.queues.get(voiceChannel.guild.id);
 | 
				
			||||||
      const newQueue = queue ? queue.slice(1) : [];
 | 
					      const isLooping = this.players.get(voiceChannel.guild.id).loop;
 | 
				
			||||||
 | 
					      let newQueue;
 | 
				
			||||||
 | 
					      if (isLooping) {
 | 
				
			||||||
 | 
					        queue.push(queue.shift());
 | 
				
			||||||
 | 
					        newQueue = queue;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        newQueue = queue ? queue.slice(1) : [];
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      this.queues.set(voiceChannel.guild.id, newQueue);
 | 
					      this.queues.set(voiceChannel.guild.id, newQueue);
 | 
				
			||||||
      if (newQueue.length === 0) {
 | 
					      if (newQueue.length === 0) {
 | 
				
			||||||
        this.manager.leave(voiceChannel.guild.id);
 | 
					        this.manager.leave(voiceChannel.guild.id);
 | 
				
			||||||
| 
						 | 
					@ -132,7 +140,7 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
 | 
				
			||||||
        if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
 | 
					        if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
 | 
				
			||||||
      } 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, true);
 | 
					        this.nextSong(message, connection, newQueue[0], track, music, voiceChannel, isLooping, true);
 | 
				
			||||||
        if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
 | 
					        if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					@ -140,24 +148,24 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.stop = async (message) => {
 | 
					exports.stop = async (message) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
  if (this.players.get(message.channel.guild.id).host !== message.author.id) return client.createMessage(message.channel.id, `${message.author.mention}, only the current voice session host can stop the music!`);
 | 
					  if (this.players.get(message.channel.guild.id).host !== message.author.id) return `${message.author.mention}, only the current voice session host can stop the music!`;
 | 
				
			||||||
  this.manager.leave(message.channel.guild.id);
 | 
					  this.manager.leave(message.channel.guild.id);
 | 
				
			||||||
  const connection = this.players.get(message.channel.guild.id).player;
 | 
					  const connection = this.players.get(message.channel.guild.id).player;
 | 
				
			||||||
  connection.destroy();
 | 
					  connection.destroy();
 | 
				
			||||||
  this.players.delete(message.channel.guild.id);
 | 
					  this.players.delete(message.channel.guild.id);
 | 
				
			||||||
  this.queues.delete(message.channel.guild.id);
 | 
					  this.queues.delete(message.channel.guild.id);
 | 
				
			||||||
  await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
 | 
					  return "🔊 The current voice channel session has ended.";
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.skip = async (message) => {
 | 
					exports.skip = async (message) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
  const player = this.players.get(message.channel.guild.id);
 | 
					  const player = this.players.get(message.channel.guild.id);
 | 
				
			||||||
  if (player.host !== message.author.id) {
 | 
					  if (player.host !== message.author.id) {
 | 
				
			||||||
    const votes = skipVotes.has(message.channel.guild.id) ? skipVotes.get(message.channel.guild.id) : { count: 0, ids: [] };
 | 
					    const votes = skipVotes.has(message.channel.guild.id) ? skipVotes.get(message.channel.guild.id) : { count: 0, ids: [] };
 | 
				
			||||||
    if (votes.ids.includes(message.author.id)) return client.createMessage(message.channel.id, `${message.author.mention}, you've already voted to skip!`);
 | 
					    if (votes.ids.includes(message.author.id)) return `${message.author.mention}, you've already voted to skip!`;
 | 
				
			||||||
    const newObject = {
 | 
					    const newObject = {
 | 
				
			||||||
      count: votes.count + 1,
 | 
					      count: votes.count + 1,
 | 
				
			||||||
      ids: [...votes.ids, message.author.id].filter(item => !!item)
 | 
					      ids: [...votes.ids, message.author.id].filter(item => !!item)
 | 
				
			||||||
| 
						 | 
					@ -166,31 +174,32 @@ exports.skip = async (message) => {
 | 
				
			||||||
      player.player.stop(message.channel.guild.id);
 | 
					      player.player.stop(message.channel.guild.id);
 | 
				
			||||||
      skipVotes.set(message.channel.guild.id, { count: 0, ids: [] });
 | 
					      skipVotes.set(message.channel.guild.id, { count: 0, ids: [] });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      await client.createMessage(message.channel.id, `🔊 Voted to skip song (${votes.count + 1}/3 people have voted).`);
 | 
					 | 
				
			||||||
      skipVotes.set(message.channel.guild.id, newObject);
 | 
					      skipVotes.set(message.channel.guild.id, newObject);
 | 
				
			||||||
 | 
					      return `🔊 Voted to skip song (${votes.count + 1}/3 people have voted).`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    player.player.stop(message.channel.guild.id);
 | 
					    player.player.stop(message.channel.guild.id);
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.pause = async (message) => {
 | 
					exports.pause = async (message) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
  if (this.players.get(message.channel.guild.id).host !== message.author.id) return client.createMessage(message.channel.id, `${message.author.mention}, only the current voice session host can pause/resume the music!`);
 | 
					  if (this.players.get(message.channel.guild.id).host !== message.author.id) return `${message.author.mention}, only the current voice session host can pause/resume the music!`;
 | 
				
			||||||
  const player = this.players.get(message.channel.guild.id).player;
 | 
					  const player = this.players.get(message.channel.guild.id).player;
 | 
				
			||||||
  player.pause(!player.paused ? true : false);
 | 
					  player.pause(!player.paused ? true : false);
 | 
				
			||||||
  await client.createMessage(message.channel.id, `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`);
 | 
					  return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.playing = async (message) => {
 | 
					exports.playing = async (message) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
  const player = this.players.get(message.channel.guild.id).player;
 | 
					  const player = this.players.get(message.channel.guild.id).player;
 | 
				
			||||||
  if (!player) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not playing anything!`);
 | 
					  if (!player) return `${message.author.mention}, I'm not playing anything!`;
 | 
				
			||||||
  const track = await fetch(`http://${player.node.host}:${player.node.port}/decodetrack?track=${encodeURIComponent(player.track)}`, { headers: { Authorization: player.node.password } }).then(res => res.json());
 | 
					  const track = await fetch(`http://${player.node.host}:${player.node.port}/decodetrack?track=${encodeURIComponent(player.track)}`, { headers: { Authorization: player.node.password } }).then(res => res.json());
 | 
				
			||||||
  const parts = Math.floor((player.state.position / track.length) * 10);
 | 
					  const parts = Math.floor((player.state.position / track.length) * 10);
 | 
				
			||||||
  await client.createMessage(message.channel.id, {
 | 
					  return {
 | 
				
			||||||
    "embed": {
 | 
					    "embed": {
 | 
				
			||||||
      "color": 16711680,
 | 
					      "color": 16711680,
 | 
				
			||||||
      "author": {
 | 
					      "author": {
 | 
				
			||||||
| 
						 | 
					@ -214,17 +223,17 @@ exports.playing = async (message) => {
 | 
				
			||||||
        "value": `${moment.duration(player.state.position).format("m:ss", { trim: false })}/${track.isStream ? "∞" : moment.duration(track.length).format("m:ss", { trim: false })}`
 | 
					        "value": `${moment.duration(player.state.position).format("m:ss", { trim: false })}/${track.isStream ? "∞" : moment.duration(track.length).format("m:ss", { trim: false })}`
 | 
				
			||||||
      }]
 | 
					      }]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.queue = async (message) => {
 | 
					exports.queue = async (message) => {
 | 
				
			||||||
  if (!message.member.voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return client.createMessage(message.channel.id, `${message.author.mention}, I'm not in a voice channel!`);
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`;
 | 
					  if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`;
 | 
				
			||||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
 | 
					  if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
 | 
				
			||||||
  const queue = this.queues.get(message.channel.guild.id);
 | 
					  const queue = this.queues.get(message.channel.guild.id);
 | 
				
			||||||
  const player = this.players.get(message.channel.guild.id).player;
 | 
					  const player = this.players.get(message.channel.guild.id);
 | 
				
			||||||
  const tracks = await fetch(`http://${player.node.host}:${player.node.port}/decodetracks`, { method: "POST", body: JSON.stringify(queue), headers: { Authorization: player.node.password, "Content-Type": "application/json" } }).then(res => res.json());
 | 
					  const tracks = await fetch(`http://${player.player.node.host}:${player.player.node.port}/decodetracks`, { method: "POST", body: JSON.stringify(queue), headers: { Authorization: player.player.node.password, "Content-Type": "application/json" } }).then(res => res.json());
 | 
				
			||||||
  const trackList = [];
 | 
					  const trackList = [];
 | 
				
			||||||
  const firstTrack = tracks.shift();
 | 
					  const firstTrack = tracks.shift();
 | 
				
			||||||
  for (const [i, track] of tracks.entries()) {
 | 
					  for (const [i, track] of tracks.entries()) {
 | 
				
			||||||
| 
						 | 
					@ -250,6 +259,9 @@ exports.queue = async (message) => {
 | 
				
			||||||
        "fields": [{
 | 
					        "fields": [{
 | 
				
			||||||
          "name": "🎶 Now Playing",
 | 
					          "name": "🎶 Now Playing",
 | 
				
			||||||
          "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": "🔁 Looping?",
 | 
				
			||||||
 | 
					          "value": player.loop ? "Yes" : "No"
 | 
				
			||||||
        }, {
 | 
					        }, {
 | 
				
			||||||
          "name": "🗒️ Queue",
 | 
					          "name": "🗒️ Queue",
 | 
				
			||||||
          "value": value !== "del" ? value.join("\n") : "There's nothing in the queue!"
 | 
					          "value": value !== "del" ? value.join("\n") : "There's nothing in the queue!"
 | 
				
			||||||
| 
						 | 
					@ -260,3 +272,13 @@ exports.queue = async (message) => {
 | 
				
			||||||
  if (embeds.length === 0) return `${message.author.mention}, there's nothing in the queue!`;
 | 
					  if (embeds.length === 0) return `${message.author.mention}, there's nothing in the queue!`;
 | 
				
			||||||
  return paginator(message, embeds);
 | 
					  return paginator(message, embeds);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.loop = async (message) => {
 | 
				
			||||||
 | 
					  if (!message.member.voiceState.channelID) return `${message.author.mention}, you need to be in a voice channel first!`;
 | 
				
			||||||
 | 
					  if (!message.channel.guild.members.get(client.user.id).voiceState.channelID) return `${message.author.mention}, I'm not in a voice channel!`;
 | 
				
			||||||
 | 
					  if (this.players.get(message.channel.guild.id).host !== message.author.id) return `${message.author.mention}, only the current voice session host can loop the music!`;
 | 
				
			||||||
 | 
					  const object = this.players.get(message.channel.guild.id);
 | 
				
			||||||
 | 
					  object.loop = !object.loop;
 | 
				
			||||||
 | 
					  this.players.set(message.channel.guild.id, object);
 | 
				
			||||||
 | 
					  return object.loop ? "🔊 The player is now looping." : "🔊 The player is no longer looping.";
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue