Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const client = new Discord.Client();
- let token = "|||"
- const PersistentCollection = require("djs-collection-persistent");
- const configs = new PersistentCollection({name: 'configs'});
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag}!`);
- });
- client.on("guildCreate", guild => {
- if(!configs.has(guild.id)) {
- configs.set(guild.id, {prefix: "-", staff_role: "Admin"});
- }
- });
- client.on('message', msg => {
- if (msg.author.bot) return;
- if (!msg.guild) return;
- // Loading the configuration for this guild
- const conf = configs.get(msg.guild.id);
- // Get prefix from conf, or default to static prefix
- if(conf.prefix) {
- prefix = conf.prefix;
- } else {
- prefix = "-";
- }
- if (msg.content.startsWith(prefix + `help`)) {
- const embed = new Discord.RichEmbed()
- 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);
- embed.setFooter("help | Kai", client.user.avatarURL)
- embed.setTimestamp()
- msg.channel.send({embed});
- }
- if (msg.content.startsWith(prefix + `setconf`)) {
- const args = msg.content.split(" ");
- const key = args[0];
- const value = args.shift(1).join(" ");
- conf[key] = value;
- confs.set(msg.guild.id, conf);
- msg.channel.send(`:white_check_mark: The config value \`${key}\` was set to \`${value}\`.`)
- }
- });
- client.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement