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,33 +1,49 @@
var libCore = require("../libCore.js");
const libCore = require("../libCore.js");
const { SlashCommandBuilder } = require('discord.js');
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "add");
module.exports = {
name: 'add',
description: 'Add RSS Source',
execute(message, args) {
try {
if (args.length < 3) {
message.reply(`Please use in !add [title] [https://domain.com/feed.xml] [category] format`);
return;
}
var title = args[0];
var link = args[1];
var category = args[2];
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Add RSS Source')
.addStringOption(option =>
option.setName('title')
.setDescription('The title of the RSS feed')
.setRequired(true))
.addStringOption(option =>
option.setName('link')
.setDescription('The link to the RSS feed')
.setRequired(true))
.addStringOption(option =>
option.setName('category')
.setDescription('The category for the RSS feed *("ALL" by default")*')
.setRequired(false)),
example: "add [title] [https://domain.com/feed.xml] [category]",
isPrivileged: false,
async execute(interaction, args) {
try {
var title = interaction.options.getString('title');
var link = interaction.options.getString('link');
var category = interaction.options.getString('category');
if (!category) category = "ALL";
libCore.addSource(title, link, category, (err, result) => {
console.log("Result from adding entry", result);
if (result) {
message.reply(`Adding ${title} to the list of RSS sources`);
interaction.reply(`Adding ${title} to the list of RSS sources`);
} else {
message.reply(`${title} already exists in the list of RSS sources`);
interaction.reply(`${title} already exists in the list of RSS sources`);
}
var sources = libCore.getSources();
libCore.loadFeeds();
});
} catch (err) {
console.log(err);
message.reply(err.toString());
}
}
}catch(err){
log.ERROR(err)
await message.reply(err.toString());
}
}
};