more functions
This commit is contained in:
parent
68847e9c72
commit
4bfe1a97e0
|
@ -169,24 +169,83 @@ module.exports = (client) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const randomColor = () => [
|
const randomColor = () => [
|
||||||
Math.floor(Math.random() * 256),
|
Math.floor(Math.random() * 256),
|
||||||
Math.floor(Math.random() * 256),
|
Math.floor(Math.random() * 256),
|
||||||
Math.floor(Math.random() * 256)
|
Math.floor(Math.random() * 256)
|
||||||
];
|
];
|
||||||
|
|
||||||
const randomFooter = () => {
|
const randomFooter = () => {
|
||||||
return randomSelection([
|
return randomSelection([
|
||||||
'just add water!',
|
'just add water!',
|
||||||
'Powered by squirrels!',
|
'Powered by squirrels!',
|
||||||
'codeisluvcodeislife',
|
'codeisluvcodeislife',
|
||||||
'Where did you get that?',
|
'Where did you get that?',
|
||||||
'WHAT DID YOU BREAK!?',
|
'WHAT DID YOU BREAK!?',
|
||||||
'D-D-D-DROP THE BASS',
|
'D-D-D-DROP THE BASS',
|
||||||
'Eat, Sleep, JavaScript',
|
'Eat, Sleep, JavaScript',
|
||||||
'#BlameRhearmas',
|
'#BlameRhearmas',
|
||||||
'SharpBot was the best, right?',
|
'SharpBot was the best, right?',
|
||||||
'I like turtles',
|
'I like turtles',
|
||||||
'Hi mom!'
|
'Hi mom!'
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
const timestampToDate = timestamp => {
|
||||||
|
if (timestamp === true) {
|
||||||
|
return new Date();
|
||||||
|
}
|
||||||
|
if (typeof timestamp === 'number') {
|
||||||
|
return new Date(timestamp);
|
||||||
|
}
|
||||||
|
return timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseArgs = (args, options) => {
|
||||||
|
if (!options)
|
||||||
|
return args;
|
||||||
|
if (typeof options === 'string')
|
||||||
|
options = [options];
|
||||||
|
|
||||||
|
let optionValues = {};
|
||||||
|
|
||||||
|
let i;
|
||||||
|
for (i = 0; i < args.length; i++) {
|
||||||
|
let arg = args[i];
|
||||||
|
if (!arg.startsWith('-')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let label = arg.substr(1);
|
||||||
|
|
||||||
|
if (options.indexOf(label + ':') > -1) {
|
||||||
|
let leftover = args.slice(i + 1).join(' ');
|
||||||
|
let matches = leftover.match(/^"(.+?)"/);
|
||||||
|
if (matches) {
|
||||||
|
optionValues[label] = matches[1];
|
||||||
|
i += matches[0].split(' ').length;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
optionValues[label] = args[i];
|
||||||
|
}
|
||||||
|
} else if (options.indexOf(label) > -1) {
|
||||||
|
optionValues[label] = true;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
options: optionValues,
|
||||||
|
leftover: args.slice(i)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const multiSend = (channel, messages, delay) => {
|
||||||
|
delay = delay || 100;
|
||||||
|
messages.forEach((m, i) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
channel.send(m);
|
||||||
|
}, delay * i);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue