use for of and remove awaits

merge-requests/13/head
hector6704 2020-08-25 15:28:53 +02:00
parent a475df226f
commit dee8243ad1
1 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export default class Role extends Command {
const rolesToAdd = [];
const rolesToRemove = [];
let stop = false;
await rolesList.forEach((arg) => {
for (const arg of rolesList) {
const action = arg[0];
let role;
if (action !== '+' && action !== '-') {
@ -57,10 +57,10 @@ export default class Role extends Command {
}
return rolesToRemove.push(role);
}
});
}
if (stop) return;
await rolesToAdd.forEach((role) => member.addRole(role.id));
await rolesToRemove.forEach((role) => member.removeRole(role.id));
rolesToAdd.forEach((role) => member.addRole(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('`, `')}\`` : ''}`);
} catch (err) {
return this.client.util.handleError(err, message, this);