Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Fozzie
Fozzie1/10/2023
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


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,
  }
);


Has there been a change I'm missing here?
kaname-png
kaname-png1/10/2023
@139836912335716352
kaname-png
kaname-png1/10/2023
:pepeHmm:
Vladdy
Vladdy1/10/2023
A.......what
Vladdy
Vladdy1/10/2023
do you register the command elsewhere too
kaname-png
kaname-png1/10/2023
Fozzie
Fozzie1/10/2023
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!


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


Interesting that if I remove Banish, but keep Report I don't get an error for Report.
Vladdy
Vladdy1/10/2023
Can youuu get me a small repro sample
Vladdy
Vladdy1/10/2023
when you've got time
Vladdy
Vladdy1/10/2023
i'll take a look
Fozzie
Fozzie1/10/2023
Alright, interestingly it only seems to happen when you're registering multiple context menus.
Fozzie
Fozzie1/10/2023
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: "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!


4) Add the idHints
registry.registerContextMenuCommand(
  {
    name: "Banish",
    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
Fozzie
Fozzie1/10/2023
Looking at the error message, it starts with ApplicationCommandRegistry[report] but the error is actually to do with the Banish context menu.
Vladdy
Vladdy1/10/2023
if it starts with that header its forthat registry but thats confusing
Vladdy
Vladdy1/10/2023
did u pass in the wrong ids
Fozzie
Fozzie1/10/2023
Nope right ids.
Fozzie
Fozzie1/10/2023
Just recreated in v3 and it works fine.
Vladdy
Vladdy1/10/2023
o.o
Vladdy
Vladdy1/10/2023
yeah pls make a repo with the repro :Prayge:
Fozzie
Fozzie1/10/2023
I don't know if it's also causing people not to receive context menu interactions in https://discord.com/channels/737141877803057244/1062361081303007282
Fozzie
Fozzie1/10/2023
Wdym?
Vladdy
Vladdy1/10/2023
Fozzie
Fozzie1/10/2023
So you can checkout and run it straight away? Or do you just want to see the surrounding code?
Vladdy
Vladdy1/10/2023
oh i think i already found the bug
Vladdy
Vladdy1/10/2023
LOL
Vladdy
Vladdy1/10/2023
oh ffs
Vladdy
Vladdy1/10/2023
Such a small bug
Vladdy
Vladdy1/10/2023
Will PR a fix, are you available to test it?
Fozzie
Fozzie1/10/2023
Yea
Vladdy
Vladdy1/10/2023
fyi @268792781713965056 we'll need a patch release soon
Vladdy
Vladdy1/10/2023
@259745940972240896 npm install @sapphire/framework@pr-590
Vladdy
Vladdy1/10/2023
I dont think I've spotted a bug this fast in my life
Fozzie
Fozzie1/10/2023
Seems to work fine now! Also seems to work when registering them independently as well.
Vladdy
Vladdy1/10/2023
kaname-png
kaname-png1/10/2023
Fozzie
Fozzie1/10/2023
Thanks for your help 😉
Vladdy
Vladdy1/10/2023
ty for the report
Vladdy
Vladdy1/10/2023
we'll hopefully get this out this week
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy