discord-bot-template/slash-commands/template

31 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2023-01-21 04:35:03 +00:00
const { SlashCommandBuilder } = require('discord.js');
const fn = require('../modules/functions.js');
2023-02-13 04:51:17 +00:00
const strings = require('../data/strings.json');
2023-01-21 04:35:03 +00:00
module.exports = {
data: new SlashCommandBuilder()
2023-02-13 04:51:17 +00:00
.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
2023-01-21 04:35:03 +00:00
async execute(interaction) {
2023-02-13 04:51:17 +00:00
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));
}
2023-01-21 04:35:03 +00:00
},
};