mirror of
https://github.com/Technicolor-creamsicle/Osselbot.git
synced 2024-11-19 10:45:54 -05:00
it works
This commit is contained in:
parent
3a84baa944
commit
275493b0f5
@ -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
6
quotes.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"quotes": [
|
||||||
|
"you can add quotes by running ?quote add <person> Quote goes here",
|
||||||
|
"tech,is,bad,at,sneezing"
|
||||||
|
]
|
||||||
|
}
|
33
src/index.js
33
src/index.js
@ -142,24 +142,31 @@ 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 = "";
|
||||||
|
var selector;
|
||||||
try{
|
try{
|
||||||
let selector = args[0].toLowerCase();
|
selector = args[0].toLowerCase();
|
||||||
if(selector === "add") {
|
} catch (err) {
|
||||||
args.shift();
|
|
||||||
quoteadd = args;
|
|
||||||
quotes.quotes.push(quoteadd.tostring());
|
|
||||||
fs.writeFile(`${homedir}/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) {};
|
|
||||||
var number = quotes.quotes.length + 1;
|
var number = quotes.quotes.length + 1;
|
||||||
let quotesend = Math.floor(Math.random() * (number - 0) + 0);
|
let quotesend = Math.floor(Math.random() * (number - 0) + 0);
|
||||||
return message.channel.send(`${quotes.quotes[quotesend]}`);
|
return message.channel.send(`${quotes.quotes[quotesend]}`);
|
||||||
|
};
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return message.reply("you can add quotes by running `?quote add <person> Quote goes here`");
|
||||||
|
};
|
||||||
};
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
if (command === "version") {
|
if (command === "version") {
|
||||||
|
Loading…
Reference in New Issue
Block a user