$getGlobalUserObjectVar
Returns the value of a property from a global user variable object.
Usage
$getGlobalUserObjectVar[varname;property;userID?;table?]
Parameters
varname
- The variable name.
property
- The name of the property.
userID?
- The user ID. (Optional)
table?
- Variable table. (Optional)
Source Code
module.exports = {
name: "$getGlobalUserObjectVar",
type: "djs",
code: async d => {
const data = d.util.aoiFunc(d);
let [varname, property, userID = d.author?.id, table = d.client.db.tables[0]] = data.inside.splits;
varname = varname.addBrackets();
if (!d.client.variableManager.has(varname, table)) return d.aoiError.fnError(d, 'custom', {}, `Variable "${varname}" Not Found`);
let variable = (await d.client.db.get(table, varname, userID))?.value || d.client.variableManager.get(varname, table)?.default;
if (typeof variable === 'object') {
if (variable.hasOwnProperty(property)) {
data.result = variable[property];
} else {
return d.aoiError.fnError(d, 'custom', {}, `Property "${property}" Not Found`);
}
} else {
return d.aoiError.fnError(d, 'custom', {}, `Variable "${varname}" Not Object`);
}
return {
code: d.util.setCode(data)
}
}
}
What is an object variable?
An object variable is a variable that holds a reference to an object. Objects are collections of key-value pairs, where keys are strings (or symbols), and values can be any data type, including other objects or primitive values like strings or numbers. This type of variable can be created through this method:
<AoiClient>.variables({
varname: {
key: value
}
});