qeled / discordie

Predictable JavaScript abstractions for Discord API.
https://qeled.github.io/discordie/
BSD 2-Clause "Simplified" License
190 stars 45 forks source link

Check role(s) #43

Closed ghost closed 8 years ago

ghost commented 8 years ago

How do I check the role of a specific user?

I tried e.message.author.role but that wasn't right. It just returns undefined.

foxbot commented 8 years ago

https://qeled.github.io/discordie/#/docs/IGuildMember?p=IGuildMember%23roles&_k=3dslqq

read the fucking docs

ghost commented 8 years ago

I know there are the docs, but since I'm completely new to both DIscordie and JS, without any examples (at least that I could find) including .roles I am not completely sure on what to use .roles on.

Is it directly i.e. e.message.author.roles (it returns undefined for me) or is it something else?

arqunis commented 8 years ago

Firstly it's e.message.member.roles (member being IGuildMember). And "i am not completely sure on what to use .roles on" anything related to roles really or more or less

// outputs the names of my roles.
channel.sendMessage("Your roles are: " + member.roles.map(r => r.name).join(", ")); 

or even

const role = member.roles.find(r => r.name === "Bot Commander");
if (role) {} // do something with the role.
else {} // it doesn't exist on him.

or

const roleID = "some role id gotten from somewhere";
if (member.hasRole(roleID)) {} // he has it!
else {} // he doesn't have it. 
arqunis commented 8 years ago

Also can you atleast stop making so many issues about questions that could've been answered in the discordie channel in Discord API? (Link: https://discord.gg/wsEcz)

ghost commented 8 years ago

Thank you and sorry. I didn't know they had an official discord.