SHARE
TWEET

Untitled

a guest Mar 24th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!Client) {
  2.     var { Client } = require("discord.js");
  3. }
  4. if (!client) {
  5.     var client = new Client();
  6. }
  7. if (!fs) {
  8.     var fs = require("fs");
  9. }
  10. try {
  11.     require("autorole.json");
  12. } catch (error) {
  13.     fs.writeFileSync("autorole.json", "{}");
  14. }
  15. if (!data) {
  16.     var data = require("autorole.json");
  17. }
  18. client.on("message", async function (msg) {
  19.     if (!msg.author.bot) {
  20.         if (!prefix) {
  21.             var prefix = "-";
  22.         }
  23.         if (msg.content.startsWith(prefix)) {
  24.             var args = msg.content.slice(prefix.length).split(" ");
  25.             var command = args[0];
  26.             switch(command) {
  27.                 case "autorole":
  28.                     if (!msg.guild) return msg.reply("Nah");
  29.                     if (!msg.member.hasPermission("MANAGE_ROLES")) return msg.reply("You don't have enough permissions");
  30.                     if (!args[1]) return msg.reply("please mention the role");
  31.                     var role = msg.guild.roles.get(args[1]) || msg.mentions.roles.first() || msg.guild.roles.find(role => role.name.includes(args.slice(1).split(" "))) || msg.guild.roles.filter(role => role.name.includes(args.slice(1).split(" "))).first();
  32.                     if (!role) return msg.reply("please mention the role");
  33.                     data[msg.guild.id] = role.id;
  34.                 break;
  35.             }
  36.         }
  37.     }
  38. })
  39. .on("guildMemberAdd", async function (member) {
  40.     if (data[member.guild.id]) {
  41.         if (member.guild.roles.get(data[member.guild.id])) {
  42.             try {
  43.                 member.addRole(member.guild.roles.get(data[member.guild.id]));
  44.             } catch (error) {
  45.                 console.error(error);
  46.             }
  47.         }
  48.     }
  49. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top