Passing an external arrays as command option choices.

I am trying to figure out how I can pass an external array through module exports into my command file.
My Command File:
const { EmbedBuilder, ApplicationCommandOptionType, ApplicationCommandType } = require("discord.js")
const { mysql, connection } = require('../../../../bot')
const { items } = require('../../../Functions/shopItems')
module.exports = {
    name: "buy",
    type: ApplicationCommandType.ChatInput,
    description: "Buy Items from the in-game shop.",
    options: [
        {
            name: "item",
            description: "The name of the item you would like to buy",
            type: ApplicationCommandOptionType.String,
            choices: [items]
        }
    ],
    run: async(DiscordClient, interaction) => {
        try {
            await interaction.deferReply();
            const user = interaction.options.getUser("user");
            var userId = interaction.user.id;
            var account_balance = "";
            connection.query(`SELECT * FROM economy_accounts WHERE user_id = "786521239560519712";`, function(error, results) {
                if (error) {
                    console.log(error)
                    interaction.editReply("Sorry, something went wrong, please contact the developer if this issue persists.")
                } else {
                    interaction.editReply(`Your account balance is: ${results[0]["account_balance"]}`)
                }
            })
            console.log(items)
        } catch (error) {
            console.log(error)
        }
    }
}

shopItems list
module.exports = {
    items: [
        { name: "Pen", value: "pen" },
        { name: "Book", value: "book" }
    ]
}

DiscordAPIError[50035]: Invalid Form Body options[0].choices[0][LIST_ITEM_VALUE_REQUIRED]: List item values of ModelType are required
image.png
Was this page helpful?