Failed to overwrite global application commands

Since updating to BulkOverwrite, I'm getting the following error:
2023-01-12 22:00:07 - DEBUG - ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 6 commands
2023-01-12 22:00:07 - ERROR - ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite global application commands DiscordAPIError[50035]: Invalid Form Body
2023-01-12 22:00:07 - ERROR - 2[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique
2023-01-12 22:00:07 - DEBUG - ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 6 commands
2023-01-12 22:00:07 - ERROR - ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite global application commands DiscordAPIError[50035]: Invalid Form Body
2023-01-12 22:00:07 - ERROR - 2[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique
Solution:
you're calling registerChatInputCommand twice ergo, twice a command with the same name...
Jump to solution
7 Replies
Freakspot
Freakspot2y ago
I've only got two command files in my commands directory. I suspected previous slash commands being an issue, but I've tried manually deleting those through the REST API to no avail. I'd highly appreciate any help. :)
Favna
Favna2y ago
Application command names must be unique
Freakspot
Freakspot2y ago
Well I'm not trying to register any equally named commands and before enabling BulkOverwrite, I didn't have this issue.
Freakspot
Freakspot2y ago
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ChannelType } from 'discord.js';
const { fetch } = require('undici');

@ApplyOptions<Command.Options>({
description: 'Does some things.'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
// Register slash command
registry.registerChatInputCommand({
name: this.name,
description: this.description
});

registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description).addStringOption((option) => option.setName('game').setDescription('Provide a game to add to gaming-list').setRequired(true)));
}

// slash command
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const nameOfGameOld = interaction.options.getString('game');
await interaction.reply({
content: `Looking for game "${nameOfGameOld}"`
});

// TODO: find ID programmatically rather than set it here
const channel = await interaction.guild?.channels.cache.get(ValidIdIsHere);

// Should never happen as long as ID is provided manually
if (channel?.type !== ChannelType.GuildForum) {
return;
}

const response = await fetch(`https://api.steampowered.com/ISteamApps/GetAppList/v2?format=json`);
const { applist } = await response.json();
const results = applist.apps.filter((app: any) => app.name === nameOfGameOld);

if (!results || results.length === 0) {
return await interaction.editReply({
content: 'Could not find any games matching your query!'
});
}
return await interaction.editReply({ content: `Created an entry for "${nameOfGameOld}"` });
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ChannelType } from 'discord.js';
const { fetch } = require('undici');

@ApplyOptions<Command.Options>({
description: 'Does some things.'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
// Register slash command
registry.registerChatInputCommand({
name: this.name,
description: this.description
});

registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description).addStringOption((option) => option.setName('game').setDescription('Provide a game to add to gaming-list').setRequired(true)));
}

// slash command
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const nameOfGameOld = interaction.options.getString('game');
await interaction.reply({
content: `Looking for game "${nameOfGameOld}"`
});

// TODO: find ID programmatically rather than set it here
const channel = await interaction.guild?.channels.cache.get(ValidIdIsHere);

// Should never happen as long as ID is provided manually
if (channel?.type !== ChannelType.GuildForum) {
return;
}

const response = await fetch(`https://api.steampowered.com/ISteamApps/GetAppList/v2?format=json`);
const { applist } = await response.json();
const results = applist.apps.filter((app: any) => app.name === nameOfGameOld);

if (!results || results.length === 0) {
return await interaction.editReply({
content: 'Could not find any games matching your query!'
});
}
return await interaction.editReply({ content: `Created an entry for "${nameOfGameOld}"` });
}
}
This is the content of a file located in src/commands/General; without this file present, the error does not pop up
Solution
Favna
Favna2y ago
you're calling registerChatInputCommand twice ergo, twice a command with the same name
Freakspot
Freakspot2y ago
Ohh, I understand how it should be. That's such an obvious mistake to me now. Thank you very much!