diff --git a/lib/Util/Cache.js b/lib/Util/Cache.js index b0d5f51c0..a5d978624 100644 --- a/lib/Util/Cache.js +++ b/lib/Util/Cache.js @@ -83,6 +83,10 @@ var Cache = (function (_Array) { } }; + Cache.prototype.random = function random() { + return this[Math.floor(Math.random() * this.length)]; + }; + Cache.prototype.remove = function remove(data) { var index = this.indexOf(data); if (~index) { diff --git a/package.json b/package.json index 6d90f45c7..1b71509d2 100644 --- a/package.json +++ b/package.json @@ -1,41 +1,44 @@ { - "name": "discord.js", - "version": "5.0.1", - "description": "A way to interface with the Discord API", - "main": "./entrypoint.js", - "scripts": { - "test": "node ./test/bot.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hydrabolt/discord.js.git" - }, - "keywords": [ - "discord", - "api", - "bot", - "client", - "node", - "discordapp" - ], - "author": "Amish Shah ", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/hydrabolt/discord.js/issues" - }, - "homepage": "https://github.com/hydrabolt/discord.js#readme", - "dependencies": { - "superagent": "^1.3.0", - "ws": "^0.7.2" - }, - "devDependencies": { - "grunt": "~0.4.5", - "grunt-babel": "^5.0.1", - "grunt-browserify": "^4.0.0", - "grunt-contrib-uglify": "^0.9.2", - "load-grunt-tasks": "^3.2.0" - }, - "optionalDependencies": { - "node-opus": "^0.1.11" - } -} + "name": "discord.js", + "version": "5.0.1", + "description": "A way to interface with the Discord API", + "main": "./entrypoint.js", + "scripts": { + "test": "node ./test/bot.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hydrabolt/discord.js.git" + }, + "keywords": [ + "discord", + "api", + "bot", + "client", + "node", + "discordapp" + ], + "author": "Amish Shah ", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/hydrabolt/discord.js/issues" + }, + "homepage": "https://github.com/hydrabolt/discord.js#readme", + "dependencies": { + "superagent": "^1.3.0", + "ws": "^0.7.2" + }, + "devDependencies": { + "grunt": "~0.4.5", + "grunt-babel": "^5.0.1", + "grunt-browserify": "^4.0.0", + "grunt-contrib-uglify": "^0.9.2", + "load-grunt-tasks": "^3.2.0" + }, + "optionalDependencies": { + "node-opus": "^0.1.11" + }, + "engines": { + "node": ">=0.12.7" + } +} \ No newline at end of file diff --git a/src/Util/Cache.js b/src/Util/Cache.js index 776e7deaf..3b2210d01 100644 --- a/src/Util/Cache.js +++ b/src/Util/Cache.js @@ -61,6 +61,10 @@ class Cache extends Array { return false; } } + + random() { + return this[Math.floor(Math.random()*this.length)]; + } remove(data) { var index = this.indexOf(data);