MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / pickRandom

Function pickRandom

plugins/random-img.js:36–46  ·  view source on GitHub ↗
(arr, count = 1)

Source from the content-addressed store, hash-verified

34 wallhp: 'https://raw.githubusercontent.com/GlobalTechInfo/GLOBAL-XMD/master/src/media/randompics/wallhp.json',
35};
36function pickRandom(arr, count = 1) {
37 const result = [];
38 const copy = [...arr];
39 for (let i = 0; i < count; i++) {
40 if (copy.length === 0)
41 break;
42 const index = Math.floor(Math.random() * copy.length);
43 result.push(copy.splice(index, 1)[0]);
44 }
45 return result;
46}
47export default {
48 command: 'images',
49 aliases: ['wallpics', 'pics'],

Callers 1

handlerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected