Fixed bugs

This commit is contained in:
CorwinDev 2022-12-23 08:15:33 +01:00
parent 899510861e
commit 3fe8915cfb
2 changed files with 8 additions and 9 deletions

View file

@ -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

View file

@ -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