Files
drb-server/discordBot/commands/rssTrigger.mjs
Logan Cusano 43dfa7b5ad
All checks were successful
DRB Tests / drb_mocha_tests (pull_request) Successful in 31s
RSS improvements
- Updated rss discord command name scheme
- Implemented new sourceManager for handling feed sources
- Added wrappers to delete/get feed sources by title
2024-05-26 01:26:12 -04:00

46 lines
1.9 KiB
JavaScript

import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.command.rssTrigger");
import { SlashCommandBuilder } from 'discord.js';
import { updateFeeds } from '../../rss-manager/feedHandler.mjs'
// Exporting data property that contains the command structure for discord including any params
export const data = new SlashCommandBuilder()
.setName('rss-trigger')
.setDescription('Manually triggers an RSS feed update');
// Exporting other properties
export const example = "/rss-trigger"; // An example of how the command would be run in discord chat, this will be used for the help command
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
/**
* Function to give the user auto-reply suggestions
* @param {any} nodeIo The nodeIO server for manipulation of sockets
* @param {any} interaction The interaction object
*/
/*
export async function autocomplete(nodeIo, interaction) {
const focusedValue = interaction.options.getFocused();
const choices = [];
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
log.INFO(focusedValue, choices, filtered);
await interaction.respond(filtered);
}
*/
/**
* The function to run when the command is called by a discord user
* @param {any} nodeIo The nodeIO server for manipulation of sockets
* @param {any} interaction The interaction object
*/
export const execute = async (nodeIo, interaction) => {
try {
//const sockets = await nodeIo.allSockets();
//await interaction.reply(`**Online Sockets: '${sockets}'**`);
await interaction.reply('Triggering RSS update');
await updateFeeds(interaction.client);
//await interaction.channel.send('**Pong.**');
} catch (err) {
console.error(err);
// await interaction.reply(err.toString());
}
}