From 5ac243c3c0a638e8eb7061fadbc9bccf36b363a8 Mon Sep 17 00:00:00 2001 From: CanadaHonk Date: Mon, 19 Sep 2022 16:40:23 +0100 Subject: [PATCH] [Patcher > Commands] Ensure new displayName --- src/util/patcher/commands.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/util/patcher/commands.js b/src/util/patcher/commands.js index ea2e1584..c66fd4b8 100644 --- a/src/util/patcher/commands.js +++ b/src/util/patcher/commands.js @@ -11,26 +11,26 @@ export const setThisScope = (scope) => { const iconManager = goosemod.webpackModules.findByProps('getIconComponent'); const ApplicationCommandItem = goosemod.webpackModules.find(x => x.default?.displayName === 'ApplicationCommandItem'); const searchManager = goosemod.webpackModules.findByProps('useSearchManager'); - + const section = { id: applicationId, type: 0, name: 'GooseMod' }; goosemod.patcher.patch(iconManager, 'getIconComponent', ([ section ]) => { // Custom icon for sidebar/general if (section.id === applicationId) return (e) => React.createElement('div', { className: 'wrapper-1wwiGV selectable-fgiA2c', style: { width: e.width, height: e.height, padding: e.padding ?? 0 } }, React.createElement('img', { src: 'https://goosemod.com/img/logo.jpg', style: { width: e.width, height: e.height, borderRadius: '50%' }, className: 'icon-1kx1ir' })); }); - + goosemod.patcher.patch(ApplicationCommandItem, 'default', ([ { command }], ret) => { // Custom icon in commands/results if (command.applicationId === applicationId) ret.props.children[0] = React.createElement('div', { className: 'wrapper-3t15Cn image-1a_IXB', style: { width: 32, height: 32 } }, React.createElement('img', { src: 'https://goosemod.com/img/logo.jpg', style: { width: 32, height: 32, borderRadius: '50%' }, className: 'icon-1kx1ir' })); - + return ret; }); - + goosemod.patcher.patch(searchManager, 'useSearchManager', (args, ret) => { const gmCommands = Object.values(Commands.BUILT_IN_COMMANDS).filter(x => x.applicationId === applicationId); if (gmCommands.length === 0) return ret; // No GM commands, don't add if (!ret.activeSections.find(x => x.id === section.id)) ret.activeSections.push(section); if (!ret.sectionDescriptors.find(x => x.id === section.id)) ret.sectionDescriptors.push(section); // Add to sections sidebar - + let currentSection = ret.commandsByActiveSection.find(x => x.section.id === section.id); if (currentSection) currentSection.data = gmCommands; else if ((ret.filteredSectionId == null || ret.filteredSectionId === applicationId)) ret.commandsByActiveSection.push({ section, data: gmCommands }); // Add our section to commands @@ -39,7 +39,7 @@ export const setThisScope = (scope) => { const builtin = ret.commandsByActiveSection.find(x => x.section.id === '-1'); builtin.data = builtin.data.filter(x => x.applicationId !== applicationId); } - + return ret; }); }; @@ -49,6 +49,10 @@ const applicationId = "-3"; export const add = (name, description, execute, options = []) => { const mod = Commands; + for (const o of options) { + o.displayName = o.displayName ?? o.name; // ensure displayName or crash + } + mod.BUILT_IN_COMMANDS.push({ applicationId,