Update commands to slash commands
This commit is contained in:
@@ -1,33 +1,49 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const libCore = require("../libCore.js");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "add");
|
||||
|
||||
module.exports = {
|
||||
name: 'add',
|
||||
description: 'Add RSS Source',
|
||||
execute(message, args) {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('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)),
|
||||
example: "add [title] [https://domain.com/feed.xml] [category]",
|
||||
isPrivileged: false,
|
||||
async execute(interaction, args) {
|
||||
try {
|
||||
if (args.length < 3) {
|
||||
message.reply(`Please use in !add [title] [https://domain.com/feed.xml] [category] format`);
|
||||
return;
|
||||
}
|
||||
var title = args[0];
|
||||
var link = args[1];
|
||||
var category = args[2];
|
||||
var title = interaction.options.getString('title');
|
||||
var link = interaction.options.getString('link');
|
||||
var category = interaction.options.getString('category');
|
||||
|
||||
if (!category) category = "ALL";
|
||||
|
||||
libCore.addSource(title, link, category, (err, result) => {
|
||||
console.log("Result from adding entry", result);
|
||||
|
||||
if (result) {
|
||||
message.reply(`Adding ${title} to the list of RSS sources`);
|
||||
interaction.reply(`Adding ${title} to the list of RSS sources`);
|
||||
} else {
|
||||
message.reply(`${title} already exists in the list of RSS sources`);
|
||||
interaction.reply(`${title} already exists in the list of RSS sources`);
|
||||
}
|
||||
|
||||
var sources = libCore.getSources();
|
||||
libCore.loadFeeds();
|
||||
});
|
||||
}catch(err){
|
||||
console.log(err);
|
||||
message.reply(err.toString());
|
||||
log.ERROR(err)
|
||||
await message.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,13 +1,19 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "categories");
|
||||
|
||||
module.exports = {
|
||||
name: 'categories',
|
||||
description: 'Categories',
|
||||
execute(message) {
|
||||
var cats = libCore.getCategories();
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('categories')
|
||||
.setDescription('Return all categories'),
|
||||
example: "categories",
|
||||
isPrivileged: false,
|
||||
async execute(interaction) {
|
||||
var categories = libCore.getCategories();
|
||||
|
||||
message.reply(
|
||||
`Categories: [${cats.join(', ')}]`
|
||||
await interaction.reply(
|
||||
`Categories: [${categories.join(', ')}]`
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,21 +1,47 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const libCore = require("../libCore.js");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "chat");
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'chat',
|
||||
description: 'Chat',
|
||||
async execute(message, args) {
|
||||
if (args.length < 1) {
|
||||
message.reply(`Please use in !chat [chat query]`);
|
||||
return;
|
||||
}
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('chat')
|
||||
.setDescription('Send a text prompt to ChatGPT')
|
||||
.addStringOption(option =>
|
||||
option.setName('prompt')
|
||||
.setDescription('The prompt to be sent to ChatGPT')
|
||||
.setRequired(true))
|
||||
.addNumberOption(option =>
|
||||
option.setName('temperature')
|
||||
.setDescription('Set the temperature, 0 = repetitive, 1 = random')
|
||||
.setRequired(false))
|
||||
.addNumberOption(option =>
|
||||
option.setName('maxTokens')
|
||||
.setDescription('The max amount of tokens to be spent')
|
||||
.setRequired(false)),
|
||||
example: "chat [tell me a story] [0.07] []", // Need to figure out the tokens
|
||||
isPrivileged: false,
|
||||
requiresTokens: true,
|
||||
async execute(interaction) {
|
||||
// Needs middleware for payment
|
||||
|
||||
try {
|
||||
var question = encodeURIComponent(args.join(" "));
|
||||
var params = {};
|
||||
var prompt = encodeURIComponent(interaction.options.getString('prompt').join(" "));
|
||||
var temperature = interaction.options.getNumber('temperature');
|
||||
var maxTokens = interaction.options.getNumber('maxTokens');
|
||||
|
||||
var response = await libCore.getChat(question);
|
||||
message.reply(`${message.author.username} ${response}`);
|
||||
if (temperature) params._temperature = temperature;
|
||||
if (maxTokens) params._max_tokens = maxTokens;
|
||||
|
||||
var gptResponse = await prompt.libCore.getChat(prompt, params);
|
||||
await interaction.reply(`${interaction.author.username} ${gptResponse}`);
|
||||
|
||||
// Needs reply code to reply to the generation
|
||||
}catch(err){
|
||||
//message.reply(err.toString());
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,17 +1,20 @@
|
||||
var libUtils = require("../libUtils.js");
|
||||
const libUtils = require("../libUtils.js");
|
||||
const discordAuth = require("../utilities/discordAuthorization");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'exit',
|
||||
description: 'Exit the current application.',
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('exit')
|
||||
.setDescription('Exit the current application.'),
|
||||
example: "exit",
|
||||
isPrivileged: true,
|
||||
async execute(message) {
|
||||
async execute(interaction) {
|
||||
// TODO - Need to add middleware for admins
|
||||
if (message.member.user.tag !== "Logan#3331") message.reply(`Sorry ${message.member.user.tag}, you are not allowed to use this command.`);
|
||||
message.reply(
|
||||
discordAuth.authorizeCommand(interaction, this.data.name, async () => {
|
||||
await interaction.reply(
|
||||
`Goodbye world - Disconnection imminent.`
|
||||
);
|
||||
await libUtils.sleep(5000);
|
||||
await new Promise(resolve => setTimeout(process.exit(), 5000));
|
||||
libUtils.runAfter(process.exit, 5000);
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -1,64 +0,0 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'find',
|
||||
description: 'Find RSS Sources',
|
||||
execute(message, args) {
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
message.reply(`Missing arguments`);
|
||||
return;
|
||||
}
|
||||
|
||||
var search = args.join(" ");
|
||||
var found = false;
|
||||
|
||||
let i = 0;
|
||||
let iSave = 0
|
||||
let count = 0;
|
||||
var feedArray = libCore.getFeeds();
|
||||
var searchString = "";
|
||||
var foundError = false;
|
||||
feedArray.forEach(linkFlay => {
|
||||
try {
|
||||
if (linkFlay.title.toLowerCase().indexOf(search.toLowerCase()) > -1) {
|
||||
iSave = i;
|
||||
found = true;
|
||||
console.log(linkFlay.title);
|
||||
searchString += `Use !get ${i} to view: ${linkFlay.title} \n`;
|
||||
count++;
|
||||
if (count > 5) {
|
||||
message.reply(searchString);
|
||||
searchString = "";
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} catch (error) {
|
||||
foundError = true;
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (foundError) {
|
||||
message.reply("Error in search");
|
||||
return;
|
||||
} else {
|
||||
message.reply('-' + searchString);
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
//message.channel.send('Displaying 1 result');
|
||||
//message.channel.send('!get '+iSave);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
message.reply(`No results found for: ${search}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
message.reply(error.toString());
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
@@ -1,14 +1,21 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const libCore = require("../libCore.js");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "food");
|
||||
|
||||
module.exports = {
|
||||
name: 'food',
|
||||
description: 'Food',
|
||||
async execute(message, args) {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('food')
|
||||
.setDescription('Gets a random recipe and gives it to you'),
|
||||
example: "food",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try {
|
||||
|
||||
var resultArray = await libCore.getFood();
|
||||
|
||||
message.reply(`
|
||||
await interaction.reply(`
|
||||
[**${resultArray.strMeal}** - *${resultArray.strCategory}*]
|
||||
|
||||
${resultArray.strSource}
|
||||
@@ -17,7 +24,8 @@ module.exports = {
|
||||
|
||||
`);
|
||||
}catch(err){
|
||||
message.reply(err.toString());
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,22 +1,28 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const libCore = require("../libCore.js");
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "get");
|
||||
|
||||
module.exports = {
|
||||
name: 'get',
|
||||
description: 'Get RSS Source Link',
|
||||
execute(message, args) {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('get')
|
||||
.setDescription('Get RSS link by number')
|
||||
.addNumberOption(option =>
|
||||
option.setName('position')
|
||||
.setDescription('The index position of the RSS link')
|
||||
.setRequired(true)),
|
||||
example: "get [1]",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try {
|
||||
|
||||
if (args.length < 1) {
|
||||
message.reply(`Use !get [number] Ex: !get 25`);
|
||||
return;
|
||||
}
|
||||
var search = args[0];
|
||||
var catName = "All";
|
||||
var feedArray = libCore.getFeeds();
|
||||
message.reply(`**Retrieving**: [${catName}] (${feedArray[search].link})`);
|
||||
await interaction.reply(`**Retrieving**: [${catName}] (${feedArray[search].link})`);
|
||||
}catch(err){
|
||||
message.reply(err.toString());
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,16 +1,25 @@
|
||||
const fs = require('fs');
|
||||
const path = require('node:path');
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "help");
|
||||
|
||||
const prefix = process.env.PREFIX;
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'Display this help message',
|
||||
example: "help",
|
||||
execute(message) {
|
||||
messageText = "";
|
||||
const commandsPath = path.resolve('./commands'); // Resolves from either working dir or __dirname
|
||||
const commandsPath = path.resolve(__dirname, '../commands'); // Resolves from either working dir or __dirname
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription('Display this help message'),
|
||||
example: "help",
|
||||
isPrivileged: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
messageText = "";
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
@@ -20,11 +29,15 @@ module.exports = {
|
||||
messageText += `\n`;
|
||||
}
|
||||
|
||||
messageText += `**${prefix}${command.name}** - *${command.description}*`;
|
||||
messageText += `**/${command.data.name}** - *${command.data.description}*`;
|
||||
|
||||
if (command.example) messageText += `\n\t\t***Usage:*** \`${command.example}\``
|
||||
}
|
||||
}
|
||||
message.reply(messageText);
|
||||
await interaction.reply(messageText);
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "ping");
|
||||
|
||||
// TODO - Add insults as the response to this command
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
@@ -8,11 +9,19 @@ module.exports = {
|
||||
/*
|
||||
.addStringOption(option =>
|
||||
option.setName('input')
|
||||
.setDescription('The input to echo back')),
|
||||
.setDescription('The input to echo back')
|
||||
.setRequired(false)
|
||||
.addChoices()),
|
||||
*/
|
||||
example: "ping",
|
||||
isPrivileged: false,
|
||||
async execute(message) {
|
||||
await message.channel.send('**Pong.**');
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
await interaction.channel.send('**Pong.**'); // TODO - Add insults as the response to this command
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,15 +1,26 @@
|
||||
var libCore = require("../libCore.js");
|
||||
const quote_url = "https://zenquotes.io/api/quotes/";
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "quotes");
|
||||
|
||||
module.exports = {
|
||||
name: 'quote',
|
||||
description: 'Quote!',
|
||||
async execute(message) {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('quote')
|
||||
.setDescription('Get a random quote'),
|
||||
example: "quote",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try {
|
||||
var quotes = await libCore.getQuotes(quote_url);
|
||||
var selectedQuote = Math.floor(Math.random() * quotes.length);
|
||||
message.reply(quotes[selectedQuote].quoteText + " - " + quotes[selectedQuote].quoteAuthor);
|
||||
} catch (e) {
|
||||
message.reply(e.toString());
|
||||
|
||||
interaction.reply(quotes[selectedQuote].quoteText + " - " + quotes[selectedQuote].quoteAuthor);
|
||||
} catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,24 +1,32 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "random");
|
||||
|
||||
module.exports = {
|
||||
name: 'random',
|
||||
description: 'Get a random link from one of the RSS feeds.',
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('random')
|
||||
.setDescription('Get a random link from one of the RSS feeds.')
|
||||
.addStringOption(option =>
|
||||
option.setName('category')
|
||||
.setDescription('Select the category to grab from *(default is "ALL")*')
|
||||
.setRequired(false)),
|
||||
example: "random [category]",
|
||||
execute(message, args) {
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try {
|
||||
var category = "";
|
||||
var catName = "All";
|
||||
if (args.length == 1) {
|
||||
category = args[0];
|
||||
catName = category;
|
||||
}
|
||||
let category = interaction.options.getString('category');
|
||||
if (!category) category = "ALL";
|
||||
|
||||
var feedArray = libCore.getFeeds(category);
|
||||
var i = Math.floor(Math.random() * (feedArray.length - 0) + 0);
|
||||
|
||||
message.reply(`**Retrieved**: [${catName}](${feedArray[i].link})`);
|
||||
await message.reply(`**Retrieved**: [${category}](${feedArray[i].link})`);
|
||||
} catch (err) {
|
||||
message.reply(err.toString());
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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) {
|
||||
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{
|
||||
if (args.length < 1) {
|
||||
message.reply(`Please use in '${process.env.prefix}remove [title]' format`);
|
||||
return;
|
||||
}
|
||||
var title = args[0];
|
||||
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());
|
||||
log.ERROR(err)
|
||||
interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,33 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "slang");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('slang')
|
||||
.setDescription('Search Urban Dictionary for a phrase.')
|
||||
.addStringOption(option =>
|
||||
option.setName('phrase')
|
||||
.setDescription('The phrase to search')
|
||||
.setRequired(true)),
|
||||
example: "slang \"[phrase to search]\"",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
var question = encodeURIComponent(interaction.options.getString('phrase').join(" "));
|
||||
|
||||
var slangData = await libCore.getSlang(question);
|
||||
await message.reply(`**Term**: ${decodeURIComponent(question)}\n\n**Answer**: ${slangData.definition}\n\n**Example**: ${slangData.example}`);
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'slang',
|
||||
description: 'Search Urban Dictionary for a phrase.',
|
||||
|
||||
@@ -1,5 +1,33 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "sources");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('sources')
|
||||
.setDescription('Replies with your input!'),
|
||||
example: "sources",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
var sourceArray = libCore.getSources();
|
||||
var sourceString = "";
|
||||
|
||||
sourceArray.forEach(source => {
|
||||
sourceString +=`[${source.title}](${source.link}) \n`;
|
||||
});
|
||||
|
||||
await interaction.reply(sourceString);
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'sources',
|
||||
description: 'List RSS Sources',
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "update");
|
||||
|
||||
module.exports = {
|
||||
name: 'update',
|
||||
description: 'Get RSS Source Link',
|
||||
execute(message, args) {
|
||||
message.reply(`Loading Feeds from Sources`);
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('update')
|
||||
.setDescription('Reloads all RSS feeds'),
|
||||
example: "update",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
libCore.loadFeeds();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
await interaction.reply("Reloaded all RSS feeds");
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
feedArray = libCore.getFeeds();
|
||||
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,41 @@
|
||||
var libCore = require("../libCore.js");
|
||||
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "alert");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('alert')
|
||||
.setDescription('Get any current weather alerts in the state specified.')
|
||||
.addStringOption(option =>
|
||||
option.setName('state')
|
||||
.setDescription('The state to get any current weather alerts from')
|
||||
.setRequired(false)
|
||||
.addChoices()),
|
||||
example: "alert [state]",
|
||||
isPrivileged: false,
|
||||
requiresTokens: false,
|
||||
async execute(interaction) {
|
||||
try{
|
||||
var question = encodeURIComponent(interaction.options.getString("state").join(" "));
|
||||
|
||||
var answerData = await libCore.weatherAlert(question);
|
||||
answerData.forEach(feature => {
|
||||
interaction.reply(`
|
||||
${feature.properties.areaDesc}
|
||||
${feature.properties.headline}
|
||||
${feature.properties.description}
|
||||
`);
|
||||
});
|
||||
|
||||
}catch(err){
|
||||
log.ERROR(err)
|
||||
//await interaction.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'alert',
|
||||
description: 'Get any current weather alerts in the state specified.',
|
||||
|
||||
Reference in New Issue
Block a user