From fd7f8eba960981482fabf350995bf753feebb176 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 3 Mar 2025 11:42:27 -0500 Subject: More commands ported; Almost all 2.x features have been added --- bot/src/commands/quote.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bot/src/commands/quote.js (limited to 'bot/src/commands/quote.js') 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.'); + } + } +}; -- cgit v1.2.3