From fdb14602c3937316b46c3b9e1b0fdf8ec60a0879 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 25 May 2020 17:32:35 -0500 Subject: [PATCH] ah --- src/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index de3c39f..7daa88c 100755 --- a/src/index.js +++ b/src/index.js @@ -138,24 +138,24 @@ client.on("message", async message => { message.delete().catch(O_o=>{}); // And we get the bot to say the thing: return message.channel.send(sayMessage); - } - else { - return message.channel.send("Im sorry but we cant have nice things...") - }; +}; }; //////////////////////////////////////////////////////////////////////////////// if(command === "quote") { - const quotes = require(`${homedir}/quotes.json`); - const quoteadd = ""; - if(args[0].toLowerCase() === "add") { + let quotes = require(`${homedir}/quotes.json`); + var quoteadd = ""; + let selector = args[0].toLowerCase() + if(selector === "add") { quoteadd = args.shift(); quotes.quotes.push(quoteadd); JSON.stringify(quotes); - fs.createWriteStream(`${homedir}/quotes.json`, quotes, {emitClose: "true"}); - client.channels.get('712084662033580064').send(`${message.member} has submitted ${quoteadd} to the quote repository`); + fs.writeFile(`${homedir}/quotes.json`, JSON.stringify(quotes), (err) => { + return message.reply("Something went wrong"); + }); + client.channels.cache.get('712084662033580064').send(`${message.member} has submitted ${quoteadd} to the quote repository`); return message.reply("Quote added to repository"); }; - const number = quotes.quotes.length() + 1; + var number = quotes.quotes.length() + 1; let quotesend = Math.floor(Math.random() * (number - 0) + 0); return message.send(`\`\`\`${quotes.quotes[quotesend]}\`\`\``); };