Added removeDuplicates and capitalise functions.

This commit is contained in:
Keanu Timmermans 2020-07-01 14:38:07 +02:00
parent 58787c907c
commit 5645d856cf
1 changed files with 10 additions and 0 deletions

View File

@ -27,12 +27,22 @@ module.exports = class Util {
}
return arr;
}
formatBytes(bytes) {
if (bytes === 0) return '0 Bytes';
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(1024));
return `${parseFloat((bytes / Math.pow(1024, i)).toFixed(2))} ${sizes[i]}`;
}
removeDuplicates(arr) {
return [...new Set(arr)];
}
capitalise(string) {
return string.split(' ').map(str => str.slice(0, 1).toUpperCase() + str.slice(1)).join(' ');
}
async loadCommands() {
return glob(`${this.directory}commands/**/*.js`).then(commands => {
for (const commandFile of commands) {