Skip to content

Commit

Permalink
Merge pull request #279 from Kathund/Unverified-Role
Browse files Browse the repository at this point in the history
Unverified role
  • Loading branch information
Killermaschine88 authored Dec 28, 2024
2 parents 48cdee8 + 77abee1 commit 1add97b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"verification": {
"enabled": false,
"verifiedRole": "VERIFIED_ROLE_ID",
"unverifiedRole": "UNVERIFIED_ROLE_ID",
"removeVerificationRole": true,
"guildMemberRole": "GUILD_MEMBER_ROLE_ID",
"autoUpdater": true,
Expand Down
15 changes: 8 additions & 7 deletions src/discord/DiscordManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const StateHandler = require("./handlers/StateHandler.js");
const CommandHandler = require("./CommandHandler.js");
const config = require("../../config.json");
const Logger = require(".././Logger.js");
const path = require("node:path");
const fs = require("fs");

class DiscordManager extends CommunicationBridge {
Expand All @@ -24,7 +23,12 @@ class DiscordManager extends CommunicationBridge {
connect() {
global.imgurUrl = "";
global.client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});

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

const eventsPath = path.join(__dirname, "events");
const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith(".js"));

const eventFiles = fs.readdirSync("src/discord/events").filter((file) => file.endsWith(".js"));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
const event = require(`./events/${file}`);
event.once
? client.once(event.name, (...args) => event.execute(...args))
: client.on(event.name, (...args) => event.execute(...args));
Expand Down
18 changes: 18 additions & 0 deletions src/discord/events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// eslint-disable-next-line no-unused-vars
const { GuildMember } = require("discord.js");
const config = require("../../../config.json");

module.exports = {
name: "guildMemberAdd",
/**
* @param {GuildMember} member
*/
async execute(member) {
try {
if (member.user.bot || config.verification.enabled === false) return;
await member.roles.add(config.verification.unverifiedRole, "Updated Roles");
} catch (error) {
console.log(error);
}
},
};

0 comments on commit 1add97b

Please sign in to comment.