Skip to main content

Variables

This guide will provide you with a comprehensive understanding of variables.

Using Variables

Variables are useful tools in programming that allow you to store values that can be accessed and manipulated throughout your code. To use a variable, you first need to declare it by giving it a name and assigning a value to it.

One way to do this is by using the following code snippet in your main file (usually named index.js):

<AoiClient>..variables({
variableName: boolean,
variableName: number,
variableName: object,
variableName: "string",
}, table?);

The <AoiClient>..variables() function takes an object as an argument, where each property represents a variable name and its corresponding value. You can assign variables to a certain table. However, this is optional and will default to "main".

For example:

index.js
<AoiClient>..variables(
{
blacklisted: false,
money: 0,
developers: {},
title: "none",
},
"main",
);

Variable Handlers

Another way to use variables is by using a variable handler, which can help keep your main file organized and cleaner. To set up a variable handler, follow these steps:

  1. Create a directory called "handler".
  2. Create a file inside the directory named "variables.js".
  3. In your main file, add the following code:
require("./handler/variables.js")(client);
  1. In the variables.js file, create an array of objects, where each object represents a variable name and its corresponding value:
module.exports = (client) => {
client.variables({
variableName: boolean,
variableName: number,
variableName: object,
variableName: "string",
}, table?);
};

For example:

handler/variables.js
module.exports = (client) => {
client.variables(
{
blacklisted: false,
money: 0,
developers: {},
title: "none",
},
"main",
);
};

With these steps, you now have a working variable handler, which can help you keep your code organized and easier to manage.