fix BotFunction's call_context method

previously called by stored template string instead of actual function
This commit is contained in:
Akulij 2025-05-21 12:46:46 +05:00
parent 970ce07280
commit 0dc71fda08

View File

@ -89,13 +89,13 @@ impl BotFunction {
} }
pub fn call_context(&self, runner: &Runner) -> ScriptResult<JsValue> { pub fn call_context(&self, runner: &Runner) -> ScriptResult<JsValue> {
let func_name: &str = self match &self.func {
.func FunctionMarker::Function(f) => {
.as_str_template() let val = f.call(Default::default())?;
.map(|o| o.as_str()) Ok(val)
.unwrap_or(""); }
FunctionMarker::StrTemplate(func_name) => runner.run_script(&format!("{func_name}()")),
runner.run_script(&format!("{func_name}()")) }
} }
pub fn set_js_function(&mut self, f: JsFunction) { pub fn set_js_function(&mut self, f: JsFunction) {