Update commands to slash commands
This commit is contained in:
@@ -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