Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Try to fix invite in a non-breaking way since d.js constants changed #219

Merged
merged 3 commits into from
May 9, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions functions/botPermissions.js
Original file line number Diff line number Diff line change
@@ -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"]))]);