list all commands in array

` `` async execute(interaction) {
const foldersPath = path.join(dirname);
fs.readdir(
dirname, (err, files) => { if(err) console.error(err); let jsfiles = files.filter(f => f.split(".").pop() === "js"); if(jsfiles.length <= 0) { applog("No commands to load!"); return; } const filesArray = new Array(); jsfiles.forEach((f, i) => { const props = require(__dirname + '/' + f); applog(props.data.name + ' | usage: ' + props.usage) const filesArray = [props.data.name, props.data.description, props.usage] }); applog(filesArray) });
interaction.reply('nur bis her').then(msg => { setTimeout(() => msg.delete(), deleteInSlow) }); }, ``` I try to output all commands in an array but I can't get the array to display at that point. As soon as I reply with the bot inside the foreach, it always gives me the error message interaction not found. Thank you for your help
7 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
h4ze
h4zeOP7mo ago
The array is always from outside empty
No description
h4ze
h4zeOP7mo ago
async execute(interaction) {

const foldersPath = path.join(__dirname);

fs.readdir(__dirname, (err, files) => {
if(err) console.error(err);

let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
applog("No commands to load!");
return;
}
const filesArray = new Array();
jsfiles.forEach((f, i) => {
const props = require(__dirname + '/' + f);
applog(props.data.name + ' | usage: ' + props.usage)
const filesArray = [props.data.name, props.data.description, props.usage]
interaction.reply('nur bis her').then(msg => {
setTimeout(() => msg.delete(), deleteInSlow)
});
});
applog(filesArray)
});



},
async execute(interaction) {

const foldersPath = path.join(__dirname);

fs.readdir(__dirname, (err, files) => {
if(err) console.error(err);

let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
applog("No commands to load!");
return;
}
const filesArray = new Array();
jsfiles.forEach((f, i) => {
const props = require(__dirname + '/' + f);
applog(props.data.name + ' | usage: ' + props.usage)
const filesArray = [props.data.name, props.data.description, props.usage]
interaction.reply('nur bis her').then(msg => {
setTimeout(() => msg.delete(), deleteInSlow)
});
});
applog(filesArray)
});



},
With this I become as error
h4ze
h4zeOP7mo ago
No description
d.js docs
d.js docs7mo ago
Tag suggestion for @h4ze: Common causes of DiscordAPIError[10062]: Unknown interaction: - Initial response took more than 3 seconds ➞ defer the response *. - Wrong interaction object inside a collector. - Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance) * Note: you cannot defer modal or autocomplete value responses
h4ze
h4zeOP7mo ago
async execute(interaction) {
interaction.deferReply();
wait(4_000);
const foldersPath = path.join(__dirname);

fs.readdir(__dirname, (err, files) => {
if(err) console.error(err);

let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
applog("No commands to load!");
return;
}
const filesArray = new Array();
jsfiles.forEach((f, i) => {
const props = require(__dirname + '/' + f);
applog(props.data.name + ' | usage: ' + props.usage)
const filesArray = [props.data.name, props.data.description, props.usage]

interaction.editReply('Pong!');


});
applog(filesArray)
});


async execute(interaction) {
interaction.deferReply();
wait(4_000);
const foldersPath = path.join(__dirname);

fs.readdir(__dirname, (err, files) => {
if(err) console.error(err);

let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
applog("No commands to load!");
return;
}
const filesArray = new Array();
jsfiles.forEach((f, i) => {
const props = require(__dirname + '/' + f);
applog(props.data.name + ' | usage: ' + props.usage)
const filesArray = [props.data.name, props.data.description, props.usage]

interaction.editReply('Pong!');


});
applog(filesArray)
});


Shows me this error .. without the editReply it shows only bot is thinking ..
h4ze
h4zeOP7mo ago
No description
Want results from more Discord servers?
Add your server