This commit is contained in:
Alex 2020-05-26 17:09:56 -05:00
parent c6fb55a097
commit 8a1bc2137b

View File

@ -142,9 +142,9 @@ client.on("message", async message => {
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if(command === "quote") { if(command === "quote") {
let quotes = require(`${homedir}/quotes.json`); let quotes = require(`${homedir}/quotes.json`);
var quoteadd = ""; var quoteadd = "";
var selector; var selector;
try{ try{
selector = args[0].toLowerCase(); selector = args[0].toLowerCase();
@ -155,11 +155,13 @@ client.on("message", async message => {
}; };
if(selector === "add") { if(selector === "add") {
args.shift(); args.shift();
quoteadd = args; //This does logic to make it from an array to a nice string.
quoteadd = quoteadd.toString(); quoteadd = args.join(' ');
quoteadd = quoteadd.replace(/,/g, " "); //quoteadd = quoteadd.toString();
quoteadd = quoteadd.replace(/ /g, ", "); //quoteadd = quoteadd.replace(/,/g, " ");
quotes.quotes.push(quoteadd.toString()); //quoteadd = quoteadd.replace(/ /g, ", ");
//quotes.quotes.push(quoteadd.toString());
quotes.quotes.push(quoteadd)
fs.writeFile(`${homedir}/quotes.json`, JSON.stringify(quotes), (err) => { fs.writeFile(`${homedir}/quotes.json`, JSON.stringify(quotes), (err) => {
if (err) return message.reply("Something went wrong");`` if (err) return message.reply("Something went wrong");``
client.channels.cache.get('712084662033580064').send(`${message.member} has submitted \`${quoteadd}\` to the quote repository`); client.channels.cache.get('712084662033580064').send(`${message.member} has submitted \`${quoteadd}\` to the quote repository`);