From 3fe8915cfb3eb8f5acb15eeaff3803609586da7c Mon Sep 17 00:00:00 2001 From: CorwinDev <88144943+CorwinDev@users.noreply.github.com> Date: Fri, 23 Dec 2022 08:15:33 +0100 Subject: [PATCH] Fixed bugs --- src/dev.js | 2 +- src/handlers/functions/functions.js | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dev.js b/src/dev.js index 4e50e8b..05756da 100644 --- a/src/dev.js +++ b/src/dev.js @@ -5,6 +5,7 @@ * * @string member - The member you want to add the badge to */ +const chalk = require('chalk'); if (!process.argv[2]) { console.log(chalk.red(`[ERROR]`), chalk.white(`>>`), chalk.red(`Developer Badge`), chalk.white(`>>`), chalk.red(`Please provide a member id!`)) process.exit(1); @@ -14,7 +15,6 @@ require('dotenv').config('./.env'); const mongoose = require('mongoose'); // Require the model const model = require('./database/models/badge.js'); -const chalk = require('chalk'); // Connect to the database mongoose.set('strictQuery', false); // Await the connection diff --git a/src/handlers/functions/functions.js b/src/handlers/functions/functions.js index 4d4a10e..cd76bdc 100644 --- a/src/handlers/functions/functions.js +++ b/src/handlers/functions/functions.js @@ -8,7 +8,11 @@ module.exports = async (client) => { //----------------------------------------------------------------// // Permissions // //----------------------------------------------------------------// - + // All bitfields to name + client.bitfieldToName = function (bitfield) { + const permissions = new Discord.PermissionsBitField(bitfield); + return permissions.toArray(); + } client.checkPerms = async function ({ flags: flags, perms: perms @@ -16,7 +20,7 @@ module.exports = async (client) => { for (let i = 0; i < flags.length; i++) { if (!interaction.member.permissions.has(flags[i])) { client.errMissingPerms({ - perms: perms[i], + perms: client.bitfieldToName(flags[i]) || flags[i], type: 'editreply' }, interaction); @@ -24,7 +28,7 @@ module.exports = async (client) => { } if (!interaction.guild.members.me.permissions.has(flags[i])) { client.errNoPerms({ - perms: perms[i], + perms: client.bitfieldToName(flags[i]) || flags[i], type: 'editreply' }, interaction); @@ -32,11 +36,6 @@ module.exports = async (client) => { } } } - // All bitfields to name - client.bitfieldToName = function (bitfield) { - const permissions = new Discord.PermissionsBitField(bitfield); - return permissions.toArray(); - } client.checkBotPerms = async function ({ flags: flags, perms: perms