SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const config = require('./config.json');
  3. const { token } = require('./token.json')
  4. const client = new Discord.Client();
  5. const fs = require('fs');
  6.  
  7. client.on('ready', () => {
  8.     console.log(`The bot is currently online as ${client.user.username}`)
  9. })
  10.  
  11. client.on('message', (message) => {
  12.     let prefixes = JSON.parse(fs.readFileSync('./prefixes.json', 'utf8'));
  13.  
  14.     if(!prefixes[message.guild.id]){
  15.         prefixes[message.guild.id] = {
  16.             prefixes: config.prefix
  17.         };
  18.     }
  19.  
  20.     let prefix = prefixes[message.guild.id].prefixes;
  21.    
  22.     let messageArray = message.content.split(" ");
  23.     let cmd = messageArray[0].slice(prefix.length);
  24.     let args = messageArray.slice(1);
  25.  
  26.     if (cmd === `prefix`){
  27.         if (!message.member.hasPermission('MANAGE_SERVER')) return message.channel.send("Oops! You are missing the following permission: **Manage Server**");
  28.  
  29.         if(!args[0]) return message.channel.send(`Current prefix is ${prefix}`);
  30.  
  31.         let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
  32.  
  33.         prefixes[message.guild.id] = {
  34.             prefixes: args[0]
  35.         };
  36.  
  37.         fs.writeFile("./prefixes.json", JSON.stringify(prefixes), (err) => {
  38.             if (err) console.log(err)
  39.         });
  40.  
  41.         message.channel.send(`Prefix is now set to ${args[0]}!`)
  42.     }
  43.    
  44.     if (cmd === `help`){
  45.         if(!args[0]) return message.channel.send("```HELP MENU (COMMANDS LIST)```\n\n`help`\n**Shows this menu**\n\n`prefix`\n**Changes the current prefix**\n\n`setup`\n**Runs the setup**")
  46.  
  47.         if(args[0] == "help") return message.channel.send("no")
  48.         if(args[0] == "prefix") return message.channel.send("**USAGE: ${prefix}prefix (your desired prefix)**\n**The current prefix is:** ${prefix}")
  49.         if(args[0] == "setup") return message.channel.send("**USAGE: ${prefix}setup**\n**After running setup, move the color roles all the way to the top.**")
  50.     }
  51. })
  52.  
  53. client.login(token);
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