Not loading ban command

With the basic command ping it works but with ban.js it doesn't. ping.js that works:
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Testing 2'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Testing 2'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
ban.js that doens't:
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban a member')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to ban')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false)
};
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban a member')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to ban')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false)
};
But if i put the same configuration as i have done with the ping command it works, but adding the .addUserOption it doesn't appear when i write /
11 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna4mo ago
how are you deploying your commands
Developer
DeveloperOP4mo ago
nodemon
treble/luna
treble/luna4mo ago
not quite what i meant what code is responsible for loading your commands
Developer
DeveloperOP4mo ago
you mean about the rest.put ?
treble/luna
treble/luna4mo ago
yes
Developer
DeveloperOP4mo ago
const rest = new REST({ version: '10' }).setToken(TOKEN);

(async () => {
try {
const commands = Array.from(client.commands.values()).map(command => command.data.toJSON());

console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationCommands(CLIENT_ID),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();
const rest = new REST({ version: '10' }).setToken(TOKEN);

(async () => {
try {
const commands = Array.from(client.commands.values()).map(command => command.data.toJSON());

console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationCommands(CLIENT_ID),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();
treble/luna
treble/luna4mo ago
first of all, this script is meant to be run separately, you should not have a client in there and run it at every start second, did you refresh your discord client and are you sure the command is actually being passed inthe body
Developer
DeveloperOP4mo ago
It should be passed as ping command does
treble/luna
treble/luna4mo ago
and have you confirmed it
Developer
DeveloperOP4mo ago
If i create any file with the same configuration as the ping one it works fine, same for the ban command, but the ban command appears only if i delete the .addUserOption Resolved ✅
Want results from more Discord servers?
Add your server