Update commands to slash commands

This commit is contained in:
Logan Cusano
2023-02-25 03:25:07 -05:00
parent 49c80b7f5e
commit 02bf0ebda2
16 changed files with 370 additions and 223 deletions

View File

@@ -1,15 +1,26 @@
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 = {
name: 'quote',
description: 'Quote!',
async execute(message) {
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);
message.reply(quotes[selectedQuote].quoteText + " - " + quotes[selectedQuote].quoteAuthor);
} catch (e) {
message.reply(e.toString());
interaction.reply(quotes[selectedQuote].quoteText + " - " + quotes[selectedQuote].quoteAuthor);
} catch(err){
log.ERROR(err)
//await interaction.reply(err.toString());
}
}
};