Context menu commands not being registered

Hi, on updating to v4 I experienced the following error:
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
I imagined this might be caused by the migration, so I deleted the application command and removed the idHints, but now the context menu won't even register at all. I'm not getting any error or output in the console using the following code:
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: Constants.GUILD_IDS,
}
);
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: Constants.GUILD_IDS,
}
);
Has there been a change I'm missing here?
Solution:
we'll hopefully get this out this week
Jump to solution
22 Replies
Sawako
Sawako•2y ago
pepeHmm
vladdy
vladdy•2y ago
A.......what do you register the command elsewhere too
Fozzie
Fozzie•2y ago
This is very interesting, I have two context menu commands in my application. If I delete the other one as well, I can then create both of them on the next restart:
ApplicationCommandRegistry[banish] Successfully created message context menu guild command "Banish" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[report] Successfully created message context menu guild command "Report" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[banish] Successfully created message context menu guild command "Banish" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[report] Successfully created message context menu guild command "Report" with id "<id>". You should add the id to the "idHints" property of the register method you used!
However, if I then add the idHints and restart again, I get the error back:
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
Interesting that if I remove Banish, but keep Report I don't get an error for Report.
vladdy
vladdy•2y ago
Can youuu get me a small repro sample when you've got time i'll take a look
Fozzie
Fozzie•2y ago
Alright, interestingly it only seems to happen when you're registering multiple context menus. Here's the simplest repro I've found: 1) Start with no context menus 2) Register two at the same time
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Report",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Report",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
}
);
3) Restart
ApplicationCommandRegistry[banish] Successfully created message context menu guild command "Banish" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[report] Successfully created message context menu guild command "Report" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[banish] Successfully created message context menu guild command "Banish" with id "<id>". You should add the id to the "idHints" property of the register method you used!
ApplicationCommandRegistry[report] Successfully created message context menu guild command "Report" with id "<id>". You should add the id to the "idHints" property of the register method you used!
4) Add the idHints
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
idHints: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
idHints: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Report",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
idHints: ["<id>"],
}
);
registry.registerContextMenuCommand(
{
name: "Report",
type: ApplicationCommandType.Message,
},
{
guildIds: ["<id>"],
idHints: ["<id>"],
}
);
5) Restart
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
Looking at the error message, it starts with ApplicationCommandRegistry[report] but the error is actually to do with the Banish context menu.
vladdy
vladdy•2y ago
if it starts with that header its forthat registry but thats confusing did u pass in the wrong ids
Fozzie
Fozzie•2y ago
Nope right ids. Just recreated in v3 and it works fine.
vladdy
vladdy•2y ago
o.o yeah pls make a repo with the repro Prayge
Fozzie
Fozzie•2y ago
I don't know if it's also causing people not to receive context menu interactions in https://discord.com/channels/737141877803057244/1062361081303007282 Wdym?
vladdy
vladdy•2y ago
GitHub
Build software better, together
GitHub is where people build software. More than 94 million people use GitHub to discover, fork, and contribute to over 330 million projects.
Fozzie
Fozzie•2y ago
So you can checkout and run it straight away? Or do you just want to see the surrounding code?
vladdy
vladdy•2y ago
oh i think i already found the bug LOL oh ffs Such a small bug Will PR a fix, are you available to test it?
Fozzie
Fozzie•2y ago
Yea
vladdy
vladdy•2y ago
fyi @Favna we'll need a patch release soon @Fozzie npm install @sapphire/framework@pr-590 I dont think I've spotted a bug this fast in my life
Fozzie
Fozzie•2y ago
Seems to work fine now! Also seems to work when registering them independently as well.
vladdy
vladdy•2y ago
Sawako
Sawako•2y ago
Fozzie
Fozzie•2y ago
Thanks for your help 😉
vladdy
vladdy•2y ago
ty for the report
Solution
vladdy
vladdy•2y ago
we'll hopefully get this out this week
Favna
Favna•2y ago
You'll get there eventually