Git Product home page Git Product logo

Comments (3)

Jiralite avatar Jiralite commented on June 26, 2024

Please show what you are doing with this builder (what you did with this builder to get that error).

from discord.js.

feenko avatar feenko commented on June 26, 2024

Please show what you are doing with this builder (what you did with this builder to get that error).

I just load it, everything works fine until i add translations for a user option

    private async loadCommands() {
        const commandFiles = this.findCommandFiles();

        for (const file of commandFiles) {
            const command = await import(`../commands/${file}`);
            const commandInstance = new command.default();
            const commandCategory = (file as string).split('/')[0];

            const commandData = {
                ...commandInstance.data,
                category: commandCategory,
            };

            commandInstance.data = commandData;

            client.commands.set(commandInstance.data.name, commandInstance);
        }

        client.on('ready', () => {
            client.application?.commands.set(
                client.commands.map((c) => c.data),
            );
        });
    }

from discord.js.

Jiralite avatar Jiralite commented on June 26, 2024

This is a code sample from your comments. It works:

import { Client, SlashCommandBuilder } from "discord.js";

const client = new Client({ intents: 0 });

client.on("ready", async () => {
	const command = new SlashCommandBuilder()
		.setName("info")
		.setDescription("Shows information")
		.setDescriptionLocalizations({
			pl: "Pokazuje informacje",
		})
		.addSubcommand((subcommand) =>
			subcommand
				.setName("user")
				.setDescription("Shows information about the user")
				.setDescriptionLocalizations({
					pl: "Pokazuje informacje o użytkowniku",
				})
				.addUserOption((option) =>
					option
						.setName("user")
						.setNameLocalizations({
							pl: "użytkownik",
						})
						.setDescription("The user to show information about")
						.setDescriptionLocalizations({
							pl: "Użytkownik, o którym chcesz zobaczyć informacje",
						}),
				),
		);

	await client.application!.commands.set([command]); // No error.
});

client.login();

So, you seem to have flawed logic in your code and this is not a discord.js issue. You can head to our support server where you'll get support much quicker.

from discord.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.