Advertisement
ulothar

Untitled

Jun 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.62 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const bot = new Discord.Client();
  3. const weather = require('weather-js'); //Make sure you call the packages you install.
  4. const fs = require('fs'); //But we also need to require the fs package.
  5. const Langs = ['afrikaans','albanian','amharic','arabic','armenian','azerbaijani','bangla','basque','belarusian','bengali','bosnian','bulgarian','burmese','catalan','cebuano','chichewa','chinese-simplified','chinese-traditional','corsican','croatian','czech','danish','dutch','english','esperanto','estonian','filipino','finnish','french','frisian','galician','georgian','german','greek','gujarati','haitian creole','hausa','hawaiian','hebrew','hindi','hmong','hungarian','icelandic','igbo','indonesian','irish','italian','japanese','javanese','kannada','kazakh','khmer','korean','kurdish (kurmanji)','kyrgyz','lao','latin','latvian','lithuanian','luxembourgish','macedonian','malagasy','malay','malayalam','maltese','maori','marathi','mongolian','myanmar (burmese)','nepali','norwegian','nyanja','pashto','persian','polish','portugese','punjabi','romanian','russian','samoan','scottish gaelic','serbian','sesotho','shona','sindhi','sinhala','slovak','slovenian','somali','spanish','sundanese','swahili','swedish','tajik','tamil','telugu','thai','turkish','ukrainian','urdu','uzbek','vietnamese','welsh','xhosa','yiddish','yoruba','zulu'];
  6. const translate = require('google-translate-api');
  7. const ms = require("ms");
  8. let warns = JSON.parse(fs.readFileSync("Storage/warnings.json", "utf8"));
  9.  
  10. //We can call the JSON file here
  11. const commands = JSON.parse(fs.readFileSync('Storage/commands.json', 'utf8'));
  12. //Bot settings - Global settings this file can use.
  13. const prefix = '!'; //This is the prefix, you can changeg it to whatever you want.
  14.  
  15. bot.msgs = require ("./Storage/msgs.json");
  16. let streams = JSON.parse(fs.readFileSync("./Storage/streams.json", "utf8"));
  17.  
  18.  
  19. //Listener Event: Runs whenever a message is received.
  20. bot.on('message', message => {
  21.  
  22. //Variables - Variables make it easy to call things, since it requires less typing.
  23. let msg = message.content.toUpperCase(); // This variable takes the messages, and turns it all into uppercase so it isn't case sensitive.
  24. let sender = message.author; // This variable takes the message, and finds who the author is.
  25. let cont = message.content.slice(prefix.length).split(" "); //This variable slices off the prefix then puts the rest in an array based off the spaces
  26. let args = cont.slice(1); //This slices off the command in a cont, only leaving the arguments.
  27.  
  28.  
  29. //time command
  30.  
  31. if (msg.startsWith(prefix + 'TIME')) {
  32. let timeZone = args[0];
  33. // if (timeZone === 'NEOPIA/STANDARD') timeZone = 'AMERICA/VANCOUVER';
  34. try {
  35. const time = new Date().toLocaleTimeString('en-US', {timeZone});
  36. return message.channel.send(`The current time in ${timeZone} is ${time}.`);
  37. } catch (err) {
  38. return message.channel.send('Invalid time zone. Refer to <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>.');
  39. }
  40. }
  41.  
  42. //Usefull links Command
  43. if (msg === prefix + 'LINKS') {
  44.  
  45. let linksEmbed = new Discord.RichEmbed()
  46. .setDescription("Useful LoA2 Links")
  47. .setColor("#e56b00")
  48. .addField("LoA2 GTA main Page: http://loa2.gtarcade.com/", "Main Page for LOA2")
  49. .addField("LoA2 Support Page: https://support.gtarcade.com/search?gid=160", "GTA Support Page for Tickets")
  50. .addField("LoA2 Facebook Page: https://www.facebook.com/LeagueOfAngels2/", "LOA2 Facebook Fanpage")
  51.  
  52. message.author.send(linksEmbed)
  53. }
  54.  
  55.  
  56. if (msg === prefix + 'LINKSA') {
  57.  
  58. let test = new Discord.RichEmbed()
  59. .setDescription("Streaming Info")
  60. .setColor("#e56b00")
  61. .addField("Streamer", "Ulothar GTA Sr Modr")
  62. .addField("Total Streams", "3")
  63. .addField("Total Duration", "270")
  64.  
  65. message.author.send(test)
  66. }
  67.  
  68.  
  69. //Ping Command
  70. if (msg === prefix + 'PING') { // This checks if msg (the message but in all caps), is the same as the prefix ++ the command in all caps
  71.  
  72. //Now, let's send a response.
  73. message.channel.send('Pong!'); // This 'sends' a ping
  74. }
  75.  
  76.  
  77. // mute starts here
  78. //!tempmute @user 1s/m/h/d
  79. if (msg.startsWith(prefix + 'MUTE')) {
  80. let muterole = message.guild.roles.find(`name`, "muted");
  81. let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  82. if(!muterole){ // we start creating a role for the muted people
  83. try{
  84. muterole = message.guild.createRole({ // we must create a role for the muted people
  85. name: "muted",
  86. color: "#000000",
  87. permissions:[]
  88. })
  89. message.guild.channels.forEach(async (channel, id) => {
  90. await channel.overwritePermission(muterole, {
  91. SEND_MESSAGES: false, // Muted people should not be able to send messages
  92. ADD_REACTIONS: false // Muted people should not be able to add reactions
  93. });
  94. });
  95. }catch(e){
  96. console.log(e.stack);
  97. }
  98. }
  99. //end of create role
  100. let mutetime = args[1];
  101. if(!mutetime) return message.reply("You didn't specify a time!");
  102.  
  103. tomute.addRole(muterole.id);
  104. message.reply(`<@${tomute.id}> has been muted for ${ms(mutetime)}`);
  105.  
  106. setTimeout(function(){
  107. tomute.removeRole(muterole.id);
  108. message.channel.send(`<@${tomute.id}> has been unmuted!`);
  109. }, ms(mutetime));
  110. }
  111. // end of module
  112. // mute ends here
  113. // Translator starts here
  114.  
  115. if (msg.startsWith(prefix + 'TRANSLATE')) {
  116.  
  117. let transArg = args[0];
  118.  
  119. args = args.join(' ').slice(prefix.length);
  120. let translation;
  121.  
  122. if (!Langs.includes(transArg)) return message.channel.send(`**There was an error. Command syntax is !translate <language> <text> .**`);
  123. args = args.slice(transArg.length);
  124.  
  125. translate(args, {to: transArg}).then(res => {
  126.  
  127. const embed = new Discord.RichEmbed()
  128. .setDescription(res.text)
  129. .setFooter(`english -> ${transArg}`)
  130. .setColor(`RANDOM`);
  131. return message.channel.send(embed);
  132. })
  133. }
  134.  
  135. // Translator ends here
  136.  
  137. // Test with new stuff starts here
  138. if (msg.startsWith(prefix + 'RUNESTONE TRANSMUTE')) {
  139. let thumbb = "https://image.ibb.co/fnJ5WJ/runestone.png"
  140. let runtranEmbed = new Discord.RichEmbed()
  141. .setDescription("Runestone Transmute Materials")
  142. .setAuthor(message.author.username)
  143. .setColor("#5858FA")
  144. .setThumbnail(thumbb)
  145. .addField("R1-2 ", "Min 31, Max 35")
  146. .addField("R2-3 ", "Min 67, Max 84")
  147. .addField("R3-4 ", "Min 151, Max 179")
  148. .addField("R4-5 ", "Min 290, Max 345")
  149. .addField("R5-6 ", "Min 521, Max 568")
  150. .addField("R6-7 ", "Min 962, Max 1.054")
  151. .addField("R7-8 ", "Min 1.766, Max 2.090")
  152. .addField("R8-9 ", "Min 3.002, Max 3.573")
  153. .addField("R8-9 ", "Min 5.439, Max 6.488")
  154. .addField("R9-10 ", "Min 5.349, Max 6.488")
  155. .addField("R10-11 ", "Min 8.470, Max 9.743")
  156. .addField("R11-12 ", "Min 11.797, Max 14.567")
  157. .addField("R12-13 ", "Min 15.500, Max 19.080")
  158. .addField("R13-14 ", "Min 19.842, Max 23.326")
  159. .addField("R14-15 ", "Min 24.661, Max 24.661")
  160. .addField("R15-16 ", "Min 30.622, Max 30.622")
  161. .addField("Total ", "Min 123.031, Max 136.415")
  162. .addField("Team ", "Min 615.155, Max 682.075")
  163.  
  164. message.author.send(runtranEmbed)
  165.  
  166. }
  167.  
  168. // test with new stuff ends here
  169. //Warn command starts here
  170. //!warn @user <reason>
  171. if (msg.startsWith(prefix + 'WARN')) {
  172. let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  173. if(!wUser) return message.reply("Couldn't find the user");
  174. if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("The user has permissions that avoid to be warned!");
  175. let reason = args.join(" ").slice(22);
  176.  
  177. if(!warns[wUser.id]) warns[wUser.id] = {
  178. warns: 0
  179. };
  180. warns[wUser.id].warns++;
  181.  
  182. fs.writeFile("Storage/warnings.json", JSON.stringify(warns), (err) => {
  183. if (err) console.log(err)
  184. });
  185.  
  186. let warnEmbed = new Discord.RichEmbed()
  187. .setDescription("Warns")
  188. .setAuthor(message.author.username)
  189. .setColor("#fc6400")
  190. .addField("Warned User", wUser)
  191. .addField("Warned In", message.channel)
  192. .addField("Number of Warnings", warns[wUser.id].warns)
  193. .addField("Reason", reason);
  194.  
  195. let warnchannel = message.guild.channels.find(`name`, "incidents");
  196. if(!warnchannel) return message.reply("Couldn't find channel");
  197.  
  198. warnchannel.send(warnEmbed);
  199.  
  200. if(warns[wUser.id].warns == 2){
  201. let muterole = message.guild.roles.find(`name`, "muted");
  202. if(!muterole) return message.reply("You should create that role first");
  203. let mutetime = "30s";
  204. wUser.addRole(muterole.id);
  205. message.channel.send(`<@${wUser.id}> has been temporarily muted`);
  206.  
  207. setTimeout(function(){
  208. wUser.removeRole(muterole.id);
  209. message.channel.send(`<@${wUser.id}> has been unmuted`);
  210. })
  211. }
  212. if(warns[wUser.id].warns == 3){
  213. message.guild.member(wUser).ban(reason);
  214. message.channel.send(`${wUser.tag} has been banned.`)
  215. }
  216.  
  217. }
  218.  
  219. //Warn Command Stop here
  220.  
  221. //Command Kick
  222. if (msg.startsWith(prefix + 'KICK')) { //This checks if msg has the prefix and the kick command right after. The syntax will be !kick @name <reason>
  223.  
  224. let kUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  225. if(!kUser) return message.channel.send("Can't find user!");
  226. let kReason = args.join(" ").slice(22);
  227. if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("No permissions for that command!"); //This checks the permissions for the user can change to whatever you want.
  228. if(kUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send("That person can't be kicked!"); //This option checks if the user to be kicked has MANAGE_MESSAGES permission and in this case he can't be kicked.
  229.  
  230.  
  231. let kickEmbed = new Discord.RichEmbed()
  232. .setDescription("~Kick~")
  233. .setColor("#e56b00")
  234. .addField("Kicked User", `${kUser} with ID ${kUser.id}`)
  235. .addField("Kicked By", `<@${message.author.id}> with ID ${message.author.id}`)
  236. .addField("Kicked in", message.channel)
  237. .addField("Time", message.createdAt)
  238. .addField("Reason", kReason)
  239.  
  240. let kickChannel = message.guild.channels.find(`name`, "incidents"); //This will post the kick message in the channel named Incidents you can change that.
  241. if(!kickChannel) return message.channel.send("Can't find incidents channel.");
  242.  
  243. message.guild.member(kUser).kick(kReason);
  244. kickChannel.send(kickEmbed);
  245. return;
  246.  
  247. }
  248. //Ban command start here
  249. if (msg.startsWith(prefix + 'BAN')) {
  250.  
  251. let bUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  252. if(!bUser) return message.channel.send("Can't find user!");
  253. let bReason = args.join(" ").slice(22);
  254. if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("No permissions for that command!"); //This checks the permissions for the user can change to whatever you want.
  255. if(bUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send("That person can't be kicked!"); //This option checks if the user to be kicked has MANAGE_MESSAGES permission and in this case he can't be kicked.
  256.  
  257.  
  258. let banEmbed = new Discord.RichEmbed()
  259. .setDescription("~Ban~")
  260. .setColor("#bc0000")
  261. .addField("Banned User", `${bUser} with ID ${bUser.id}`)
  262. .addField("Banned By", `<@${message.author.id}> with ID ${message.author.id}`)
  263. .addField("Banned in", message.channel)
  264. .addField("Time", message.createdAt)
  265. .addField("Reason", bReason)
  266.  
  267. let incidentChannel = message.guild.channels.find(`name`, "incidents"); //This will post the kick message in the channel named Incidents you can change that.
  268. if(!incidentChannel) return message.channel.send("Can't find incidents channel.");
  269.  
  270. message.guild.member(bUser).ban(bReason);
  271. incidentChannel.send(banEmbed);
  272. return;
  273. }
  274.  
  275. //Weather Command
  276. if (msg.startsWith(prefix + 'WEATHER')) { //This checks to see if the beginning of the message is calling the weather command.
  277. //you can find some of the code used here on the weather-js npm page in the description
  278.  
  279. weather.find({search: args.join(" "), degreeType: 'F'}, function(err, result) { // Make sure you get that args.join part, since it adds everything after weather.
  280. if (err) message.channel.send(err);
  281.  
  282. //We also want them to know if a place they enter is invalid.
  283. if (result.length === 0) {
  284. message.channel.send('**Please enter a valid location.**') //This tells them in chat that the place they entered is invalid.
  285. }
  286.  
  287. //Variables
  288. var current = result[0].current; //This is a variable for the current part of the JSON output
  289. var location = result[0].location; //This is a variable for the location part of the JSON output
  290.  
  291.  
  292. //Let's use an embed for this.
  293. const embed = new Discord.RichEmbed()
  294. .setDescription(`**${current.skytext}**`) //This is the text of what the sky looks like, remember you can find all of this on the weather-js npm page.
  295. .setAuthor(`Weather for ${current.observationpoint}`) //This shows the current location of the weather.
  296. .setThumbnail(current.imageUrl) //This sets the thumbnail of the embed.
  297. .setColor(0x00AE86) //This sets the color of the embed, you cna set this to anything if you look put a hex color picker, just make sure you put 0x infront of the hex
  298. .addField('Timezone',`UTC${location.timezone}`, true) //This is the first field, it shows the timezone, and the true means `inline`, you can read more about this on the official discord.js documentation
  299. .addField('Degree Type', location.degreetype, true) //This is the field that shows the degree type, and is inline
  300. .addField('Temperature',`${current.temperature} Degrees`, true)
  301. .addField('Feels Like', `${current.feelslike} Degrees`, true)
  302. .addField('Winds', current.winddisplay, true)
  303. .addField('Humidity', `${current.humidity}%`, true)
  304.  
  305. //Now, let's display it when called
  306. message.channel.send({embed}); //This posts the Current part of the First result.
  307. });
  308.  
  309. }
  310.  
  311. //Purge Command
  312. if (msg.startsWith(prefix + 'PURGE')) { // This time we have to use startsWith, since we will be adding a number to the end of the command.
  313. // We have to wrap this in an async since awaits only work in them.
  314. async function purge() {
  315. message.delete(); // Lets delete the command message, so it doesn't interfere with the messages we are going to delete.
  316.  
  317.  
  318.  
  319. // Now, we want to check if the user has the 'bot-commander' role, you can change this to whatever yo uwant.
  320. if(!message.member.roles.find("name", "bot-commander")) { // This checks to see if they DONT have it, the "!" inverts the true/false
  321. message.channel.send('You need the \`bot-commander\` role to use this command.'); //This tells the user in chat that they need the role.
  322. return; // this returns the code, so the rest doesn't run.
  323.  
  324. }
  325.  
  326. // we want ot check if the argument is a number
  327. if (isNaN(args[0])) {
  328. // sends a message to the channel.
  329. message.channel.send('Please use a number as your arguments. \n Usage: ' + prefix + 'purge <amount>'); //\n means new line.
  330. //Cancels out of the script, so the rest doesn't run.
  331. return;
  332. }
  333.  
  334. const fetched = await message.channel.fetchMessages({limit: args[0]}); //Tis grabs the last number(args) of messages in the channel.
  335. console.log(fetched.size + ' messages found, deleting...'); // lets post into console how many messages we are deleting
  336.  
  337. //Deleting the fetchMessages
  338. message.channel.bulkDelete(fetched)
  339. .catch(error => message.channel.send(`Error: ${error}`)); //If it finds an error, it post it into the channel.
  340.  
  341. }
  342.  
  343. //we want to make sure we call the function whenever the purge command is run.
  344. purge(); //make sure this is inside the if(msg.startsWith)
  345. //We also have two more things to do:
  346. //1) make sure their variable is a number
  347. //2) Limit only people you want to use the command
  348. }
  349.  
  350. //This is for help command. We will also add a category system for the commands, for example !help mod (shows moderator commands), !help admin (shows admin commands), as well as !help <command> shows more info
  351.  
  352. //Help Command
  353. if (msg.startsWith(prefix + 'HELP')) { //We're also going to use a seperate JSON file, so we need to call it.
  354.  
  355. //Let's see if the only thing they typed in chat was !help
  356. if (msg === `${prefix}HELP`) { //If they only type this, let's only show the commands for regular users
  357.  
  358. // Start of the embed
  359. const embed = new Discord.RichEmbed()
  360. .setColor(0x1D82B6) //You can set this color to whatever you want.
  361.  
  362. //Variables
  363. let commandsFound = 0; //We also want to tell them how many commands there are for that specific group.
  364.  
  365. //Lets create the for loop that loops through the commands
  366. for (var cmd in commands) { //we should start creating the commands json first.
  367.  
  368. //Checks if the group is "users"
  369. if (commands[cmd].group.toUpperCase() === 'USER') {
  370. //Lets also count commandsFound +1 every time it finds a command in the newGroup
  371. commandsFound++
  372. //LETS ADD THE COMMAND FIELD TO THE EMBED
  373. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); //This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
  374. }
  375.  
  376. }
  377.  
  378. //add some more to the EMBED
  379. embed.setFooter(`Currently showing user commands. To view another group do ${prefix}help [group / command]`)
  380. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
  381. //We can output it two ways 1 - send to DMs, and tell them that they sent to DMs in chat. 2 - Post commands in chat. [since commands take up a lot let's send to DMs]
  382. message.author.send({embed})
  383. //post in chat they sent to DMs
  384. message.channel.send({embed: {
  385. color: 0x1D8286,
  386. description: `**Check your DMs ${message.author}!**`
  387. }})
  388.  
  389. } else if (args.join(" ").toUpperCase() === 'GROUPS') {
  390.  
  391. //Variables
  392. let groups = '';
  393. for (var cmd in commands) {
  394. if (!groups.includes(commands[cmd].group)) {
  395. groups += `${commands[cmd].group}\n`
  396. }
  397.  
  398. }
  399. message.channel.send({embed: {
  400. description: `**${groups}**`,
  401. title:"Groups",
  402. color: 0x1D82B6,
  403.  
  404. }})
  405.  
  406. return;
  407.  
  408. }else {
  409. //Now lets do something when they do !help [cmd / group]
  410.  
  411. //Variables
  412. let groupFound = '';
  413. for (var cmd in commands) { //we should start creating the commands json first.
  414.  
  415. if (args.join(" ").trim().toUpperCase() === commands[cmd].group.toUpperCase()) {
  416. groupFound = commands[cmd].group.toUpperCase(); //Lets set the ground found, then break out of the loop.
  417. break;
  418. }
  419. }
  420. if (groupFound != '') { //If a group is found, run this statement.
  421.  
  422. // Start of the embed
  423. const embed = new Discord.RichEmbed()
  424. .setColor(0x1D82B6) //You can set this color to whatever you want.
  425.  
  426. //Variables
  427. let commandsFound = 0; //We also want to tell them how many commands there are for that specific group.
  428.  
  429. for (var cmd in commands) { //we should start creating the commands json first.
  430.  
  431. //Checks if the group is "users" and replace type with group
  432. if (commands[cmd].group.toUpperCase() === groupFound) {
  433. //Lets also count commandsFound +1 every time it finds a command in the newGroup
  434. commandsFound++
  435. //LETS ADD THE COMMAND FIELD TO THE EMBED
  436. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); //This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
  437. }
  438.  
  439. }
  440.  
  441. //add some more to the EMBED
  442. embed.setFooter(`Currently showing ${groupFound} commands. To view another group do ${prefix}help [group / command]`)
  443. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
  444. //We can output it two ways 1 - send to DMs, and tell them that they sent to DMs in chat. 2 - Post commands in chat. [since commands take up a lot let's send to DMs]
  445. message.author.send({embed})
  446. //post in chat they sent to DMs
  447. message.channel.send({embed: {
  448. color: 0x1D8286,
  449. description: `**Check your DMs ${message.author}!**`
  450. }})
  451.  
  452. //make sure you copy and paste into the right place, lets test it now!
  453. return; //we want to make sure we return so it doesn't run the rest of the script after it finds a group! lets test it
  454.  
  455. //Now lets show groups.
  456.  
  457. }
  458.  
  459. //although, if a group is not found, lets see if it is a command
  460. let commandFound = '';
  461. let commandDesc = '';
  462. let commandUsage = '';
  463. let commandGroup = '';
  464.  
  465. for (var cmd in commands) { //we should start creating the commands json first.
  466.  
  467. if (args.join(" ").trim().toUpperCase() === commands[cmd].name.toUpperCase()) {
  468. commandFound = commands[cmd].name; //Lets set the ground found, then break out of the loop. And not to uppcase this time
  469. commandDesc = commands[cmd].desc;
  470. commandUsage = commands[cmd].usage;
  471. commandGroup = commands[cmd].group;
  472. break;
  473. }
  474. }
  475.  
  476. //lets post in chat if nothing is found!
  477. if (commandFound === '') {
  478. message.channel.send({embed: {
  479. description: `"**No group or command found titled \`${args.join(" ")}\`**`,
  480. color: 0x1D8286,
  481.  
  482. }})
  483.  
  484.  
  485. }
  486. message.channel.send({embed: {
  487. title: '<> means required, [] means optional',
  488. color: 0x1D82B6,
  489. fields: [{
  490. name:commandFound,
  491. value:`**Description:** ${commandDesc}\n**Usage:** ${commandUsage}\n**Group ${commandGroup}`
  492. }]
  493. }})
  494. }
  495. }
  496. if (!streams[message.author.username]) streams[message.author.username] = {
  497. streams: 0,
  498. duration: 0,
  499. };
  500.  
  501. if (message.content.startsWith ("write")) {
  502. editeddate = message.content.slice (6, 16);
  503. editedtime = message.content.slice (17, 22);
  504. editedgame = message.content.slice (23, 27);
  505. editedduration = message.content.slice (28, 30);
  506. editedname = message.content.slice (31);
  507. currentdate = Date();
  508.  
  509.  
  510. bot.msgs [message.author.username] =
  511. signdate: currentdate,
  512. streamdate: editeddate,
  513. start: editedtime,
  514. game: editedgame,
  515. duration: editedduration,
  516. name: editedname
  517.  
  518. fs.writeFile ("./msgs.json", JSON.stringify (bot.msgs, null, 4), {flag: a}, err => {
  519. if (err) throw error
  520. message.channel.send ("message written");
  521. });
  522.  
  523. }
  524.  
  525. if (message.content.startsWith ("get")) {
  526. let _message = bot.msgs[message.author.username].duration;
  527. message.channel.send("Duration is: " + _message);
  528. }
  529.  
  530. });
  531.  
  532. //Listener Event: Runs whenever the bot sends a ready event (when it first starts for example)
  533. bot.on('ready', () => {
  534. //we can post into console that the bot launched.
  535. console.log('Bot started.')
  536. });
  537.  
  538. //We need to login also, this can be done using this
  539. bot.login('BLAH');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement