Pr Stuff
Some checks failed
Release / Build Equicord (push) Has been cancelled
Sync to Codeberg / Sync Codeberg and Github (push) Has been cancelled
Test / Test (push) Has been cancelled

Co-Authored-By: sadan4 <117494111+sadan4@users.noreply.github.com>
This commit is contained in:
thororen1234 2025-03-05 23:01:08 -05:00
parent 8c2bfea5c0
commit 4f72832ba1
No known key found for this signature in database
7 changed files with 50 additions and 7 deletions

View file

@ -44,11 +44,16 @@ export let OptionalMessageOption: Option = OptPlaceholder;
*/
export let RequiredMessageOption: Option = ReqPlaceholder;
// Discords command list has random gaps for some reason, which can cause issues while rendering the commands
// add this offset too every added command to keep them unique
let commandIdOffset: number;
export const _init = function (cmds: Command[]) {
try {
BUILT_IN = cmds;
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
commandIdOffset = Math.abs(BUILT_IN.map(x => +x.id!).toSorted((x, y) => x - y)[0]) - BUILT_IN.length;
} catch (e) {
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
}
@ -142,7 +147,7 @@ export function registerCommand<C extends Command>(command: C, plugin: string) {
command.isVencordCommand = true;
command.untranslatedName ??= command.name;
command.untranslatedDescription ??= command.description;
command.id ??= `-${BUILT_IN.length + 1}`;
command.id ??= `-${BUILT_IN.length + commandIdOffset + 1}`;
command.applicationId ??= "-1"; // BUILT_IN;
command.type ??= ApplicationCommandType.CHAT_INPUT;
command.inputType ??= ApplicationCommandInputType.BUILT_IN_TEXT;