Linting
This commit is contained in:
@@ -1,28 +1,34 @@
|
||||
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { addSource } from '../../rss-manager/sourceManager.mjs'
|
||||
import { addSource } from "../../rss-manager/sourceManager.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.rssAdd");
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('rss-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')
|
||||
.setName("rss-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))
|
||||
.setRequired(false),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/rss-add [title] [https://domain.com/feed.xml] [category]"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const example =
|
||||
"/rss-add [title] [https://domain.com/feed.xml] [category]"; // 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.
|
||||
|
||||
/**
|
||||
@@ -49,24 +55,37 @@ export async function autocomplete(nodeIo, interaction) {
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
var title = interaction.options.getString('title');
|
||||
var link = interaction.options.getString('link');
|
||||
var category = interaction.options.getString('category');
|
||||
var title = interaction.options.getString("title");
|
||||
var link = interaction.options.getString("link");
|
||||
var category = interaction.options.getString("category");
|
||||
|
||||
if (!category) category = "ALL";
|
||||
await interaction.reply(`Adding ${title} to the list of RSS sources, please wait...`);
|
||||
await interaction.reply(
|
||||
`Adding ${title} to the list of RSS sources, please wait...`,
|
||||
);
|
||||
|
||||
await addSource(title, link, category, interaction.guildId, interaction.channelId, (err, result) => {
|
||||
log.DEBUG("Result from adding entry", result);
|
||||
await addSource(
|
||||
title,
|
||||
link,
|
||||
category,
|
||||
interaction.guildId,
|
||||
interaction.channelId,
|
||||
(err, result) => {
|
||||
log.DEBUG("Result from adding entry", result);
|
||||
|
||||
if (result) {
|
||||
interaction.editReply(`Successfully added ${title} to the list of RSS sources`);
|
||||
} else {
|
||||
interaction.editReply(`${title} already exists in the list of RSS sources`);
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
interaction.editReply(
|
||||
`Successfully added ${title} to the list of RSS sources`,
|
||||
);
|
||||
} else {
|
||||
interaction.editReply(
|
||||
`${title} already exists in the list of RSS sources`,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR(err)
|
||||
log.ERROR(err);
|
||||
await interaction.editReply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user