Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
132
0
Never
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.  
  4. let token = "|||"
  5.  
  6. const PersistentCollection = require("djs-collection-persistent");
  7. const configs = new PersistentCollection({name: 'configs'});
  8.  
  9. client.on('ready', () => {
  10.   console.log(`Logged in as ${client.user.tag}!`);
  11. });
  12.  
  13. client.on("guildCreate", guild => {
  14.   if(!configs.has(guild.id)) {
  15.     configs.set(guild.id, {prefix: "-", staff_role: "Admin"});
  16.   }
  17. });
  18.  
  19. client.on('message', msg => {
  20. if (msg.author.bot) return;
  21. if (!msg.guild) return;
  22.  
  23. // Loading the configuration for this guild
  24.   const conf = configs.get(msg.guild.id);
  25.   // Get prefix from conf, or default to static prefix
  26.   if(conf.prefix) {
  27.     prefix = conf.prefix;
  28.   } else {
  29.     prefix = "-";
  30.   }
  31.  
  32.   if (msg.content.startsWith(prefix + `help`)) {
  33.     const embed = new Discord.RichEmbed()
  34.     embed.addField("System", "[${prefix}help]() - Shows you this help menu\n[${prefix}setconf]() - Sets the config value of the guild this command is run in", true);
  35.     embed.setFooter("help | Kai", client.user.avatarURL)
  36.     embed.setTimestamp()
  37.     msg.channel.send({embed});
  38.   }
  39.  
  40.   if (msg.content.startsWith(prefix + `setconf`)) {
  41.       const args = msg.content.split(" ");
  42.     const key = args[0];
  43.     const value = args.shift(1).join(" ");
  44.     conf[key] = value;
  45.     confs.set(msg.guild.id, conf);
  46.       msg.channel.send(`:white_check_mark: The config value \`${key}\` was set to \`${value}\`.`)
  47.   }
  48.  
  49. });
  50.  
  51. client.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement