aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands/quote.js
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-03 11:42:27 -0500
committerAndrew Lee <andrew@alee14.me>2025-03-03 11:42:27 -0500
commitfd7f8eba960981482fabf350995bf753feebb176 (patch)
tree2bd0c85b09a04ecd8e1f20fc409eb4b8a22289a7 /bot/src/commands/quote.js
parentcf1382d88c5e3298923c8cb243b7bc5751e68b53 (diff)
downloadAleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.gz
AleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.bz2
AleeBot-fd7f8eba960981482fabf350995bf753feebb176.zip
More commands ported; Almost all 2.x features have been added
Diffstat (limited to 'bot/src/commands/quote.js')
-rw-r--r--bot/src/commands/quote.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js
new file mode 100644
index 0000000..eaac975
--- /dev/null
+++ b/bot/src/commands/quote.js
@@ -0,0 +1,35 @@
+import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
+import { quote as quoteDB } from '../models/quote.js';
+export default {
+ data: new SlashCommandBuilder()
+ .setName('quote')
+ .setDescription('It gives you a quote.')
+ .addNumberOption(option =>
+ option
+ .setName('id')
+ .setDescription('Enter the quote ID to get a specific quote.')),
+ async execute(interaction) {
+ let quoteID = interaction.options.getNumber('id');
+
+ if (!quoteID) {
+ const quoteList = await quoteDB.findAll({ attributes: ['id'] });
+ const random = crypto.getRandomValues(new Uint32Array(1));
+ quoteID = quoteList[random[0] % quoteList.length].id;
+ }
+
+ const quote = await quoteDB.findOne({ where: { id: quoteID } });
+
+ if (quote) {
+ let userSubmitter = await interaction.client.users.fetch(quote.submitter);
+ const quoteEmbed = new EmbedBuilder()
+ .setAuthor({ name: quote.author, iconURL: quote.authorImage })
+ .setDescription(quote.quote)
+ .setColor('#1fd619')
+ .setFooter({ text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}` });
+
+ return await interaction.reply({ embeds: [quoteEmbed] });
+ } else {
+ return await interaction.reply('Cannot find quote, specify the correct quote id.');
+ }
+ }
+};