Skip to content

Commit 1add97b

Browse files
authored
Merge pull request #279 from Kathund/Unverified-Role
Unverified role
2 parents 48cdee8 + 77abee1 commit 1add97b

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

config.example.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"verification": {
105105
"enabled": false,
106106
"verifiedRole": "VERIFIED_ROLE_ID",
107+
"unverifiedRole": "UNVERIFIED_ROLE_ID",
107108
"removeVerificationRole": true,
108109
"guildMemberRole": "GUILD_MEMBER_ROLE_ID",
109110
"autoUpdater": true,

src/discord/DiscordManager.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const StateHandler = require("./handlers/StateHandler.js");
77
const CommandHandler = require("./CommandHandler.js");
88
const config = require("../../config.json");
99
const Logger = require(".././Logger.js");
10-
const path = require("node:path");
1110
const fs = require("fs");
1211

1312
class DiscordManager extends CommunicationBridge {
@@ -24,7 +23,12 @@ class DiscordManager extends CommunicationBridge {
2423
connect() {
2524
global.imgurUrl = "";
2625
global.client = new Client({
27-
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
26+
intents: [
27+
GatewayIntentBits.Guilds,
28+
GatewayIntentBits.GuildMessages,
29+
GatewayIntentBits.MessageContent,
30+
GatewayIntentBits.GuildMembers,
31+
],
2832
});
2933

3034
this.client = client;
@@ -48,12 +52,9 @@ class DiscordManager extends CommunicationBridge {
4852
client.commands.set(command.name, command);
4953
}
5054

51-
const eventsPath = path.join(__dirname, "events");
52-
const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith(".js"));
53-
55+
const eventFiles = fs.readdirSync("src/discord/events").filter((file) => file.endsWith(".js"));
5456
for (const file of eventFiles) {
55-
const filePath = path.join(eventsPath, file);
56-
const event = require(filePath);
57+
const event = require(`./events/${file}`);
5758
event.once
5859
? client.once(event.name, (...args) => event.execute(...args))
5960
: client.on(event.name, (...args) => event.execute(...args));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// eslint-disable-next-line no-unused-vars
2+
const { GuildMember } = require("discord.js");
3+
const config = require("../../../config.json");
4+
5+
module.exports = {
6+
name: "guildMemberAdd",
7+
/**
8+
* @param {GuildMember} member
9+
*/
10+
async execute(member) {
11+
try {
12+
if (member.user.bot || config.verification.enabled === false) return;
13+
await member.roles.add(config.verification.unverifiedRole, "Updated Roles");
14+
} catch (error) {
15+
console.log(error);
16+
}
17+
},
18+
};

0 commit comments

Comments
 (0)