discord.js collections

hello i have two discord collections one for my slash commands and one for my user commands (context menu commands) but im having a issue if i use concat and both commands have the same name, only one is left
async execute(...args: any) {
console.log(`${this.client.user?.tag} is ready`)
const slashCommand = this.client.commands;
const userCommand = this.client.userCommands;
const messageCommand = this.client.messageCommands;
//@ts-ignore
const rest = new REST().setToken(process.env.token);
const globalCommands: any = await rest.put(Routes.applicationCommands("1190649323160088687"), {
body: commands
})
console.log(`successfully loaded `, globalCommands)


}
async execute(...args: any) {
console.log(`${this.client.user?.tag} is ready`)
const slashCommand = this.client.commands;
const userCommand = this.client.userCommands;
const messageCommand = this.client.messageCommands;
//@ts-ignore
const rest = new REST().setToken(process.env.token);
const globalCommands: any = await rest.put(Routes.applicationCommands("1190649323160088687"), {
body: commands
})
console.log(`successfully loaded `, globalCommands)


}
how would i compaine the slashCommand and userCommand and messageCommand collections but also allow for commands to have the same name
3 Replies
d.js toolkit
d.js toolkit5mo 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!
465 | Smith M.
465 | Smith M.5mo ago
is this a bad solution converting into json so concat does not remove the commands with the same name
const slashCommand = this.client.commands.toJSON();
const userCommand = this.client.userCommands.toJSON();
const messageCommand = this.client.messageCommands;
const test = slashCommand.concat(userCommand)
console.log(test)
//@ts-ignore
const rest = new REST().setToken(process.env.token);
const globalCommands: any = await rest.put(Routes.applicationCommands("1190649323160088687"), {
body: test
})
console.log(`successfully loaded `, globalCommands)
const slashCommand = this.client.commands.toJSON();
const userCommand = this.client.userCommands.toJSON();
const messageCommand = this.client.messageCommands;
const test = slashCommand.concat(userCommand)
console.log(test)
//@ts-ignore
const rest = new REST().setToken(process.env.token);
const globalCommands: any = await rest.put(Routes.applicationCommands("1190649323160088687"), {
body: test
})
console.log(`successfully loaded `, globalCommands)
monbrey
monbrey5mo ago
I don't really understand why you're deploying from a collection. It expects an array