Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const botconfig = require("./botconfig.json");
- const Discord = require("discord.js");
- const fs = require("fs");
- const bot = new Discord.Client({disableEveryone: true});
- bot.commands = new Discord.Collection();
- let coins = require("./coins.json");
- let xp = require("./xp.json");
- fs.readdir("./commands/", (err,files) => {
- if(err) console.log(err);
- let jsfile = files.filter(f => f.split(".").pop() === "js")
- if(jsfile.length <= 0 ){
- console.log("Couldn't find commands.");
- return;
- }
- jsfile.forEach((f, i) =>{
- let props = require(`./commands/${f}`)
- console.log(`${f} loaded!`);
- bot.commands.set(props.help.name, props);
- });
- })
- bot.on("ready", async () => {
- console.log(`${bot.user.username} is online!`);
- bot.user.setActivity("s.help for commands", {type: "WATCHING"});
- });
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- if(!message.content.startsWith(botconfig.prefix)) return;
- let prefix = botconfig.prefix;
- let messageArray = message.content.split(" ");
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- let commandfile = bot.commands.get(cmd.slice(prefix.length));
- if(commandfile) commandfile.run(bot,message,args);
- if(cmd === `${prefix}hello`){
- return message.channel.send("Hello!");
- }
- if(message.content === 'LOL') {
- message.channel.sendMessage("Zzz from Willa again isit");
- };
- if(!coins[message.author.id]){
- coins[message.author.id] = {
- coins : 0
- };
- }
- let coinAmt = Math.floor(Math.random() *15) + 1;
- let baseAmt = Math.floor(Math.random() *15) + 1;
- console.log(`${coinAmt} ; ${baseAmt}`)
- if(coinAmt === baseAmt){
- coins[message.author.id] = {
- coins: coins[message.author.id].coins + coinAmt
- };
- fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
- if (err) console.log(err)
- });
- let coinEmbed = new Discord.RichEmbed()
- }
- let xpAdd = Math.floor(Math.random() * 7) + 8;
- console.log(xpAdd);
- if(!xp[message.author.id]){
- xp[message.author.id] = {
- xp: 0,
- level: 1
- };
- }
- let curxp = xp[message.author.id].xp;
- let curlvl = xp[message.author.id].level;
- let nxtLvl = xp[message.author.id].level * 300;
- xp[message.author.id].xp = curxp + xpAdd;
- if(nxtLvl <= xp[message.author.id].xp){
- xp[message.author.id].level = curlvl +1;
- let lvlup = new Discord.RichEmbed()
- .setTitle("Level Up!")
- .setColor("#7142f4")
- .addField("New Level", curlvl + 1);
- message.channel.send(lvlup).then(msg => {msg.delete(3000)});
- }
- fs.writeFile("./xp.json", JSON.stringify(xp), (err) => {
- if(err) console.log(err)
- });
- console.log(`level is ${xp[message.author.id].level}`);
- });
- bot.login(botconfig.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement