iesswl

Discord Bot JSON

Aug 18th, 2019
347
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. const auth = require('./auth.json');
  4.  
  5. const fs = require('fs');
  6. const prefix = "/";
  7. client.rep = require('./data.json');
  8.  
  9.  
  10. client.on('ready', () => {
  11.   console.log(`Logged in as ${client.user.tag}!`);
  12.   client.user.setActivity('Sea of Thieves');
  13. });
  14.  
  15. client.on('message', message => {
  16.  
  17.   if (message.content.startsWith(prefix + "rep")) {
  18.     editedmessage = message.content.slice (4);
  19.  
  20.     client.rep [message.author.id] = {
  21.       message: editedmessage
  22.     }
  23.  
  24.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  25.       if(err) throw err;
  26.       message.channel.send ("Your reputation has been updated");
  27.     });
  28.   }
  29.  
  30.   else if (message.content.startsWith(prefix + "update Sea Dogs")) {
  31.     seadogsinput = message.content.slice (16);
  32.  
  33.     client.rep [message.author.id] = {
  34.       message: editedmessage,
  35.       seadogs: seadogsinput
  36.     }
  37.  
  38.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  39.       if(err) throw err;
  40.       message.channel.send ("Your Sea Dogs reputation has been updated");
  41.     });
  42.   }
  43.  
  44.   else if (message.content.startsWith(prefix + "update Hunter's Call")) {
  45.     hunterscallinput = message.content.slice (21);
  46.  
  47.     client.rep [message.author.id] = {
  48.       message: editedmessage,
  49.       seadogs: seadogsinput,
  50.       hunterscall: hunterscallinput
  51.     }
  52.  
  53.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  54.       if(err) throw err;
  55.       message.channel.send ("Your Hunter's Call reputation has been updated");
  56.     });
  57.   }
  58.  
  59.   else if (message.content.startsWith(prefix + "update Gold Hoarders")) {
  60.     goldhoardersinput = message.content.slice (21);
  61.  
  62.     client.rep [message.author.id] = {
  63.       message: editedmessage,
  64.       seadogs: seadogsinput,
  65.       hunterscall: hunterscallinput,
  66.       goldhoarders: goldhoardersinput
  67.     }
  68.  
  69.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  70.       if(err) throw err;
  71.       message.channel.send ("Your Gold Hoarders reputation has been updated");
  72.     });
  73.   }
  74.  
  75.   else if (message.content.startsWith(prefix + "update Order of Souls")) {
  76.     orderofsoulsinput = message.content.slice (22);
  77.  
  78.     client.rep [message.author.id] = {
  79.       message: editedmessage,
  80.       seadogs: seadogsinput,
  81.       hunterscall: hunterscallinput,
  82.       goldhoarders: goldhoardersinput,
  83.       orderofsouls: orderofsoulsinput
  84.     }
  85.  
  86.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  87.       if(err) throw err;
  88.       message.channel.send ("Your Order of Souls reputation has been updated");
  89.     });
  90.   }
  91.  
  92.   else if (message.content.startsWith(prefix + "update Merchant Alliance")) {
  93.     merchantallianceinput = message.content.slice (25);
  94.  
  95.     client.rep [message.author.id] = {
  96.       message: editedmessage,
  97.       seadogs: seadogsinput,
  98.       hunterscall: hunterscallinput,
  99.       goldhoarders: goldhoardersinput,
  100.       orderofsouls: orderofsoulsinput,
  101.       merchantalliance: merchantallianceinput
  102.     }
  103.  
  104.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  105.       if(err) throw err;
  106.       message.channel.send ("Your Merchant Alliance reputation has been updated");
  107.     });
  108.   }
  109.  
  110.   else if (message.content.startsWith(prefix + "update Athena's Fortune")) {
  111.     athenainput = message.content.slice (24);
  112.  
  113.     client.rep [message.author.id] = {
  114.       message: editedmessage,
  115.       seadogs: seadogsinput,
  116.       hunterscall: hunterscallinput,
  117.       goldhoarders: goldhoardersinput,
  118.       orderofsouls: orderofsoulsinput,
  119.       merchantalliance: merchantallianceinput,
  120.       athena: athenainput
  121.     }
  122.  
  123.     fs.appendFile("./data.json", JSON.stringify(client.rep, null, 4), err => {
  124.       if(err) throw err;
  125.       message.channel.send ("Your Athena's Fortune reputation has been updated");
  126.     });
  127.   }
  128.  
  129.   if (message.content.startsWith (prefix + "showrep")) {
  130.     let _message = client.rep[message.author.id].message;
  131.     let _seadogslevel = client.rep[message.author.id].seadogs;
  132.     let _hunterscalllevel = client.rep[message.author.id].hunterscall;
  133.     let _goldhoarderslevel = client.rep[message.author.id].goldhoarders;
  134.     let _orderofsoulslevel = client.rep[message.author.id].orderofsouls;
  135.     let _merchantalliancelevel = client.rep[message.author.id].merchantalliance;
  136.     let _athenalevel = client.rep[message.author.id].athena;
  137.  
  138.     var embed = new Discord.RichEmbed()
  139.       .setTitle(message.author.username + ", your Sea of Thieves reputation")
  140.       .setDescription('some description')
  141.       .setThumbnail(message.author.displayAvatarURL)
  142.       .addField('Gamer Tag', _message)
  143.       .addField('Sea Dogs', _seadogslevel, true)
  144.       .addField('Hunter\'s Call', _hunterscalllevel, true)
  145.       .addField('Gold Hoarders', _goldhoarderslevel, true)
  146.       .addField('Order of Souls', _orderofsoulslevel, true)
  147.       .addField('Merchant Alliance', _merchantalliancelevel, true)
  148.       .addField('Athena\'s Fortune', _athenalevel, true)
  149.       .setColor('#0x5fafaf')
  150.      
  151.     message.channel.send (embed);
  152.   }
  153.  
  154. });
  155.  
  156. client.login(auth.token);
Advertisement
Add Comment
Please, Sign In to add comment