diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2023-03-25 21:25:43 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2023-03-25 21:27:41 -0400 |
| commit | 1a7a627446edfeb270850f0ed15c9c8d604380b2 (patch) | |
| tree | 8435e5323ce8a81976cafe297a6c730b4f0695da /commands/quote.js | |
| parent | 85a8f11507c0fb74b67914090bdfe10c361b775e (diff) | |
| download | AleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.tar.gz AleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.tar.bz2 AleeBot-1a7a627446edfeb270850f0ed15c9c8d604380b2.zip | |
Now using sequelize; Minor tweaks; New activities
Diffstat (limited to 'commands/quote.js')
| -rw-r--r-- | commands/quote.js | 73 |
1 files changed, 17 insertions, 56 deletions
diff --git a/commands/quote.js b/commands/quote.js index 481cc9b..81f9142 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -17,72 +17,33 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * * *************************************/ -const mongo = require('../plugins/mongo'); -const quoteSchema = require('../schema/quote-schema'); module.exports.run = async (client, message, args) => { - if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); + const quoteDB = require('../models/quote'); const { MessageEmbed } = require('discord.js'); + let quoteID = args[0]; -// let NewQuote; -// let quo; - - let quoId; - let quoAuthor; - let quoAuthorImage; - let quoQuote; - let quoYear; - - if (args) { - await mongo().then(async (mongoose) => { - try { - const quote = await quoteSchema.findOne({quoteID: args[1], author: quoAuthor, authorImage: quoAuthorImage, quote: quoQuote, year: quoYear}) - /* - const embed = new MessageEmbed() - .setAuthor(quoAuthor, quoAuthorImage) - .setDescription(quoQuote) - .setColor('#1fd619') - .setFooter('- ' + quoYear); - - await message.channel.send({embeds:[embed]});*/ - console.log(quote); - } finally { - await mongoose.connection.close(); - } - }) - } else { - + if (quoteID === undefined) { + const quoteList = await quoteDB.findAll({ attributes: ['id'] }) + quoteID = Math.floor(Math.random() * (quoteList.length - 1)) + 1 } - /* + const quote = await quoteDB.findOne({ where: { id: quoteID } }) - function GetNewQuote(quoteNum = -1) { - NewQuote = new Discord.MessageEmbed(); - let quo = require('../storage/quotes.json').quotes + if (quote) { + const embed = new MessageEmbed() + .setAuthor({ name: quote.author, iconURL: quote.authorImage}) + .setDescription(quote.quote) + .setColor('#1fd619') + .setFooter('- ' + quote.year); - if (quoteNum === -1) { - quoteNum = Math.floor(Math.random() * 1000) % quo.length; - quo=quo[quoteNum]; - } - - const author = quo.author; - const authorImage = quo.authorImage; - const quote = quo.quote; - const year = quo.year; - const url = quo.url; - - NewQuote.setAuthor(author, authorImage); - NewQuote.setColor('#1fd619'); - NewQuote.setDescription(quote); - NewQuote.setFooter('- ' + year); - //NewQuote.setURL(url); - - return NewQuote; + await message.reply('Alright, here\'s your quote.') + await message.channel.send({embeds:[embed]}); + } else { + message.reply('Cannot find quote'); } - const newquote = GetNewQuote(); - message.reply('Alright, here\'s your quote.'); - await message.channel.send(newquote);*/ + }; exports.conf = { |
