Merge pull request #4 from Technicolor-creamsicle/dev

Dev
This commit is contained in:
Alex 2020-05-25 20:20:48 -05:00 committed by GitHub
commit d1749c7760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 18 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
node_modules/ node_modules/
.DS_Store .DS_Store

2
.replit Normal file
View File

@ -0,0 +1,2 @@
language = "nodejs"
run = "npm start"

View File

@ -20,7 +20,7 @@
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {
"test": "node ./src/index --TEST", "test": "node ./src/index --TEST",
"start": "npm install; node ./src/index.js" "start": "node ./src/index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

6
quotes.json Normal file
View File

@ -0,0 +1,6 @@
{
"quotes": [
"you can add quotes by running ?quote add <person> Quote goes here",
"tech,is,bad,at,sneezing"
]
}

View File

@ -142,24 +142,32 @@ client.on("message", async message => {
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if(command === "quote") { if(command === "quote") {
let quotes = require(`${homedir}/quotes.json`); let quotes = require(`../quotes.json`);
var quoteadd = ""; var quoteadd = "";
//try{
let selector = args[0].toLowerCase(); var selector;
if(selector === "add") { try{
args.shift(); selector = args[0].toLowerCase();
quotes.quotes.push(args.toString()); } catch (err) {
fs.writeFile(`${homedir}/quotes.json`, JSON.stringify(quotes), (err) => { var number = quotes.quotes.length + 1;
if (err) return message.reply("Something went wrong"); let quotesend = Math.floor(Math.random() * (number - 0) + 0);
client.channels.cache.get('712084662033580064').send(`${message.member } has submitted ${quoteadd} to the quote repository`); return message.channel.send(`${quotes.quotes[quotesend]}`);
return message.reply("Quote added to repository"); };
if(selector === "add") {
args.shift();
quoteadd = args;
quoteadd = quoteadd.toString();
quoteadd = quoteadd.replace(/,/g, " ");
quoteadd = quoteadd.replace(/ /g, ", "); quotes.quotes.push(quoteadd.toString());
fs.writeFile(`../quotes.json`, JSON.stringify(quotes), (err) => {
if (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");
}); });
}; }
//} catch (err) {}; else {
var number = quotes.quotes.length + 1; return message.reply("you can add quotes by running `?quote add <person> Quote goes here`");
let quotesend = Math.floor(Math.random() * (number)); };
return message.channel.send(`${quotes.quotes[quotesend]}`);
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (command === "version") { if (command === "version") {
return message.channel.send(`\`\`\`\ return message.channel.send(`\`\`\`\