const libCore = require("../libCore.js"); const { SlashCommandBuilder } = require('discord.js'); const { DebugBuilder } = require("../utilities/debugBuilder"); const log = new DebugBuilder("server", "add"); module.exports = { 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) { interaction.reply(`Adding ${title} to the list of RSS sources`); } else { interaction.reply(`${title} already exists in the list of RSS sources`); } libCore.loadFeeds(); }); }catch(err){ log.ERROR(err) await message.reply(err.toString()); } } };