Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/structures/forge/ForgeFunction.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions dist/structures/forge/ForgeFunction.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/structures/forge/ForgeFunction.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/structures/forge/ForgeFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ForgeFunction {
const params = await this["resolveMultipleArgs"](ctx, ...this.data.fields.slice(1).map((_, i) => i + 1))
if (!this["isValidReturnType"](params.return))
return params.return
return outer.call(ctx, this, params.args)
return outer.call(ctx, this, [condition.value as string, ...params.args])
Comment thread
xNickyDev marked this conversation as resolved.
} else {
return outer.call(ctx, this, args ?? [])
}
Expand All @@ -91,17 +91,20 @@ export class ForgeFunction {
)
)

const functionCtx = ctx.clone({
doNotSend: true,
allowTopLevelReturn: true,
data: this.compiled
})

for (let i = 0, len = params.length; i < len; i++) {
const param = params[i]
const name = typeof param === "string" ? param : param.name
ctx.setEnvironmentKey(name, args[i])

functionCtx.setEnvironmentKey(name, args[i])
}

const result = await Interpreter.run(ctx.clone({
doNotSend: true,
allowTopLevelReturn: true,
data: this.compiled
}))
const result = await Interpreter.run(functionCtx)

return result === null ? fn.stop() : fn.success(result)
}
Expand Down
Loading