const { Client, ActivityType, GatewayIntentBits, Partials, Collection, MessageActionRow, EmbedBuilder} = require('discord.js'); const fs = require('fs'); const welcome = require('./Schema/welcomeSchema'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.AutoModerationConfiguration, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.AutoModerationExecution, ], partials: [ Partials.GuildMember, Partials.Channel, Partials.GuildScheduledEvent, Partials.Message, Partials.Reaction, Partials.ThreadMember, Partials.User ] }); client.commands = new Collection(); require('dotenv').config(); const functions = fs.readdirSync("./src/functions").filter(file => file.endsWith(".js")); const eventFiles = fs.readdirSync("./src/events").filter(file => file.endsWith(".js")); const commandFolders = fs.readdirSync("./src/commands"); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; if (interaction.commandName === 'review-image') { await handleImageReviewInteraction(interaction); } }); (async () => { for (file of functions) { require(`./functions/${file}`)(client); } client.handleEvents(eventFiles, "./src/events"); client.handleCommands(commandFolders, "./src/commands"); client.login(process.env.token) })(); client.commands = new Collection(); client.on('ready', (c) => { console.log(`✅ ${c.user.tag} is online.`); client.user.setActivity({ name: '/help', type: ActivityType.Watching, }); }); client.on("guildMemberAdd", async (member) => { const data = await welcome.findOne({ Guild: member.guild.id, }); let logID; if (data) { logID = data.Channel; role = data.Role } else { return; } const row = new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("verify") .setLabel("Click Me To Verify") .setStyle(ButtonStyle.Success) ); const welcomeembed = new EmbedBuilder() .setImageUrl('https://media.discordapp.net/attachments/1145706779049738290/1215796693224788018/D_ServBan2.png?ex=662b89a8&is=662a3828&hm=07f9a67211ca5751ea7a6606a7f6276a7c8d7827cdfee87693cc7b7dd024b1ac&format=webp&quality=lossless&') .setTimestamp() .setDescription(`This server requires you to verify yourself to get access to other channels, you can simply verify by clicking on the verify button.`); const welcomechannel = client.channels.cache.get(logID); const msg = await welcomechannel.send({ embeds: [welcomeembed], components: [row], }); const collector = msg.createMessageComponentCollector(); collector.on("collect", async (i) => { if (i.customId === "verify") { await i.reply({ content: `Verified`, ephemeral: true }); member.roles.add(role); } }); }); client.login(process.env.TOKEN);