From 17f90fcc6a4bdfd6e88c732a71eedfe4042bb37e Mon Sep 17 00:00:00 2001 From: Emily J Date: Wed, 3 Mar 2021 10:43:59 +1100 Subject: [PATCH] rearranged things because my brain is dumb --- bot/util/functions.js | 70 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/bot/util/functions.js b/bot/util/functions.js index 0e9ddd9..586f445 100644 --- a/bot/util/functions.js +++ b/bot/util/functions.js @@ -27,6 +27,10 @@ class Functions { return false; } } + + intBetween (min, max) { + return Math.round((Math.random() * (max - min) + min)); + } randomColour () { const n = (Math.random() * 0xfffff * 1000000).toString(16); @@ -38,14 +42,14 @@ class Functions { return roleMap.sort((a, b) => b.position - a.position); } - displayHexColour (guild, userID) { - const roles = this.roleObjects(guild, guild.members.get(userID).roles); - for (const object of roles) { - if (object.color !== 0) return '#' + object.color.toString(16); + findRole (input, guild) { + let role; + role = guild.roles.find(r => r.name.toLowerCase() === input.toLowerCase()); + if (!role) { + role = guild.roles.get(input.toLowerCase()); } - - const colourKeys = Object.keys(colours); - return colours[colourKeys[ colours.length * Math.random() << 0]]; + if (!role) return; + return role; } highestRole (member) { @@ -61,14 +65,14 @@ class Functions { return highestRole; } - findRole (input, guild) { - let role; - role = guild.roles.find(r => r.name.toLowerCase() === input.toLowerCase()); - if (!role) { - role = guild.roles.get(input.toLowerCase()); + displayHexColour (guild, userID) { + const roles = this.roleObjects(guild, guild.members.get(userID).roles); + for (const object of roles) { + if (object.color !== 0) return '#' + object.color.toString(16); } - if (!role) return; - return role; + + const colourKeys = Object.keys(colours); + return colours[colourKeys[ colours.length * Math.random() << 0]]; } checkPermissions (channel, user_id, requiredPerms) { @@ -85,27 +89,6 @@ class Functions { return; } - intBetween (min, max) { - return Math.round((Math.random() * (max - min) + min)); - } - - shutdown () { - const exitQuotes = [ - 'Shutting down.', - 'I don\'t blame you.', - 'I don\'t hate you.', - 'Whyyyyy', - 'Goodnight.', - 'Goodbye' - ]; - - this.client.disconnect(); - - this.client.logger.success('SHUTDOWN_SUCCESS', exitQuotes.random()); - - process.exit(); - } - async getUser (id) { if (this.client.users.has(id)) return this.client.users.get(id); this.client.logger.debug('REST_FETCH_USER', 'Accessing rest API...'); @@ -153,6 +136,23 @@ class Functions { return text; } + shutdown () { + const exitQuotes = [ + 'Shutting down.', + 'I don\'t blame you.', + 'I don\'t hate you.', + 'Whyyyyy', + 'Goodnight.', + 'Goodbye' + ]; + + this.client.disconnect(); + + this.client.logger.success('SHUTDOWN_SUCCESS', exitQuotes.random()); + + process.exit(); + } + wait () { promisify(setTimeout); }