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 textIssues = issues.filter((i) => i.type === 'GUILD_TEXT');
|
||||||
const voiceIssues = issues.filter((i) => i.type === 'GUILD_VOICE');
|
const voiceIssues = issues.filter((i) => i.type === 'GUILD_VOICE');
|
||||||
const permissionIssues = issues.filter((i) => i.type === 'permission');
|
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 (textIssues.length) embed.fields.push(addField(textIssues, 'text'));
|
||||||
if (voiceIssues.length) embed.fields.push(addField(voiceIssues, 'voice'));
|
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];
|
response.embeds = [embed];
|
||||||
updated.push('role');
|
updated.push('role');
|
||||||
@ -253,8 +259,9 @@ class MuteSetting extends Setting {
|
|||||||
|
|
||||||
for (const channel of channels.values()) {
|
for (const channel of channels.values()) {
|
||||||
|
|
||||||
if (!channel.permissionsFor(this.client.user).has('ManageRoles')) {
|
const missing = channel.permissionsFor(this.client.user).missing(['ManageRoles', 'ViewChannel']);
|
||||||
issues.push({ type: 'permission', channel: channel.name });
|
if (missing.length) {
|
||||||
|
issues.push({ type: 'permission', channel: channel.name, missing });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user