SHARE
TWEET

Bot

a guest Feb 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord =  require('discord.js');
  2. const bot = new Discord.Client;
  3. const token = "NTM3Mzc5ODkwODc0Mjg2MDgx.DylKPQ.5aHAzfjqdr-0sBt-7ImNMvp4B9o";
  4. const prefix = ">";
  5. const fs = require('fs');
  6.  
  7. bot.on('message', message => {
  8.     if (!message.content.startsWith(prefix) || message.author.bot) return;
  9.  
  10.     let sender = message.author;
  11.     let msg = message.content.toUpperCase();
  12.  
  13.  
  14.     let userData = JSON.parse(fs.readFileSync('Storage/userData.json', 'utf8'));
  15.  
  16.     if(!userData[sender.id + message.guild.id]) userData[sender.id + message.guild.id] = {}
  17.     if(!userData[sender.id + message.guild.id].money) userData[sender.id + message.guild.id].money = 1000;
  18.     if(!userData[message.guild.id]) userData[message.guild.id] = {}
  19.     if(!userData[message.guild.id].Confederates) userData[message.guild.id].Confederates = 0;
  20.     if(!userData[message.guild.id].Unions) userData[message.guild.id].Unions = 0;
  21.  
  22.    
  23.  
  24.     if(message.content == prefix + "Hello, ConfediUnion!"){
  25.         message.reply("Hello!");
  26.         var emoji = "👋";
  27.         message.react(emoji);
  28.     }
  29.  
  30.     if(message.content == prefix + "subscribe" || message.content == prefix + "Subscribe"){
  31.         let role = message.guild.roles.find(r => r.name == "Subscriber");
  32.         if(!message.member.roles.has(role)){
  33.             message.member.addRole(role);
  34.  
  35.             const subscribe = new Discord.RichEmbed()
  36.                 .setDescription("Thanks for being a sub! ;)")
  37.                 .setColor(0x00AE86)
  38.                 .setImage(message.member.user.avatarURL)
  39.             message.member.send(subscribe);
  40.         }
  41.     }    
  42.  
  43.     if(message.content == prefix + "Money" || message.content == prefix + "money"){
  44.        message.channel.send({embed:{
  45.            title: "Balance",
  46.            color:0xF1C40F,
  47.            fields:[{
  48.                name:"Account Holder",
  49.                value:message.author.username,
  50.                inline:true
  51.            },
  52.             {
  53.                 name:"Account Balance",
  54.                 value:userData[sender.id + message.guild.id].money,
  55.                 inline:true
  56.             }]
  57.        }})
  58.     }
  59.  
  60.     if(message.content == prefix + "sendC" || message.content == prefix + "SendC" && !message.member.roles.has("name", "Union")){
  61.        
  62.        
  63.            
  64.            
  65.        
  66.  
  67.         if(!userData[sender.id + message.guild.id].money >= 100) return message.channel.send(":x: You must have $100 to fund the Confederate Army.");
  68.            
  69.        
  70.  
  71.         if(message.member.roles.has("name", "Confederate") && userData[sender.id + message.guild.id].money >= 100){
  72.             userData[sender.id + message.guild.id].money = userData[sender.id + message.guild.id].money - 100;
  73.             userData[message.guild.id].Confederates = userData[message.guild.id].Confederates + 10
  74.  
  75.             var confedEmbed = new Discord.RichEmbed()
  76.                 .setDescription("10 confederate units deployed. Use `>stats` to find all deployed units.")
  77.                 .setColor(0x44b3e7)
  78.                 .setFooter("Bot created by ★彡 [FerretCode] 彡★#6783")
  79.             message.channel.send(confedEmbed);
  80.         }else{
  81.             message.channel.send(":angry: You Union scum, trying to sneak into our front lines! Get out of my sight!");
  82.             return
  83.         }
  84.     }
  85.  
  86.     if(message.content == prefix + "sendU" || message.content == prefix + "SendU" && !message.member.roles.has("name", "Confederate")){                    
  87.                      
  88.        
  89.  
  90.         if(!userData[sender.id + message.guild.id].money >= 100) return message.channel.send(":x: You must have $100 to fund the Union Army.");
  91.            
  92.            
  93.        
  94.  
  95.         if(message.member.roles.has("name", "Union") && userData[sender.id + message.guild.id].money >= 100){
  96.             userData[sender.id + message.guild.id].money = userData[sender.id + message.guild.id].money - 100;
  97.             userData[message.guild.id].Unions = userData[message.guild.id].Unions + 10
  98.            
  99.             var unionEmbed = new Discord.RichEmbed()
  100.                 .setDescription("10 union units deployed. Use `>stats` to find all deployed units.")
  101.                 .setColor(0x44b3e7)
  102.                 .setFooter("Bot created by ★彡 [FerretCode] 彡★#6783")
  103.             message.channel.send(unionEmbed);
  104.         }else{
  105.             message.channel.send(":angry: You Confederate scum, trying to sneak into our front lines! Get out of my sight!");
  106.             return
  107.         }
  108.     }
  109.  
  110.     if(message.content == prefix + "Stats" || message.content == prefix + "stats"){
  111.         var statsEmbed = new Discord.RichEmbed()
  112.             .setColor(0xc944e7)
  113.             .setDescription("Current stats of both armies:")
  114.             .setFooter("Bot created by ★彡 [FerretCode] 彡★#6783")
  115.             .addField("Confederate units deployed:", ` ${userData[message.guild.id].Confederates}`)
  116.             .addField("Union units deployed:", ` ${userData[message.guild.id].Unions}`)
  117.         message.channel.send(statsEmbed)
  118.     }
  119.  
  120.  
  121.     fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) => {
  122.         if(err) console.error(err);
  123.       })
  124. });
  125.  
  126. bot.on('ready', () => {
  127.   console.log("launched");
  128. })
  129.  
  130. bot.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