@getsolara/solara.db
Version:
Optional database functionality for @getsolara/solara.js using quick.db
21 lines • 755 B
JavaScript
module.exports = {
name: "$getAllVars",
description: "Returns JSON string of all vars in scope. Args: [scope=local]",
takesBrackets: true,
execute: async (context, args) => {
const scope = args[0]?.trim().toLowerCase() || 'local';
let vars = {};
if (scope === 'local') {
vars = Object.fromEntries(context.localVariables || new Map());
} else if (scope === 'global') {
vars = Object.fromEntries(context.client.variables || new Map());
} else {
return "[Error: Invalid scope for $getAllVars. Use 'local' or 'global']";
}
try {
return JSON.stringify(vars);
} catch {
return "{}";
}
}
};