Created
August 30, 2017 02:49
-
-
Save Jackzmc/c50c3cef180d2f7fcb31d0bbaeaeebb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const JsonDB = require('node-json-db'); | |
const db = new JsonDB('database.json',true,true); //to be moved to mysql/sqlite (have fun future self) | |
const settings = [ | |
{ | |
name:"prefix", | |
config_value:"prefix", | |
help:"Can be any characters except (to be filled in), maximum of 5 characters.\nYou may disable prefix, you will have to @mention bot", | |
boolean:false, | |
exec: (msg,args,config) => { | |
//args[1] IS filled: | |
if(args[1].length > 5) return msg.channel.send("Value must be less than 5 characters") | |
return msg.channel.send("Prefix set to " + args[1] + " from " + config.prefix); | |
} | |
} | |
]; | |
exports.run = (client,msg,args) => { | |
if(!client.permCheck(msg.member,msg.guild) > 0) { | |
return msg.channel.send("You don't have permission for this!"); | |
} | |
if(!args[0] || args[0].toLowerCase() === "help") { | |
if(!args[1]) return msg.channel.send("This is a help command. No args sent"); | |
for(var i=0;i<settings.length;i++) { | |
if(settings[i].name === args[1].toLowerCase()) { | |
return msg.channel.send({embed:{title:`Help for ${settings[i].name}`,description:`${settings[i].help}`}}); | |
break; | |
} | |
} | |
return msg.channel.send("The setting ``" + args[0] + "`` doesn't exist, or no help exists"); | |
} | |
const server_config = db.getData(`/servers/${msg.guild.id}`) | |
for(var i=0;i<settings.length;i++) { | |
if(settings[i].name === args[0].toLowerCase()) { | |
if(!args[1]) return msg.channel.send({embed:{title:`Value for ${settings[i].name}`,description:`${server_config[settings[i].config_value]}`}}); | |
return settings[i].exec(msg,args,server_config); | |
} | |
} | |
return msg.channel.send("The setting ``" + args[0] + "`` doesn't exist."); | |
}; | |
exports.config = { | |
enabled: true, | |
permLevel: 0 | |
}; | |
exports.help = { | |
name: "config", | |
aliases:[], | |
description: "Configure the bot for your server", | |
usage:"config <help/blah>" | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment