{"_id":"57859d192eca4e0e002b4d5d","project":"57858bff9e80c32200234f4c","category":{"_id":"57858e1b8a711d2000d1252b","version":"57858bff9e80c32200234f4f","project":"57858bff9e80c32200234f4c","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-13T00:40:59.463Z","from_sync":false,"order":1,"slug":"managers","title":"Core Managers"},"__v":1,"version":{"_id":"57858bff9e80c32200234f4f","__v":3,"project":"57858bff9e80c32200234f4c","createdAt":"2016-07-13T00:31:59.708Z","releaseDate":"2016-07-13T00:31:59.708Z","categories":["57858bff9e80c32200234f50","57858e1b8a711d2000d1252b","5785a2bf2eca4e0e002b4d67"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Stable. I Hope.","version_clean":"0.3.0","version":"0.3.00"},"parentDoc":null,"user":"5785966d4b8fba2b0083e738","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-13T01:44:57.987Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Info\"\n}\n[/block]\n**Name** - `MusicManager`\n**Options** :\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"key\",\n    \"h-1\": \"type\",\n    \"h-2\": \"desc\",\n    \"0-0\": \"voiceEvents\",\n    \"0-1\": \"bool\",\n    \"0-2\": \"Wether to track voice events\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Commands\"\n}\n[/block]\nThese are the default commands include.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Command\",\n    \"h-1\": \"Run\",\n    \"h-2\": \"Context\",\n    \"h-3\": \"Desc\",\n    \"h-4\": \"Usage\",\n    \"0-0\": \"skip\",\n    \"0-1\": \"cmdSkip\",\n    \"0-2\": \"MusicManager\",\n    \"0-3\": \"Displays list of Audio Files.\",\n    \"0-4\": \"list [page]\",\n    \"1-0\": \"stream\",\n    \"2-0\": \"pause\",\n    \"1-1\": \"cmdStream\",\n    \"2-1\": \"cmdPause\",\n    \"1-2\": \"MusicManager\",\n    \"2-2\": \"MusicManager\",\n    \"1-3\": \"Plays an audio file.\",\n    \"2-3\": \"Stops all audio.\",\n    \"1-4\": \"play\",\n    \"2-4\": \"stop\"\n  },\n  \"cols\": 5,\n  \"rows\": 3\n}\n[/block]\nThis Function is used internally to AudioPlayer for the commands playFile and stopPlayinghttps://dash.readme.io/project/disnode/v0.3.00/docs/audioplayer\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Config\"\n}\n[/block]\nDefault Config Params\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"name\",\n    \"h-1\": \"type\",\n    \"h-2\": \"desc\",\n    \"0-0\": \"commands\",\n    \"0-1\": \"Array<CommandObjects>\",\n    \"0-2\": \"Default Commands\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Source Code\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\\"use strict\\\"\\nconst colors = require('colors');\\nconst walk = require('walk');\\nconst fs = require(\\\"fs\\\");\\nconst ytdl = require('ytdl-core');\\n\\nclass MusicManager{\\n  constructor(options){\\n    this.options = options;\\n    this.disnode = options.disnode;\\n\\n    this.following = [];\\n\\n\\n    this.defaultConfig = {\\n      commands:[\\n        {\\n\\t\\t      \\\"cmd\\\": \\\"skip\\\",\\n\\t\\t      \\\"context\\\": \\\"MusicManager\\\",\\n\\t\\t      \\\"run\\\": \\\"cmdSkip\\\",\\n\\t\\t      \\\"desc\\\": \\\"Displays list of Audio Files.\\\",\\n\\t\\t      \\\"usage\\\": \\\"list [page]\\\",\\n\\t\\t    },\\n\\t\\t\\t\\t{\\n\\t\\t      \\\"cmd\\\": \\\"stream\\\",\\n\\t\\t      \\\"context\\\": \\\"MusicManager\\\",\\n\\t\\t      \\\"run\\\": \\\"cmdStream\\\",\\n\\t\\t      \\\"desc\\\": \\\"Plays an audio file.\\\",\\n\\t\\t      \\\"usage\\\": \\\"play [url] [volume]\\\",\\n\\t\\t    },\\n        {\\n\\t\\t      \\\"cmd\\\": \\\"clearqueue\\\",\\n\\t\\t      \\\"context\\\": \\\"MusicManager\\\",\\n\\t\\t      \\\"run\\\": \\\"cmdClearQueue\\\",\\n\\t\\t      \\\"desc\\\": \\\"Stopps and Clears all URLS's in Queue\\\",\\n\\t\\t      \\\"usage\\\": \\\"clearqueue\\\",\\n\\t\\t    },\\n\\t\\t    {\\n\\t\\t      \\\"cmd\\\": \\\"resume\\\",\\n\\t\\t      \\\"context\\\": \\\"MusicManager\\\",\\n\\t\\t      \\\"run\\\": \\\"cmdResume\\\",\\n\\t\\t      \\\"desc\\\": \\\"Resumes Connection\\\",\\n\\t\\t      \\\"usage\\\": \\\"resume\\\",\\n\\t\\t    },\\n        {\\n\\t\\t      \\\"cmd\\\": \\\"pause\\\",\\n\\t\\t      \\\"context\\\": \\\"MusicManager\\\",\\n\\t\\t      \\\"run\\\": \\\"cmdPause\\\",\\n\\t\\t      \\\"desc\\\": \\\"Pauses Connection\\\",\\n\\t\\t      \\\"usage\\\": \\\"resume\\\",\\n\\t\\t    },\\n\\t\\t\\t\\t{\\n          \\\"cmd\\\": \\\"jv\\\",\\n          \\\"context\\\": \\\"MusicManager\\\",\\n          \\\"run\\\": \\\"cmdJoinVoice\\\",\\n          \\\"desc\\\": \\\"Joins the voice channel you are connected to.\\\",\\n          \\\"usage\\\": \\\"jv\\\"\\n        },\\n        {\\n          \\\"cmd\\\": \\\"lv\\\",\\n          \\\"context\\\": \\\"MusicManager\\\",\\n          \\\"run\\\": \\\"cmdLeaveVoice\\\",\\n          \\\"desc\\\": \\\"Leaves the voice channel you are connected to.\\\",\\n          \\\"usage\\\": \\\"lv\\\",\\n        },\\n        {\\n          \\\"cmd\\\": \\\"follow\\\",\\n          \\\"context\\\": \\\"MusicManager\\\",\\n          \\\"run\\\": \\\"cmdFollowUser\\\",\\n          \\\"desc\\\": \\\"Test Command that lists all params.\\\",\\n          \\\"usage\\\": \\\"follow [User]\\\",\\n        },\\n        {\\n          \\\"cmd\\\": \\\"unfollow\\\",\\n          \\\"context\\\": \\\"MusicManager\\\",\\n          \\\"run\\\": \\\"cmdUnFollowUser\\\",\\n          \\\"desc\\\": \\\"Test Command that lists all params.\\\",\\n          \\\"usage\\\": \\\"unfollow [parms]\\\",\\n        }\\n\\t\\t\\t],\\n\\t\\t\\tsongs: [],\\n      maxVolume: 3,\\n      defaultVolume: 0.8,\\n\\t\\t\\tresNoName : \\\"```Please Enter a name for this song!```\\\",\\n\\t\\t\\tresNoUrl : \\\"```Please Enter a Youtube URL for this song!```\\\",\\n\\t\\t\\tresSongAdded : \\\"```[Song] Added!```\\\",\\n      resFollow : \\\"**Following: ** [Sender]\\\",\\n      resUnFollow : \\\"**Stop Following: ** [Sender]\\\",\\n      resJoiningServer: \\\"**Joining Server: ** [Server]\\\",\\n      resNotInServer: \\\"**Can't Join You! Try Joining a Channel First!**\\\",\\n      resMaxVolume: \\\"**Max Volume([MaxVolume]) Reached! Playing at: [DefaultVolume].**\\\",\\n      resResume: \\\"**Resuming the queue!**\\\",\\n      resAddedToQueue: \\\"**Added to the queue!**\\\",\\n      resPause: \\\"**Pausing the queue!**\\\",\\n      resClearQueue: \\\"**Clearing the queue!**\\\"\\n    };\\n\\n    this.config = this.disnode.config.MusicManager || this.defaultConfig;\\n\\n    if(options.voiceEvents == true){\\n       options.disnode.bot.on(\\\"voiceJoin\\\", (c,u)=>this.OnVoiceJoin(c,u));\\n       options.disnode.bot.on(\\\"voiceLeave\\\", (c,u)=>this.OnVoiceLeave(c,u));\\n    }\\n  }\\n\\n  OnVoiceJoin(channel,user){\\n    if(this.following.includes(user.username)){\\n        this.JoinServer(channel);\\n    }\\n  }\\n\\n  OnVoiceLeave(channel,user){\\n    if(this.following.includes(user.username)){\\n      this.LeaveServer(channel);\\n    }\\n  }\\n\\n  playStream(connection, vol){\\n    if(connection.queue[0]){\\n      var self = this;\\n      connection.playRunning = true;\\n      connection.setVolume(vol);\\n      connection.ytStream = ytdl(connection.queue[0], {audioonly: true});\\n      connection.ytStream.on('end', function(){\\n        if(connection.queue.length == 0){\\n          connection.playRunning = false;\\n\\n        }else{\\n          self.playStream(connection);\\n          //connection.ytStream.destory();\\n        }\\n      });\\n      connection.queue.splice(0,1);\\n  \\t\\tconnection.playRawStream(connection.ytStream);\\n    }else{\\n      console.log(\\\"No Next Song!\\\");\\n      if(connection.ytStream){\\n        connection.ytStream.destroy();\\n      }\\n      connection.playRunning = false;\\n    }\\n  }\\n  addUrl(url,connection, vol){\\n    var bot = this.disnode.bot;\\n\\n    if(!connection.queue){connection.queue = [];}\\n    connection.queue.push(url);\\n    if(!connection.playRunning){\\n      this.playStream(connection,vol);\\n    }\\n  }\\n\\n  JoinServer(channel){\\n    var self = this;\\n    this.disnode.bot.joinVoiceChannel(channel, function(err, connnection){\\n      if(err){\\n        console.log(err);\\n        return;\\n      }\\n    });\\n  }\\n\\n  LeaveServer(channel){\\n    var self = this;\\n    this.disnode.bot.leaveVoiceChannel(channel, function(err, connnection){\\n      if(err){\\n        console.log(err);\\n        return;\\n      }\\n    });\\n  }\\n\\n  cmdPause(parsedMsg){\\n    var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\\n\\n    if(connection){\\n      connection.pause();\\n      this.disnode.sendResponse(parsedMsg, this.config.resPause);\\n    }else{\\n      this.disnode.sendResponse(parsedMsg, this.config.resNotInServer);\\n    }\\n  }\\n\\n  cmdResume(parsedMsg){\\n    var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\\n\\n    if(connection){\\n      connection.resume();\\n      this.disnode.sendResponse(parsedMsg, this.config.resResume,{parse: true});\\n    }else{\\n      this.disnode.sendResponse(parsedMsg, this.config.resNotInServer,{parse: true});\\n    }\\n  }\\n\\n  cmdStream(parsedMsg){\\n    var self = this;\\n    var url = parsedMsg.params[0];\\n    var vol = this.config.defaultConfig || .8;\\n    if(parsedMsg.params[1]){\\n      if(parseFloat(parsedMsg.params[1]) != 'NaN'){\\n        vol = parseFloat(parsedMsg.params[1]);\\n      }\\n    }\\n    GetVolume(vol, this.config, function(err, res){\\n      if(!err){\\n        vol = res;\\n\\n      }\\n      if(err == \\\"MAX\\\"){\\n        var shortcuts = [\\n          {shortcut: \\\"[DefaultVolume]\\\", data: self.config.defaultVolume},\\n          {shortcut: \\\"[MaxVolume]\\\", data: self.config.maxVolume},\\n          {shortcut: \\\"[RequestedVolume]\\\", data: vol}\\n        ];\\n        self.disnode.sendResponse(parsedMsg, self.config.resMaxVolume, {parse: true, shortcuts: shortcuts})\\n      }\\n    });\\n    var channel = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\\n\\n    if(channel){\\n      var shortcutsAdd = [\\n        {shortcut: \\\"[url]\\\", data: url},\\n        {shortcut: \\\"[channel]\\\", data: channel.voiceChannel.name},\\n        {shortcut: \\\"[vol]\\\", data: vol},\\n      ];\\n      this.addUrl(url,channel,vol);\\n      this.disnode.sendResponse(parsedMsg, self.config.resAddedToQueue, {parse: true, shortcuts: shortcutsAdd});\\n    }\\n    else{\\n      this.disnode.sendResponse(parsedMsg, \\\"Not In Server!\\\");\\n    }\\n  }\\n\\n  cmdJoinVoice(parsedMsg){\\n    var self = this;\\n    var channel = parsedMsg.msg.author.voiceChannel;\\n    var shortcuts = [{\\n      shortcut: \\\"[Server]\\\",\\n      data: channel.name\\n    }];\\n    if(channel){\\n      this.JoinServer(channel);\\n      this.disnode.sendResponse(parsedMsg, this.config.resJoiningServer,{parse: true, shortcuts: shortcuts});\\n    }else{\\n      this.disnode.sendResponse(parsedMsg, this.config.resNotInServer,{parse: true});\\n    }\\n  }\\n\\n  cmdLeaveVoice(parsedMsg){\\n    var channel = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections).voiceChannel;\\n    this.LeaveServer(channel);\\n  }\\n\\n  cmdSkip(parsedMsg){\\n    var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\\n\\n    if(connection){\\n      connection.queue.splice(0,1);\\n      this.playStream(connection,0.8);\\n    }\\n  }\\n\\n  cmdFollowUser(parsedMsg){\\n    var self = this;\\n    this.following.push(parsedMsg.msg.author.username);\\n    console.log(this.following);\\n    this.disnode.sendResponse(parsedMsg, this.config.resFollow,{parse: true});\\n  }\\n\\n  cmdUnFollowUser(parsedMsg){\\n    var index = this.following.indexOf(parsedMsg.msg.author.username);\\n\\n    this.following.splice(index,1);\\n\\n    this.disnode.sendResponse(parsedMsg, this.config.resUnFollow,{parse: true});\\n  }\\n\\n  cmdClearQueue(parsedMsg){\\n    var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\\n\\n    if(connection){\\n      connection.queue = [];\\n      connection.stopPlaying();\\n      this.disnode.sendResponse(parsedMsg, this.config.resClearQueue);\\n    }else{\\n      this.disnode.sendResponse(parsedMsg, this.config.resNotInServer);\\n    }\\n  }\\n\\n}\\n\\nfunction GetVoiceConnectionViaMsg(msg, voiceConnections){\\n  var connection;\\n\\n  var serverChannels = msg.server.channels;\\n\\n  for (var i = 0; i < voiceConnections.length; i++) {\\n    var channel = voiceConnections[i].voiceChannel;\\n\\n    if(serverChannels.includes(channel)){\\n      connection = voiceConnections[i];\\n    }\\n  }\\n\\n  return connection;\\n}\\n\\nfunction GetVolume(requestedVol, config, cb){\\n  var defaultVol = config.defaultVolume || 0.8;\\n  var maxVol = config.maxVolume || 1;\\n\\n  if(requestedVol <= maxVol){\\n\\n    cb(null,requestedVol) ;\\n  }else{\\n    cb(\\\"MAX\\\", defaultVol);\\n  }\\n}\\n\\nmodule.exports = MusicManager;\\n\",\n      \"language\": \"javascript\",\n      \"name\": \"ManagerSource\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"audioplayer","type":"basic","title":"MusicManager"}
[block:api-header] { "type": "basic", "title": "Info" } [/block] **Name** - `MusicManager` **Options** : [block:parameters] { "data": { "h-0": "key", "h-1": "type", "h-2": "desc", "0-0": "voiceEvents", "0-1": "bool", "0-2": "Wether to track voice events" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "basic", "title": "Commands" } [/block] These are the default commands include. [block:parameters] { "data": { "h-0": "Command", "h-1": "Run", "h-2": "Context", "h-3": "Desc", "h-4": "Usage", "0-0": "skip", "0-1": "cmdSkip", "0-2": "MusicManager", "0-3": "Displays list of Audio Files.", "0-4": "list [page]", "1-0": "stream", "2-0": "pause", "1-1": "cmdStream", "2-1": "cmdPause", "1-2": "MusicManager", "2-2": "MusicManager", "1-3": "Plays an audio file.", "2-3": "Stops all audio.", "1-4": "play", "2-4": "stop" }, "cols": 5, "rows": 3 } [/block] This Function is used internally to AudioPlayer for the commands playFile and stopPlayinghttps://dash.readme.io/project/disnode/v0.3.00/docs/audioplayer [block:api-header] { "type": "basic", "title": "Config" } [/block] Default Config Params [block:parameters] { "data": { "h-0": "name", "h-1": "type", "h-2": "desc", "0-0": "commands", "0-1": "Array<CommandObjects>", "0-2": "Default Commands" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "basic", "title": "Source Code" } [/block] [block:code] { "codes": [ { "code": "\"use strict\"\nconst colors = require('colors');\nconst walk = require('walk');\nconst fs = require(\"fs\");\nconst ytdl = require('ytdl-core');\n\nclass MusicManager{\n constructor(options){\n this.options = options;\n this.disnode = options.disnode;\n\n this.following = [];\n\n\n this.defaultConfig = {\n commands:[\n {\n\t\t \"cmd\": \"skip\",\n\t\t \"context\": \"MusicManager\",\n\t\t \"run\": \"cmdSkip\",\n\t\t \"desc\": \"Displays list of Audio Files.\",\n\t\t \"usage\": \"list [page]\",\n\t\t },\n\t\t\t\t{\n\t\t \"cmd\": \"stream\",\n\t\t \"context\": \"MusicManager\",\n\t\t \"run\": \"cmdStream\",\n\t\t \"desc\": \"Plays an audio file.\",\n\t\t \"usage\": \"play [url] [volume]\",\n\t\t },\n {\n\t\t \"cmd\": \"clearqueue\",\n\t\t \"context\": \"MusicManager\",\n\t\t \"run\": \"cmdClearQueue\",\n\t\t \"desc\": \"Stopps and Clears all URLS's in Queue\",\n\t\t \"usage\": \"clearqueue\",\n\t\t },\n\t\t {\n\t\t \"cmd\": \"resume\",\n\t\t \"context\": \"MusicManager\",\n\t\t \"run\": \"cmdResume\",\n\t\t \"desc\": \"Resumes Connection\",\n\t\t \"usage\": \"resume\",\n\t\t },\n {\n\t\t \"cmd\": \"pause\",\n\t\t \"context\": \"MusicManager\",\n\t\t \"run\": \"cmdPause\",\n\t\t \"desc\": \"Pauses Connection\",\n\t\t \"usage\": \"resume\",\n\t\t },\n\t\t\t\t{\n \"cmd\": \"jv\",\n \"context\": \"MusicManager\",\n \"run\": \"cmdJoinVoice\",\n \"desc\": \"Joins the voice channel you are connected to.\",\n \"usage\": \"jv\"\n },\n {\n \"cmd\": \"lv\",\n \"context\": \"MusicManager\",\n \"run\": \"cmdLeaveVoice\",\n \"desc\": \"Leaves the voice channel you are connected to.\",\n \"usage\": \"lv\",\n },\n {\n \"cmd\": \"follow\",\n \"context\": \"MusicManager\",\n \"run\": \"cmdFollowUser\",\n \"desc\": \"Test Command that lists all params.\",\n \"usage\": \"follow [User]\",\n },\n {\n \"cmd\": \"unfollow\",\n \"context\": \"MusicManager\",\n \"run\": \"cmdUnFollowUser\",\n \"desc\": \"Test Command that lists all params.\",\n \"usage\": \"unfollow [parms]\",\n }\n\t\t\t],\n\t\t\tsongs: [],\n maxVolume: 3,\n defaultVolume: 0.8,\n\t\t\tresNoName : \"```Please Enter a name for this song!```\",\n\t\t\tresNoUrl : \"```Please Enter a Youtube URL for this song!```\",\n\t\t\tresSongAdded : \"```[Song] Added!```\",\n resFollow : \"**Following: ** [Sender]\",\n resUnFollow : \"**Stop Following: ** [Sender]\",\n resJoiningServer: \"**Joining Server: ** [Server]\",\n resNotInServer: \"**Can't Join You! Try Joining a Channel First!**\",\n resMaxVolume: \"**Max Volume([MaxVolume]) Reached! Playing at: [DefaultVolume].**\",\n resResume: \"**Resuming the queue!**\",\n resAddedToQueue: \"**Added to the queue!**\",\n resPause: \"**Pausing the queue!**\",\n resClearQueue: \"**Clearing the queue!**\"\n };\n\n this.config = this.disnode.config.MusicManager || this.defaultConfig;\n\n if(options.voiceEvents == true){\n options.disnode.bot.on(\"voiceJoin\", (c,u)=>this.OnVoiceJoin(c,u));\n options.disnode.bot.on(\"voiceLeave\", (c,u)=>this.OnVoiceLeave(c,u));\n }\n }\n\n OnVoiceJoin(channel,user){\n if(this.following.includes(user.username)){\n this.JoinServer(channel);\n }\n }\n\n OnVoiceLeave(channel,user){\n if(this.following.includes(user.username)){\n this.LeaveServer(channel);\n }\n }\n\n playStream(connection, vol){\n if(connection.queue[0]){\n var self = this;\n connection.playRunning = true;\n connection.setVolume(vol);\n connection.ytStream = ytdl(connection.queue[0], {audioonly: true});\n connection.ytStream.on('end', function(){\n if(connection.queue.length == 0){\n connection.playRunning = false;\n\n }else{\n self.playStream(connection);\n //connection.ytStream.destory();\n }\n });\n connection.queue.splice(0,1);\n \t\tconnection.playRawStream(connection.ytStream);\n }else{\n console.log(\"No Next Song!\");\n if(connection.ytStream){\n connection.ytStream.destroy();\n }\n connection.playRunning = false;\n }\n }\n addUrl(url,connection, vol){\n var bot = this.disnode.bot;\n\n if(!connection.queue){connection.queue = [];}\n connection.queue.push(url);\n if(!connection.playRunning){\n this.playStream(connection,vol);\n }\n }\n\n JoinServer(channel){\n var self = this;\n this.disnode.bot.joinVoiceChannel(channel, function(err, connnection){\n if(err){\n console.log(err);\n return;\n }\n });\n }\n\n LeaveServer(channel){\n var self = this;\n this.disnode.bot.leaveVoiceChannel(channel, function(err, connnection){\n if(err){\n console.log(err);\n return;\n }\n });\n }\n\n cmdPause(parsedMsg){\n var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\n\n if(connection){\n connection.pause();\n this.disnode.sendResponse(parsedMsg, this.config.resPause);\n }else{\n this.disnode.sendResponse(parsedMsg, this.config.resNotInServer);\n }\n }\n\n cmdResume(parsedMsg){\n var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\n\n if(connection){\n connection.resume();\n this.disnode.sendResponse(parsedMsg, this.config.resResume,{parse: true});\n }else{\n this.disnode.sendResponse(parsedMsg, this.config.resNotInServer,{parse: true});\n }\n }\n\n cmdStream(parsedMsg){\n var self = this;\n var url = parsedMsg.params[0];\n var vol = this.config.defaultConfig || .8;\n if(parsedMsg.params[1]){\n if(parseFloat(parsedMsg.params[1]) != 'NaN'){\n vol = parseFloat(parsedMsg.params[1]);\n }\n }\n GetVolume(vol, this.config, function(err, res){\n if(!err){\n vol = res;\n\n }\n if(err == \"MAX\"){\n var shortcuts = [\n {shortcut: \"[DefaultVolume]\", data: self.config.defaultVolume},\n {shortcut: \"[MaxVolume]\", data: self.config.maxVolume},\n {shortcut: \"[RequestedVolume]\", data: vol}\n ];\n self.disnode.sendResponse(parsedMsg, self.config.resMaxVolume, {parse: true, shortcuts: shortcuts})\n }\n });\n var channel = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\n\n if(channel){\n var shortcutsAdd = [\n {shortcut: \"[url]\", data: url},\n {shortcut: \"[channel]\", data: channel.voiceChannel.name},\n {shortcut: \"[vol]\", data: vol},\n ];\n this.addUrl(url,channel,vol);\n this.disnode.sendResponse(parsedMsg, self.config.resAddedToQueue, {parse: true, shortcuts: shortcutsAdd});\n }\n else{\n this.disnode.sendResponse(parsedMsg, \"Not In Server!\");\n }\n }\n\n cmdJoinVoice(parsedMsg){\n var self = this;\n var channel = parsedMsg.msg.author.voiceChannel;\n var shortcuts = [{\n shortcut: \"[Server]\",\n data: channel.name\n }];\n if(channel){\n this.JoinServer(channel);\n this.disnode.sendResponse(parsedMsg, this.config.resJoiningServer,{parse: true, shortcuts: shortcuts});\n }else{\n this.disnode.sendResponse(parsedMsg, this.config.resNotInServer,{parse: true});\n }\n }\n\n cmdLeaveVoice(parsedMsg){\n var channel = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections).voiceChannel;\n this.LeaveServer(channel);\n }\n\n cmdSkip(parsedMsg){\n var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\n\n if(connection){\n connection.queue.splice(0,1);\n this.playStream(connection,0.8);\n }\n }\n\n cmdFollowUser(parsedMsg){\n var self = this;\n this.following.push(parsedMsg.msg.author.username);\n console.log(this.following);\n this.disnode.sendResponse(parsedMsg, this.config.resFollow,{parse: true});\n }\n\n cmdUnFollowUser(parsedMsg){\n var index = this.following.indexOf(parsedMsg.msg.author.username);\n\n this.following.splice(index,1);\n\n this.disnode.sendResponse(parsedMsg, this.config.resUnFollow,{parse: true});\n }\n\n cmdClearQueue(parsedMsg){\n var connection = GetVoiceConnectionViaMsg(parsedMsg.msg, this.disnode.bot.voiceConnections);\n\n if(connection){\n connection.queue = [];\n connection.stopPlaying();\n this.disnode.sendResponse(parsedMsg, this.config.resClearQueue);\n }else{\n this.disnode.sendResponse(parsedMsg, this.config.resNotInServer);\n }\n }\n\n}\n\nfunction GetVoiceConnectionViaMsg(msg, voiceConnections){\n var connection;\n\n var serverChannels = msg.server.channels;\n\n for (var i = 0; i < voiceConnections.length; i++) {\n var channel = voiceConnections[i].voiceChannel;\n\n if(serverChannels.includes(channel)){\n connection = voiceConnections[i];\n }\n }\n\n return connection;\n}\n\nfunction GetVolume(requestedVol, config, cb){\n var defaultVol = config.defaultVolume || 0.8;\n var maxVol = config.maxVolume || 1;\n\n if(requestedVol <= maxVol){\n\n cb(null,requestedVol) ;\n }else{\n cb(\"MAX\", defaultVol);\n }\n}\n\nmodule.exports = MusicManager;\n", "language": "javascript", "name": "ManagerSource" } ] } [/block]