From 5645d856cffa23bf4d50f7b89ed39f1557023193 Mon Sep 17 00:00:00 2001 From: Keanu Date: Wed, 1 Jul 2020 14:38:07 +0200 Subject: [PATCH] Added removeDuplicates and capitalise functions. --- src/Structures/Util.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Structures/Util.js b/src/Structures/Util.js index 78b8b21..39d9ee4 100644 --- a/src/Structures/Util.js +++ b/src/Structures/Util.js @@ -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) {