Update commands to slash commands
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user