Files
Emmelia-Link-Flayer-Rewrite/commands/quotes.js
2023-02-25 03:25:07 -05:00

26 lines
802 B
JavaScript

var libCore = require("../libCore.js");
const quote_url = "https://zenquotes.io/api/quotes/";
const { SlashCommandBuilder } = require('discord.js');
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "quotes");
module.exports = {
data: new SlashCommandBuilder()
.setName('quote')
.setDescription('Get a random quote'),
example: "quote",
isPrivileged: false,
requiresTokens: false,
async execute(interaction) {
try {
var quotes = await libCore.getQuotes(quote_url);
var selectedQuote = Math.floor(Math.random() * quotes.length);
interaction.reply(quotes[selectedQuote].quoteText + " - " + quotes[selectedQuote].quoteAuthor);
} catch(err){
log.ERROR(err)
//await interaction.reply(err.toString());
}
}
};