From d95f20db3f716eacc80eb08f008788b4803a76e6 Mon Sep 17 00:00:00 2001 From: Oj Date: Sun, 4 Apr 2021 15:29:20 +0100 Subject: [PATCH] [PCCompat > Entities] Global: Add api.commands.registerCommand --- moduleWrappers/powercord/entities.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/moduleWrappers/powercord/entities.js b/moduleWrappers/powercord/entities.js index 62edd0a..1e939f8 100644 --- a/moduleWrappers/powercord/entities.js +++ b/moduleWrappers/powercord/entities.js @@ -1,3 +1,23 @@ +// Also set Powercord global var stuff here since entities import is needed to use Plugin (which every PC plugin uses) + +window.powercord = { + api: { + commands: { + registerCommand: ({ command, description, _usage, executor }) => { + goosemodScope.patcher.commands.add(command, description, + ( { message: [ { text } ] } ) => { + const out = executor(text.split(' ')); // Run original executor func + + if (!out.send) return; // PC impl. sends internal message when out.send === true, so we also do the same via our previous Patcher API function, seen below + goosemodScope.patcher.internalMessage(out.result); + }, [ + { type: 3, required: false, name: 'args', description: 'Arguments for PC command' } // Argument for any string for compat. with PC's classical commands + ]) + } + } + } +}; + export class Plugin { constructor() {