#Discord DMs
1 messages · Page 1 of 1 (latest)
Just a Question, Since the user messaged the bot in DMs, Can the bot get the roles of the author?
I'm confused because lets say the bot is in multiple servers. How would I check for the Roles in a specific server?
have the user select the specific user
The specific server?
which one the bot should get the roles off of
async run(client, message, args) {
console.log(message.member)
message.author.send('Invite command works');
}
message.member.roles is undefined
So I know i have to Select the Specific Server and Then Get the roles of the author from that server.
Can you link me to the docs for this? Thank you
well, tell the users to give you the id of the guild since getting mutual servers would be a hassle
let guild = client.guilds.cache.get('SERVER-ID');
guild.members.fetch(message.author.id).then(async member => {
if (member.roles.cache.has('ROLE-ID')) {
message.channel.send('You already have the Holder Role!');
} else {
message.channel.send('You do not have the Holder Role!');
}
}).catch(err => {
console.log(err);
});
The user role does not update. I have to restart the server for it to take effect.
If the user has the Holder role and i remove it, the bot will still send You already have the Holder Role! even after removing it. I have to restart the server for it to take effect.
How do I fix it?
I just check if the message author is in the server or not. thats easier
if you already have a specific server you want to look in, sure