journaler/slash-commands/template

31 lines
1.0 KiB
Plaintext
Raw Normal View History

2023-05-24 23:00:38 +00:00
const { SlashCommandBuilder } = require('discord.js');
const fn = require('../modules/functions.js');
const strings = require('../data/strings.json');
module.exports = {
data: new SlashCommandBuilder()
.setName("")
.setDescription("")
.addBooleanOption(o =>
o.setName("private")
.setDescription("Should the reply be visible only to you?")
.setRequired(false)
),
id: "", // The command ID, used to generate clickable commands
about: "", // A description of the command to be used with /commands
async execute(interaction) {
let private = interaction.options.getBoolean('private');
if (private == undefined) {
private = true;
}
// Defer the reply so we have time to do things
await interaction.deferReply({ ephemeral: private }).catch(e => console.error(e));
try {
// Code here...
} catch(err) {
// In case of error, log it and let the user know something went wrong
console.error(err);
await interaction.editReply(strings.errors.generalCommand).catch(e => console.error(e));
}
},
};