DudeThatsErin

index.js

Apr 30th, 2021
651
18 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. client.commands = new Discord.Collection();
  4. const fs = require('fs');
  5. const config = require('./config.json');
  6. client.login(config.token);
  7. const connection = require('./database');
  8.  
  9. // Will delete
  10. const Enmap = require("enmap");
  11. client.points = new Enmap("points");
  12.  
  13. const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
  14.  
  15. for (const file of commandFiles) {
  16.     console.log(file.slice(0, -3));
  17.     const command = require(`./commands/${file.slice(0, -3)}`)
  18.     client.commands.set(command.name, command);
  19.  
  20. }
  21.  
  22. client.on('ready', () => {
  23.     console.log(`logged in as ${client.user.tag}!`);
  24.  
  25.     client.user.setPresence({
  26.         status: "online",
  27.         activity: {
  28.             name: `!help`,  
  29.             type: "LISTENING"
  30.         }
  31.       });
  32. });
  33.  
  34. client.on('message', async message => {
  35.     if (!message.content.startsWith(config.prefix) || message.author.bot) return;
  36.     const args = message.content.slice(config.prefix.length).trim().split(/ + /);
  37.     const commandName = args.shift().toLowerCase();
  38.  
  39.     const command = client.commands.get(commandName)
  40.         || client.commands.find(command => command.aliases && command.aliases.includes(commandName));
  41.     if (!command) return;
  42.  
  43.     if (!message.guild) return;
  44.     if (command.guildOnly && message.channel.type !== 'text') {
  45.         return message.reply('I can\'t execute that command inside DMs!');
  46.     }
  47.  
  48.  
  49.     if (command.args && args.length) {
  50.         let reply = `You didn't provide any arguments, ${message.author}!`;
  51.  
  52.         if (command.usage) {
  53.             reply += `\nThe proper usage would be: \`${config.prefix}${command.name} ${command.usage}\``;
  54.         }
  55.  
  56.         return message.channel.send(reply);
  57.     }
  58.  
  59.     try {
  60.         command.execute(message, args);
  61.     } catch (error) {
  62.         console.error(error);
  63.         message.reply('there was an error trying to execute that command!');
  64.     }
  65.  
  66. });
  67.  
  68.  
  69. client.on("messageReactionAdd", (reaction, user) => {
  70.     if(!user || user.bot || !reaction.message.channel.guild) {
  71.       return;
  72.     }
  73.     const msg = reaction.message;
  74.     const role = msg.channel.guild.roles.cache.find(role => role.name == "Participant");
  75.     // I would like to add the role to the user here.
  76.     reaction.message.guild.member(user).roles.add(role);
  77.  });
  78.  
  79.  client.on("messageReactionRemove", (reaction, user) => {
  80.     if(!user || user.bot || !reaction.message.channel.guild) {
  81.       return;
  82.     }
  83.     const msg = reaction.message;
  84.     const role = msg.channel.guild.roles.cache.find(role => role.name == "Participant");
  85.     // I would like to remove the role to the user here.
  86.     reaction.message.guild.member(user).roles.remove(role);
  87.  });
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×