Disable updating permissions

This commit is contained in:
Isaac 2022-05-02 00:36:41 +01:00 committed by GitHub
parent 44a515e6e9
commit 2ea78a1457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,65 +81,65 @@ module.exports = class CommandManager {
} }
async updatePermissions(guild) { async updatePermissions(guild) {
guild.commands.fetch().then(async commands => { // guild.commands.fetch().then(async commands => {
const permissions = []; // const permissions = [];
const settings = await this.client.utils.getSettings(guild.id); // const settings = await this.client.utils.getSettings(guild.id);
const blacklist = []; // const blacklist = [];
settings.blacklist.users?.forEach(userId => { // settings.blacklist.users?.forEach(userId => {
blacklist.push({ // blacklist.push({
id: userId, // id: userId,
permission: false, // permission: false,
type: 'USER' // type: 'USER'
}); // });
}); // });
settings.blacklist.roles?.forEach(roleId => { // settings.blacklist.roles?.forEach(roleId => {
blacklist.push({ // blacklist.push({
id: roleId, // id: roleId,
permission: false, // permission: false,
type: 'ROLE' // type: 'ROLE'
}); // });
}); // });
const categories = await this.client.db.models.Category.findAll({ where: { guild: guild.id } }); // const categories = await this.client.db.models.Category.findAll({ where: { guild: guild.id } });
const staff_roles = new Set(categories.map(category => category.roles).flat()); // const staff_roles = new Set(categories.map(category => category.roles).flat());
commands.forEach(async g_cmd => { // commands.forEach(async g_cmd => {
const cmd_permissions = [...blacklist]; // const cmd_permissions = [...blacklist];
const command = this.client.commands.commands.get(g_cmd.name); // const command = this.client.commands.commands.get(g_cmd.name);
if (command.staff_only) { // if (command.staff_only) {
cmd_permissions.push({ // cmd_permissions.push({
id: guild.roles.everyone.id, // id: guild.roles.everyone.id,
permission: false, // permission: false,
type: 'ROLE' // type: 'ROLE'
}); // });
staff_roles.forEach(roleId => { // staff_roles.forEach(roleId => {
cmd_permissions.push({ // cmd_permissions.push({
id: roleId, // id: roleId,
permission: true, // permission: true,
type: 'ROLE' // type: 'ROLE'
}); // });
}); // });
} // }
permissions.push({ // permissions.push({
id: g_cmd.id, // id: g_cmd.id,
permissions: cmd_permissions // permissions: cmd_permissions
}); // });
}); // });
this.client.log.debug(`Command permissions for "${guild.name}"`, require('util').inspect(permissions, { // this.client.log.debug(`Command permissions for "${guild.name}"`, require('util').inspect(permissions, {
colors: true, // colors: true,
depth: 10 // depth: 10
})); // }));
try { // try {
await guild.commands.permissions.set({ fullPermissions: permissions }); // await guild.commands.permissions.set({ fullPermissions: permissions });
} catch (error) { // } catch (error) {
this.client.log.warn('An error occurred whilst updating command permissions'); // this.client.log.warn('An error occurred whilst updating command permissions');
this.client.log.error(error); // this.client.log.error(error);
} // }
}); // });
} }
/** /**