diff --git a/functions/botPermissions.js b/functions/botPermissions.js index 23bd0fb0..14f85783 100644 --- a/functions/botPermissions.js +++ b/functions/botPermissions.js @@ -1,28 +1,3 @@ -const permFlags = require("discord.js/src/util/Constants.js").PermissionFlags; +const { Permissions } = require("discord.js"); -module.exports = (client) => { - const genObject = {}; - - for (const key in permFlags) { - genObject[key] = false; - } - - genObject.READ_MESSAGES = true; - genObject.SEND_MESSAGES = true; - - client.commands.forEach((command) => { - if (command.conf.botPerms.length > 0) { - command.conf.botPerms.forEach((val) => { - if (genObject.hasOwnProperty(val)) genObject[val] = true; - }); - } - }); - - let permNumber = 0; - for (const key in genObject) { - if (genObject[key] === true) { - permNumber += permFlags[key]; - } - } - return permNumber; -}; +module.exports = client => Permissions.resolve([...new Set(client.commands.reduce((a, b) => a.concat(b.conf.botPerms), ["READ_MESSAGES", "SEND_MESSAGES"]))]); diff --git a/package.json b/package.json index cb4088d1..20ba1eb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "komada", - "version": "0.19.1", + "version": "0.19.2", "author": "Evelyne Lachance", "description": "Komada: Croatian for 'pieces', is a modular bot system including reloading modules and easy to use custom commands.", "main": "app.js",