From c06c0be2e7520ceaf5284472d0d99c7417aceb7a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 20 Mar 2025 01:47:19 -0400 Subject: New command; New logging feature; QOTD (WIP) --- bot/src/plugins/qotd.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bot/src/plugins/qotd.js (limited to 'bot/src/plugins/qotd.js') diff --git a/bot/src/plugins/qotd.js b/bot/src/plugins/qotd.js new file mode 100644 index 0000000..a6ea73e --- /dev/null +++ b/bot/src/plugins/qotd.js @@ -0,0 +1,28 @@ +import { EmbedBuilder } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; +import { quote as quoteDB } from '../models/quote.js'; + +export async function QuoteOfTheDay(client) { + const channels = ['606602551634296968', '341669022179262464']; + const quoteList = await quoteDB.findAll({ attributes: ['id'] }); + const random = crypto.getRandomValues(new Uint32Array(1)); + + if (quoteList.length === 0) return console.log('[i] No quotes are currently in the database.'); + + let quoteID = quoteList[random[0] % quoteList.length].id; + + const quote = await quoteDB.findOne({ where: { id: quoteID } }); + + let userSubmitter = await client.users.fetch(quote.submitter); + + const quoteEmbed = new EmbedBuilder() + .setAuthor({ name: quote.author, iconURL: quote.authorImage }) + .setDescription(quote.quote) + .setColor(abEmbedColour) + .setFooter({ text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}` }); + + for (const channel of channels) { + let qotdChannel = client.channels.cache.get(channel); + await qotdChannel.send({ embeds: [quoteEmbed] }); + } +} -- cgit v1.2.3