Skip to content

Commit

Permalink
Made variables method force to use database method
Browse files Browse the repository at this point in the history
  • Loading branch information
Leref committed Sep 27, 2023
1 parent 1e7e21d commit f29c636
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/classes/AoiBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,6 @@ class BaseClient extends Discord.Client {
);
}

if (options.presence?.activities?.length) {
if (
Object.keys(ActivityTypeAvailables).includes(
options.presence?.activities[0].type,
) ||
Object.values(ActivityTypeAvailables).includes(
options.presence?.activities[0].type,
)
) {
options.presence.activities[0].type =
ActivityTypeAvailables[
options.presence?.activities[0].type
] || options.presence?.activities[0].type;
} else {
throw new TypeError(
`Activity Type Error: Invalid Activity Type (${options.presence?.activities[0].type}) Provided`,
);
}
}

options.partials = options.partials || [
Discord.Partials.GuildMember,
Discord.Partials.Channel,
Expand Down Expand Up @@ -105,9 +85,9 @@ class BaseClient extends Discord.Client {
Object.defineProperty(this, "statuses", {value: new Group()});

this.on("ready", async () => {
await require("../handler/NonIntents/ready.js")(this);
await require("../handler/status.js")(this.statuses, this);
await require("../handler/AoiStart.js")(this);
await require("../handler/NonIntents/ready.js")(this);
});
this.login(options.token);
}
Expand Down Expand Up @@ -146,9 +126,13 @@ class BaseClient extends Discord.Client {
* @param {Record<string,string | number | object >} d
* @param table
*/
variables(d, table = this.db.tables[0]) {
variables(d, table = this.db?.tables?.[0]) {
if (this.db === undefined) {
throw new TypeError('A database must be provided to use the variables method.');
}

for (const [name, value] of Object.entries(d)) {
this.variableManager.add({name, value, table});
this.variableManager.add({ name, value, table });
}
}

Expand Down

0 comments on commit f29c636

Please sign in to comment.