-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (37 loc) · 1.09 KB
/
index.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
const { Client, GatewayIntentBits } = require("discord.js");
const { guildId, token } = require("./config.json");
const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildIntegrations,
];
const client = new Client({ intents });
let Guild;
let MemberRole;
client.on("ready", async () => {
console.log("discord ready");
Guild = client.guilds.resolve(guildId);
MemberRole = await Guild.roles.fetch("735280966783991808");
});
client.on("guildMemberUpdate", (oldMember, newMember) => {
if (oldMember.guild.id == guildId) {
if (oldMember.pending && !newMember.pending) {
try {
newMember.roles
.add(MemberRole)
.then(() => {
console.log("added member role to", newMember.displayName);
})
.catch((err) => {
console.log("failed to add member role to", newMember.displayName);
console.log(err);
});
} catch (e) {
console.log(e);
}
}
}
});
client.login(token);