Linting
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { removeSource } from '../../rss-manager/sourceManager.mjs'
|
||||
import { getAllFeeds, deleteFeedByTitle } from '../../modules/mongo-wrappers/mongoFeedsWrappers.mjs'
|
||||
import { removeSource } from "../../rss-manager/sourceManager.mjs";
|
||||
import {
|
||||
getAllFeeds,
|
||||
deleteFeedByTitle,
|
||||
} from "../../modules/mongo-wrappers/mongoFeedsWrappers.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.rssRemove");
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('rss-remove')
|
||||
.setDescription('Add RSS Source')
|
||||
.addStringOption(option =>
|
||||
option.setName('title')
|
||||
.setDescription('The title of the RSS feed')
|
||||
.setName("rss-remove")
|
||||
.setDescription("Add RSS Source")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("title")
|
||||
.setDescription("The title of the RSS feed")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true))
|
||||
.setAutocomplete(true),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/rss-remove [title]"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
@@ -27,11 +31,15 @@ export const deferInitialReply = false; // If we the initial reply in discord sh
|
||||
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = await getAllFeeds() ?? [];
|
||||
const choices = (await getAllFeeds()) ?? [];
|
||||
log.INFO("RSS Remove Choices:", choices);
|
||||
const filtered = choices.filter(choice => choice.title.startsWith(focusedValue));
|
||||
const filtered = choices.filter((choice) =>
|
||||
choice.title.startsWith(focusedValue),
|
||||
);
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
await interaction.respond(filtered.map(choice => ({ name: choice.title, value: choice.title })));
|
||||
await interaction.respond(
|
||||
filtered.map((choice) => ({ name: choice.title, value: choice.title })),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,8 +49,10 @@ export async function autocomplete(nodeIo, interaction) {
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
var title = interaction.options.getString('title');
|
||||
await interaction.reply(`Removing ${title} from the list of RSS sources, please wait...`);
|
||||
var title = interaction.options.getString("title");
|
||||
await interaction.reply(
|
||||
`Removing ${title} from the list of RSS sources, please wait...`,
|
||||
);
|
||||
|
||||
const results = await deleteFeedByTitle(title);
|
||||
if (!results) {
|
||||
@@ -50,9 +60,11 @@ export const execute = async (nodeIo, interaction) => {
|
||||
await interaction.editReply(`Failed to remove source: '${title}'`);
|
||||
return;
|
||||
}
|
||||
await interaction.editReply(`${title} was successfully removed from the RSS sources.`)
|
||||
await interaction.editReply(
|
||||
`${title} was successfully removed from the RSS sources.`,
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR(err)
|
||||
log.ERROR(err);
|
||||
await interaction.editReply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user