izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Get roles from message #303

Closed clubby789 closed 5 years ago

clubby789 commented 5 years ago

How can I get roles of a user who sends a message? I can't see a way of getting a member object from the message. In extension to this, how can I check if a user has a specific role?

cloudrac3r commented 5 years ago

bot.channels[channelID].guild_id or event.d.guild_id → server ID
bot.servers[serverID].members[userID] → member object
bot.servers[serverID].members[userID].roles → array of role IDs
bot.servers[serverID].members[userID].roles.includes(target) → boolean

clubby789 commented 5 years ago

Thanks, worked!