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,31 +1,37 @@
var libCore = require("../libCore.js");
const { SlashCommandBuilder } = require('discord.js');
const { DebugBuilder } = require("../utilities/debugBuilder");
const log = new DebugBuilder("server", "remove");
module.exports = {
name: 'remove',
description: 'Remove RSS Source',
execute(message, args) {
try {
if (args.length < 1) {
message.reply(`Please use in '${process.env.prefix}remove [title]' format`);
return;
}
var title = args[0];
data: new SlashCommandBuilder()
.setName('remove')
.setDescription('Remove an RSS source by it\' title')
.addStringOption(option =>
option.setName('title')
.setDescription('The title of the source to remove')
.setRequired(true)),
example: "remove ['Leafly']",
isPrivileged: false,
requiresTokens: false,
async execute(interaction) {
try{
var title = interaction.options.getString("title");
libCore.deleteSource(title, (err, result) => {
console.log("Result from removing entry", result);
if (result) {
message.reply(`Removing ${title} from the list of RSS sources`);
interaction.reply(`Removing ${title} from the list of RSS sources`);
} else {
message.reply(`${title} does not exist in the list of RSS sources`);
interaction.reply(`${title} does not exist 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)
interaction.reply(err.toString());
}
}
};