forked from Galactic/galactic-bot
filter out managed roles for settings that assign
This commit is contained in:
parent
5a2d1e6d6b
commit
9dc16a293b
@ -56,7 +56,7 @@ class Grantable extends Setting {
|
||||
const resolved = await guild.resolveRoles(params);
|
||||
if (!resolved.length) return { error: true, index: 'RESOLVE_FAIL', params: { type: 'roles' } };
|
||||
|
||||
this[roles.value](setting.roles, resolved.map((r) => r.id));
|
||||
this[roles.value](setting.roles, resolved.filter((r) => !r.managed).map((r) => r.id));
|
||||
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,10 @@ class MuteSetting extends Setting {
|
||||
response.embeds = [embed];
|
||||
updated.push('role');
|
||||
|
||||
} else if (opt.name === 'role') {
|
||||
if(opt.value.managed) return { error: true, index: 'SETTING_MUTE_ROLE_MANAGED' };
|
||||
setting.role = opt.value.id;
|
||||
updated.push(opt.name);
|
||||
} else {
|
||||
setting[opt.name] = opt.value;
|
||||
updated.push(opt.name);
|
||||
@ -193,7 +197,7 @@ class MuteSetting extends Setting {
|
||||
if (existing) {
|
||||
|
||||
const prompt = await interaction.promptInteraction({
|
||||
content: interaction.format('SETTING_MUTE_ROLEPROMPT', {
|
||||
content: interaction.format(`SETTING_MUTE_ROLEPROMPT${existing.managed ? '_MANAGED' : ''}`, {
|
||||
name: existing.name,
|
||||
id: existing.id
|
||||
}),
|
||||
@ -224,12 +228,12 @@ class MuteSetting extends Setting {
|
||||
error: true
|
||||
};
|
||||
|
||||
await prompt.update({ content: `${Emojis.working} Working...`, components: [] });
|
||||
const boolean = this.client.resolver.resolveBoolean(prompt.customId);
|
||||
await prompt.update({ content: `${Emojis.working} Working...`, components: [] });
|
||||
|
||||
if (boolean) {
|
||||
if (boolean && !existing.managed) {
|
||||
role = existing;
|
||||
}
|
||||
} else return { index: 'SETTING_MUTE_ABORT', error: true };
|
||||
} else interaction.editReply({ content: 'Working...', emoji: 'working' });
|
||||
|
||||
if (!role) {
|
||||
|
@ -57,7 +57,7 @@ class Autorole extends Setting {
|
||||
if (content.error) return content;
|
||||
|
||||
const words = Util.parseQuotes(content).map(([word]) => word);
|
||||
const params = (await guild.resolveRoles(words)).map((role) => role.id);
|
||||
const params = (await guild.resolveRoles(words)).filter((r) => !r.managed).map((role) => role.id);
|
||||
if (!params.length) return { error: true, index: 'RESOLVE_FAIL', params: { type: 'roles' } };
|
||||
|
||||
this[method](setting.roles, params);
|
||||
|
@ -58,7 +58,7 @@ class Autorole extends Setting {
|
||||
if (content.error) return content;
|
||||
|
||||
const words = Util.parseQuotes(content).map(([word]) => word);
|
||||
const params = (await guild.resolveRoles(words)).map((role) => role.id);
|
||||
const params = (await guild.resolveRoles(words)).filter((r) => !r.managed).map((role) => role.id);
|
||||
if (!params.length) return { error: true, index: 'RESOLVE_FAIL', params: { type: 'roles' } };
|
||||
|
||||
this[method](setting.roles, params);
|
||||
|
Loading…
Reference in New Issue
Block a user