mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
[PCCompat > Commands] Only destructure if not empty object (no args given)
This commit is contained in:
parent
9bcf6d59f8
commit
0d68aa88c2
1 changed files with 10 additions and 2 deletions
|
@ -5,8 +5,16 @@ export const registerCommand = ({ command, alias, description, usage, executor }
|
|||
// TODO: implement alias
|
||||
|
||||
goosemodScope.patcher.commands.add(command, description,
|
||||
async ( { args: [ { text } ] } ) => {
|
||||
const out = await executor(text.split(' ')); // Run original executor func (await incase it's an async function)
|
||||
async (ret) => {
|
||||
// Don't just destructure as using without text arguments returns empty object ({})
|
||||
|
||||
let textGiven = '';
|
||||
if (ret.args) {
|
||||
const { args: [ { text } ] } = ret;
|
||||
textGiven = text;
|
||||
}
|
||||
|
||||
const out = await executor(textGiven.split(' ')); // Run original executor func (await incase it's an async function)
|
||||
|
||||
if (!out.send) {
|
||||
goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
|
||||
|
|
Loading…
Reference in a new issue