forked from Galactic/galactic-bot
better perms check for create mute
This commit is contained in:
parent
46c2bf689c
commit
ac30824106
@ -133,9 +133,15 @@ class MuteSetting extends Setting {
|
||||
const textIssues = issues.filter((i) => i.type === 'GUILD_TEXT');
|
||||
const voiceIssues = issues.filter((i) => i.type === 'GUILD_VOICE');
|
||||
const permissionIssues = issues.filter((i) => i.type === 'permission');
|
||||
const missingPerms = [
|
||||
...new Set(permissionIssues.reduce((acc, curr) => {
|
||||
acc.push(...curr.missing);
|
||||
return acc;
|
||||
}, []))
|
||||
];
|
||||
if (textIssues.length) embed.fields.push(addField(textIssues, 'text'));
|
||||
if (voiceIssues.length) embed.fields.push(addField(voiceIssues, 'voice'));
|
||||
if (permissionIssues.length) embed.fields.push({ name: 'Missing `ManageRoles`', value: permissionIssues.map((i) => invoker.guild.format('SETTING_MUTE_MISSING_CHANNEL_PERMS', i)).join('\n') });
|
||||
if (permissionIssues.length) embed.fields.push({ name: `Missing one of \`${missingPerms.join('`, `')}\``, value: permissionIssues.map((i) => invoker.guild.format('SETTING_MUTE_MISSING_CHANNEL_PERMS', i)).join('\n') });
|
||||
|
||||
response.embeds = [embed];
|
||||
updated.push('role');
|
||||
@ -253,8 +259,9 @@ class MuteSetting extends Setting {
|
||||
|
||||
for (const channel of channels.values()) {
|
||||
|
||||
if (!channel.permissionsFor(this.client.user).has('ManageRoles')) {
|
||||
issues.push({ type: 'permission', channel: channel.name });
|
||||
const missing = channel.permissionsFor(this.client.user).missing(['ManageRoles', 'ViewChannel']);
|
||||
if (missing.length) {
|
||||
issues.push({ type: 'permission', channel: channel.name, missing });
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user