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: 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; 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); this.storageManager._log(`Table ${chalk.bold(table.name)} was ${chalk.bold('loaded')}.`, table);
return table; return table;

View File

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