I've been facing an issue with accessing elements from an imported array. Even though the array is successfully imported, attempting to access its elements using [0] results in undefined.
Here's how I exported the array in standList.js:
exports.stands = ["Star Platinum", "Crazy Diamond", "Golden Experience"]
This is how I'm trying to access it:
const stands = require('../data/standList.js');
module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if(interaction.isButton()){
if (interaction.customId === 'standarrow'){
var stand = stands[0];
console.log(stands);
console.log(stands[0]);
console.log(stand);
await interaction.reply("You have awakened the power of *" + stand + "*!");}
}
console.log(`${interaction.user.tag} in #${interaction.channel.name} triggered an interaction.`);
},
};
The output shows:
KomiKage in #testzone triggered an interaction.
Killjoy : | testzone | Thu Oct 27 2022 13:41:51 GMT+0200 (Central European Summer Time)
{ stands: [ 'Star Platinum', 'Crazy Diamond', 'Golden Experience' ] }
undefined
undefined
KomiKage in #testzone triggered an interaction.