Discord. Js Invalid Form Body [Duplicate]

At the time I am trying to learn how to make a discord bot and I got an error I dont know waht it means or how to fix it. I made a command for welcome messages with a youtube tutorial and now it stopped working.

Error:

DiscordAPIError[50035]: Invalid Form Body
7.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
    at SequentialHandler.runRequest (C:\Users\hp\OneDrive\Desktop\Manager\node_modules\@discordjs\rest\dist\index.js:659:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.queueRequest (C:\Users\hp\OneDrive\Desktop\Manager\node_modules\@discordjs\rest\dist\index.js:458:14)
    at async REST.request (C:\Users\hp\OneDrive\Desktop\Manager\node_modules\@discordjs\rest\dist\index.js:902:22)
    at async GuildApplicationCommandManager.set (C:\Users\hp\OneDrive\Desktop\Manager\node_modules\discord.js\src\managers\ApplicationCommandManager.js:173:18)

Code:

const {Message, Client, SlashCommandBuilder, PermissionFlagsBits} = require("discord.js");
const welcomeSchema = require("../../Models/Welcome");
const {model, Schema} = require("mongoose");

module.exports = {
    name:"setup-welcome",
    description:"Set up your welcome message for the discord bot.",
    UserPerms:["BanMembers"],
    category:"Moderation",
    options: [
        {
            name:"Channel",
            description:"Channel for welcome messages.",
            type:7,
            required:true
        },

        {
            name:"welcome-message",
            description:"Enter your welcome message.",
            type:3,
            reqired:true
        },

        {
            name:"welcome-role",
            description:"Enter your welcome role.",
            type:8,
            required:true
        }
    

    ],
                
    async execute(interaction) {
        const {channel, options} = interaction;

        const welcomeChannel = options.getChannel("channel");
        const welcomeMessage = options.getString("welcome-message");
        const roleId = options.getRole("welcome-role");

        if(!interaction.guild.members.me.permissions.has(PermissionFlagsBits.SendMessages)) {
            interaction.reply({content: "I don't have permissions for this.", ephemeral: true});
        }

        welcomeSchema.findOne({Guild: interaction.guild.id}, async (err, data) => {
            if(!data) {
                const newWelcome = await welcomeSchema.create({
                    Guild: interaction.guild.id,
                    Channel: welcomeChannel.id,
                    Msg: welcomeMessage,
                    Role: roleId.id
                });
            }
            interaction.reply({content: 'Succesfully created a welcome message', ephemeral: true});
        })
    }
}

I tried a few things like changing the construction of the bot or change some thing like the command options.
Thanks in advance!

0

Your Channel argument is invalid, since all names need to be lowercase only. Change it to channel, for example, and it will work.

11
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest