Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Conversation

@viniciusestevam
Copy link

@viniciusestevam viniciusestevam commented Oct 11, 2019

Closes #1006

@viniciusestevam viniciusestevam requested a review from a team October 11, 2019 19:48

async run ({ channel, member, author, t }, targetMember, role) {
const embed = new SwitchbladeEmbed(author)
await targetMember.addRole(role).then(modifiedMember => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever you use async/await, you don't have to use .then or .catch you can use the simple try/catch. Ex.:

try {
  await targetMember.addRole(role)
  // do other things
} catch (e) {
  // handle error
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just sent this change

if (!member.hasPermission('ADMINISTRATOR', false, true, false)) {
if (member.highestRole.comparePositionTo(role) <= 0) throw new CommandError(t('commands:giverole.roleAboveAuthors'))
if (member.highestRole.comparePositionTo(member.highestRole) <= 0) throw new CommandError(t('commands:giverole.roleBelow'))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This verification process should be made before adding the role to the target member.

And the condition in line 22 is non-sense, you are comparing member.highestRole to itself: member.highestRole.comparePositionTo(member.highestRole)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shit, I just changed the variable names and forgot this one lol.

@pedrofracassi
Copy link
Member

So, how's this going?

@metehus
Copy link
Member

metehus commented Feb 28, 2020

@davipatury re-review?

@moruzerinho6 moruzerinho6 added scope: commands New command(s) suggestion/addition status: waiting-for-review type: feature New feature labels Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

scope: commands New command(s) suggestion/addition status: waiting-for-review type: feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give Role Command

5 participants