Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, GatewayIntentBits, EmbedBuilder, PermissionsBitField, Permissions, MessageManager, Embed, Collection, Events } = require(`discord.js`);
- const fs = require('fs');
- const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
- const reactions = require('./Schemas.js/reactionjs');
- 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");
- (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.on(Events.MessageReactionAdd, async (reaction, user) => {
- if (!reaction.message.guildId) return;
- if (user.bot) return
- let cID = `<:${reaction.emoji.name}:${reaction.reaction.id}>`;
- if (!reaction.emoji.id) cID = reaction.emoji.name;
- const data = await reactions.findOne({ Guild: reaction.message.guildId, Message: reaction.message.id, Emoji: cID });
- if (!data) return;
- const guild = await client.guilds.cache.get(reaction.message.guildId);
- const member = await guild.members.cache.get(user.id)
- try {
- await member.roles.add(data.Role);
- } catch (e) {
- return;
- }
- });
- client.on(Events.MessageReactionRemove, async (reaction, user) => {
- if (!reaction.message.guildId) return;
- if (user.bot) return
- let cID = `<:${reaction.emoji.name}:${reaction.reaction.id}>`;
- if (!reaction.emoji.id) cID = reaction.emoji.name;
- const data = await reactions.findOne({ Guild: reaction.message.guildId, Message: reaction.message.id, Emoji: cID });
- if (!data) return;
- const guild = await client.guilds.cache.get(reaction.message.guildId);
- const member = await guild.members.cache.get(user.id)
- try {
- await member.roles.remove(data.Role);
- } catch (e) {
- return;
- }
- });
Add Comment
Please, Sign In to add comment