aboutsummaryrefslogtreecommitdiff
path: root/commands/quote.js
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-02-25 23:15:04 -0500
committerGitHub <noreply@github.com>2025-02-25 23:15:04 -0500
commit44f7f14736aaf77858ee71c80abeb3c13343d3c2 (patch)
tree47dc895e50fa95b52a894bf0806e1a6c1edc8818 /commands/quote.js
parent9519602e73a53931be10438dcd990becea7989d9 (diff)
parent5777f96394444dab18a81d6f085ac81df3e62008 (diff)
downloadAleeBot-44f7f14736aaf77858ee71c80abeb3c13343d3c2.tar.gz
AleeBot-44f7f14736aaf77858ee71c80abeb3c13343d3c2.tar.bz2
AleeBot-44f7f14736aaf77858ee71c80abeb3c13343d3c2.zip
Merge pull request #36 from Alee14/beta
2.13 Release
Diffstat (limited to 'commands/quote.js')
-rw-r--r--commands/quote.js74
1 files changed, 33 insertions, 41 deletions
diff --git a/commands/quote.js b/commands/quote.js
index 9aa9be0..f19675f 100644
--- a/commands/quote.js
+++ b/commands/quote.js
@@ -1,7 +1,7 @@
-/****************************************
- *
+/** **************************************
+ *
* Quote: Command for AleeBot
- * Copyright (C) 2017-2020 Alee Productions
+ * Copyright (C) 2017-2021 Alee Productions
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,51 +15,43 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ *
* *************************************/
-module.exports.run = async (client, message) => {
-const Discord = require('discord.js');
-
-let NewQuote;
+module.exports.run = async (client, message, args) => {
+ const { quote: quoteDB } = require('../models/quote');
+ const { MessageEmbed } = require('discord.js');
+ let quoteID = args[0];
- function GetNewQuote(quoteNum = -1) {
- NewQuote = new Discord.RichEmbed();
-
- let quo = require('../storage/quotes.json').quotes;
+ if (quoteID === undefined) {
+ const quoteList = await quoteDB.findAll({ attributes: ['id'] })
+ const random = crypto.getRandomValues(new Uint32Array(1));
+ quoteID = quoteList[random[0] % quoteList.length].id;
+ }
- if (quoteNum == -1) {
- quoteNum = Math.floor(Math.random() * 1000) % quo.length;
- quo=quo[quoteNum];
- }
+ const quote = await quoteDB.findOne({ where: { id: quoteID } })
- const author = quo.author;
- const authorImage = quo.authorImage;
- const quote = quo.quote;
- const year = quo.year;
- const url = quo.url;
+ if (quote) {
+ const quoteEmbed = new MessageEmbed()
+ .setAuthor({ name: quote.author, iconURL: quote.authorImage })
+ .setDescription(quote.quote)
+ .setColor('#1fd619')
+ .setFooter(`- ${quote.year}\nSubmitted by ${quote.submitter}`);
- NewQuote.setAuthor(author, authorImage);
- NewQuote.setColor('#1fd619');
- NewQuote.setDescription(quote);
- NewQuote.setFooter('- ' + year);
- NewQuote.setURL(url);
+ await message.reply({ embeds: [quoteEmbed] })
+ } else {
+ message.reply('Cannot find quote, specify the correct quote id.');
+ }
- return NewQuote;
- }
- const newquote = GetNewQuote();
- message.reply('Alright, here\'s your quote.')
- message.channel.send(newquote);
};
exports.conf = {
- aliases: [],
- guildOnly: false,
- };
- exports.help = {
- name: 'quote',
- description: 'Tells you quotes',
- usage: 'quote',
- category: '- Quote Commands',
- };
- \ No newline at end of file
+ aliases: [],
+ guildOnly: false,
+};
+exports.help = {
+ name: 'quote',
+ description: 'Tells you quotes',
+ usage: 'quote',
+ category: '- Quote Commands',
+};