table shortcuts are defined dynamically

This commit is contained in:
Erik 2022-05-06 18:42:07 +03:00
parent 113190aceb
commit 5568e1fb52
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 36 additions and 28 deletions

View File

@ -79,6 +79,13 @@ class Provider {
}
this.tables[table.name] = table;
// Defines quick access getter for the table
Object.defineProperty(this, table.name, {
enumerable: true,
get: () => {
return this.tables[table.name];
}
});
this.storageManager._log(`Table ${chalk.bold(table.name)} was ${chalk.bold('loaded')}.`, table);
return table;

View File

@ -48,42 +48,43 @@ class MongoDBProvider extends Provider {
}
get guilds() {
return this.tables.guilds;
}
// Defined by Object.defineProperty in the provider superclass
// get guilds() {
// return this.tables.guilds;
// }
get permissions() {
return this.tables.permissions;
}
// get permissions() {
// return this.tables.permissions;
// }
get infractions() {
return this.tables.infractions;
}
// get infractions() {
// return this.tables.infractions;
// }
get messages() {
return this.tables.messages;
}
// get messages() {
// return this.tables.messages;
// }
get attachments() {
return this.tables.attachments;
}
// get attachments() {
// return this.tables.attachments;
// }
get users() {
return this.tables.users;
}
// get users() {
// return this.tables.users;
// }
// eslint-disable-next-line camelcase
get role_cache() {
return this.tables.role_cache;
}
// // eslint-disable-next-line camelcase
// get role_cache() {
// return this.tables.role_cache;
// }
get webhooks() {
return this.tables.webhooks;
}
// get webhooks() {
// return this.tables.webhooks;
// }
get wordwatcher() {
return this.tables.wordwatcher;
}
// get wordwatcher() {
// return this.tables.wordwatcher;
// }
}