Skip to main content

script 执行脚本

script

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

执行脚本

参数

参数名类型描述默认值
\{ script \}{ script: string }--

返回值

类型: CommandFunction | null

源代码

位置: 第 9003 行

protected script({ script }: { script: string }): CommandFunction | null {
const method = this.script as any;
let { escape } = method;
if (escape === undefined) {
escape =
/(?<=(?:[^\p{L}$_\d\s]|\n|^)\s*)\(\s*([\p{L}$_\d]+)\s*\)(?!\s*=>)/gu;
method.escape = escape;
}
try {
const code = script.replace(escape, 'CurrentEvent.attributes["$1"]');
const fn = new Function(code);
return () => (fn(), true);
} catch {
return null;
}
}

文档生成时间:2026/2/1 16:51:39