forked from valibaux/vorp_whitelist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord.js
44 lines (36 loc) · 1.3 KB
/
discord.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @author Nolosha Roleplay
* @license MIT
* Fuck Lawless.
*/
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });
client.login(config.token);
client.once('ready', () => {
console.log("Discord Client ready");
});
function checkDiscordPerms(discordId, deferrals) {
// Getting Discord Guild
let guild = client.guilds.resolve(config.guild);
// Checking if member exists in guild
return guild.members.fetch({user: discordId, force: true})
.then(member => {
let isWhitelisted = false;
if (config.checkRole) {
// Checking if member has one of the whitelisted roles
config.roles.forEach(role => {
if (member.roles.cache.has(role)) {
isWhitelisted = true;
}
});
}
if (config.checkRole && !isWhitelisted) {
deferrals.done("You're not whitelisted!");
} else {
deferrals.done();
}
})
.catch(err => {
deferrals.done("You're not whitelisted, join the discord at: https://discord.gg/syncounty");
});
}