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,24 +1,32 @@
var libCore = require("../libCore.js");
const { SlashCommandBuilder } = require('discord.js');
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "random");
module.exports = {
name: 'random',
description: 'Get a random link from one of the RSS feeds.',
example: "random [category]",
execute(message, args) {
try {
var category = "";
var catName = "All";
if (args.length == 1) {
category = args[0];
catName = category;
}
data: new SlashCommandBuilder()
.setName('random')
.setDescription('Get a random link from one of the RSS feeds.')
.addStringOption(option =>
option.setName('category')
.setDescription('Select the category to grab from *(default is "ALL")*')
.setRequired(false)),
example: "random [category]",
isPrivileged: false,
requiresTokens: false,
async execute(interaction) {
try {
let category = interaction.options.getString('category');
if (!category) category = "ALL";
var feedArray = libCore.getFeeds(category);
var i = Math.floor(Math.random() * (feedArray.length - 0) + 0);
message.reply(`**Retrieved**: [${catName}](${feedArray[i].link})`);
} catch (err) {
message.reply(err.toString());
await message.reply(`**Retrieved**: [${category}](${feedArray[i].link})`);
} catch (err) {
log.ERROR(err)
//await interaction.reply(err.toString());
}
}
}
};