Update commands to slash commands
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user