channel perms check when creating mute

This commit is contained in:
Erik 2022-07-15 11:14:27 +03:00
parent afdf63e8a6
commit 7028179152
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 10 additions and 0 deletions

View File

@ -318,6 +318,9 @@ Aborted.
[SETTING_MUTE_ROLE_MANAGED]
Cannot use a manged role for mute.
[SETTING_MUTE_MISSING_CHANNEL_PERMS]
Could not create channel overrides in **{channel}**
////////////////////////////////////////////////////////////////
// Wordfilter

View File

@ -130,8 +130,10 @@ 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');
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 `MANAGE_ROLES`', value: permissionIssues.map((i) => invoker.guild.format('SETTING_MUTE_MISSING_CHANNEL_PERMS', i)).join('\n') });
response.embeds = [embed];
updated.push('role');
@ -248,6 +250,11 @@ class MuteSetting extends Setting {
for (const channel of channels.values()) {
if (!channel.permissionsFor(guild.me).has('MANAGE_ROLES')) {
issues.push({ type: 'permission', channel: channel.name });
continue;
}
const configuration = channel.type === 'GUILD_TEXT'
? { permissions: { SEND_MESSAGES: false, ADD_REACTIONS: false }, bitwise: 0x800n }
: { permissions: { CONNECT: false, SEND_MESSAGES: false, ADD_REACTIONS: false }, bitwise: 0x100000n };