Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Need help] updateRole() incomprehension #107

Closed
ungarscool1 opened this issue Nov 24, 2017 · 7 comments
Closed

[Need help] updateRole() incomprehension #107

ungarscool1 opened this issue Nov 24, 2017 · 7 comments
Labels

Comments

@ungarscool1
Copy link

Hello,
I don't understand this function at updateRole(User user, Role Role[])
What is Role Role[] ?
My code server.updateRoles(message.getAuthor(), role.equals("Custom"));
Thanks to help me

@ungarscool1 ungarscool1 changed the title updateRole() incomprehension [Need help] updateRole() incomprehension Nov 24, 2017
@MythTheWolf
Copy link

Role[] is an array of Roles. This allows you to set multiple roles to a user

@ungarscool1
Copy link
Author

Okay, but my code is incorrect when i apply that
@SuppressWarnings({ "unchecked", "rawtypes" }) ArrayList<Role> role = new ArrayList(); role.add(Role[]); message.delete(); message.reply("GG à toi "+message.getAuthor().getMentionTag()+", tu as trouvé la phrase magique..."); server.updateRoles(message.getAuthor(), role[6]);
It's correct ?

@MythTheWolf
Copy link

No,that is not correct. When you supply a index to a array, [int], it represents the element of that position. You are trying to put a role object instead of the entire array. The correct way is updateRoles(author,role)

@MythTheWolf
Copy link

EDIT: Turn the list to an array first

@ungarscool1
Copy link
Author

So,

ArrayList<Role> role = new ArrayList();
role.add(6);
server.updateRoles(message.getAuthor(), role[]);

Or

ArrayList<Role> role = new ArrayList();
role.add(Role[6]);
server.updateRoles(message.getAuthor(), role[]);

It's correct? I think not...

@MythTheWolf
Copy link

No,you need to convert the ArrayList to an array. This is simple java

@ungarscool1
Copy link
Author

Oh, okay thanks you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants