#Help with Registering Slash Commands

11 messages · Page 1 of 1 (latest)

violet hare
#

that isnt how you structure a slash command

#

a description is also required

#

please read the guide

solemn condor
solemn condor
# violet hare that isnt how you structure a slash command
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
    command: new SlashCommandBuilder()
        .setName("stars")
        .setDescription(`Manage a member's Stars`)
        .setDMPermission(false)
        .addSubcommand(subcommand =>{
            subcommand
                .setName('add')
                .setDescription(`Add Stars to a member's balance`)
                .addUserOption(user =>{
                    user
                        .setName("user")
                        .setDescription(`The user you are giving stars to`)
                        .setRequired(true)
                })
                .addStringOption(amount =>{
                    amount
                        .setName("amount")
                        .setDescription(`The amount of stars you are giving`)
                        .setRequired(true)
                })
        })
}
violet hare
solemn condor
# violet hare show me where you deploy the command
const { REST } = require('@discordjs/rest');
const { Routes, SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { token, clientId, guildId } = require('./JSON/config.json');

const rest = new REST({ version: '10' }).setToken(token);
const fs = require("fs");

rest.on("rateLimited", console.log).on("restDebug", console.log);

const commandFiles = fs.readdirSync("./slash-commands/");
const commands = []

for(const commandFile of commandFiles){
    const cmdData = require(`./slash-commands/${commandFile}`);

    commands.push(cmdData.command);
}
commands.map(cmd => cmd.toJSON());

rest.put(
    Routes.applicationGuildCommands(clientId, guildId),
    { body: commands }
)
.catch(console.error)
#

like i said, this works for my other bots

thick verge
#

u didnt return the user option inside addUserOption method

#

since u use a bracket u must return it

solemn condor
#

Okay