DMing - Role check - discord.js 14

mail@pastecode.io avatar
unknown
plain_text
2 years ago
532 B
83
Indexable
const client = require('../index.js')

const testrole = "RoleID"
const guildId = "GuildID"

client.on("messageCreate", async message => {
    const { channel, author, content } = message;
    if (message.guild) return;
    if (author.bot) return;
    
    const guild = client.guilds.cache.get(guildId);
    const member = guild.members.cache.get(author.id);

    if (member._roles.includes(testrole)) {
        console.log("Member has role")
    } else {
        console.log("Member does not have role")
    }
});