mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Added removeDuplicates and capitalise functions.
This commit is contained in:
parent
58787c907c
commit
5645d856cf
1 changed files with 10 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue