use for of and remove awaits
parent
a475df226f
commit
dee8243ad1
|
@ -21,7 +21,7 @@ export default class Role extends Command {
|
||||||
const rolesToAdd = [];
|
const rolesToAdd = [];
|
||||||
const rolesToRemove = [];
|
const rolesToRemove = [];
|
||||||
let stop = false;
|
let stop = false;
|
||||||
await rolesList.forEach((arg) => {
|
for (const arg of rolesList) {
|
||||||
const action = arg[0];
|
const action = arg[0];
|
||||||
let role;
|
let role;
|
||||||
if (action !== '+' && action !== '-') {
|
if (action !== '+' && action !== '-') {
|
||||||
|
@ -57,10 +57,10 @@ export default class Role extends Command {
|
||||||
}
|
}
|
||||||
return rolesToRemove.push(role);
|
return rolesToRemove.push(role);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
if (stop) return;
|
if (stop) return;
|
||||||
await rolesToAdd.forEach((role) => member.addRole(role.id));
|
rolesToAdd.forEach((role) => member.addRole(role.id));
|
||||||
await rolesToRemove.forEach((role) => member.removeRole(role.id));
|
rolesToRemove.forEach((role) => member.removeRole(role.id));
|
||||||
return this.success(message.channel, `Changed the roles for ${member.username}#${member.discriminator}${rolesToAdd.length > 0 ? `, added \`${rolesToAdd.map((r) => r.name).join('`, `')}\`` : ''}${rolesToRemove.length > 0 ? `, removed \`${rolesToRemove.map((r) => r.name).join('`, `')}\`` : ''}`);
|
return this.success(message.channel, `Changed the roles for ${member.username}#${member.discriminator}${rolesToAdd.length > 0 ? `, added \`${rolesToAdd.map((r) => r.name).join('`, `')}\`` : ''}${rolesToRemove.length > 0 ? `, removed \`${rolesToRemove.map((r) => r.name).join('`, `')}\`` : ''}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.util.handleError(err, message, this);
|
return this.client.util.handleError(err, message, this);
|
||||||
|
|
Loading…
Reference in New Issue