Skip to content

Commit

Permalink
fix(InMemoryProvider): consistency
Browse files Browse the repository at this point in the history
- removes useless functions
- fixes async/Promise.resolve inconsistency
  • Loading branch information
Khaaz committed Feb 18, 2020
1 parent a88dda2 commit b854f61
Showing 1 changed file with 16 additions and 42 deletions.
58 changes: 16 additions & 42 deletions src/Database/InMemoryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,40 @@ import GuildConfig from '../Structures/DataStructure/GuildConfig';
* @extends ADBProvider
*/
class InMemoryProvider extends ADBProvider {
async fetchAxon() {
let axon = this.axon.axonConfig;
if (!axon) {
axon = await this.initAxon();
}
return Promise.resolve(axon);
}

init() {
return;
}

async fetchGuild(gID) {
let guild = this.axon.guildConfigs.get(gID);
if (!guild) {
guild = await this.initGuild(gID);
async fetchAxon() {
let { axonConfig } = this.axon;
if (!axonConfig) {
axonConfig = await this.initAxon();
}
return guild;
}

initAxon() {
this.axon.axonConfig = new AxonConfig(this.axon, {} );
return Promise.resolve(this.axon.axonConfig);
}

initGuild(gID) {
return Promise.resolve(new GuildConfig(this.axon, { guildID: gID } ) );
return axonConfig;
}

async updateBlacklistUser(blacklistedUsers) {
return this.updateAxon('bannedUsers', blacklistedUsers);
}

async updateBlacklistGuild(blacklistedGuilds) {
return this.updateAxon('bannedGuilds', blacklistedGuilds);
}

async updateGuildPrefix(gID, prefixArr) {
return this.updateGuild('prefixes', gID, prefixArr);
}

updateModule(gID, modulesArr) {
return this.updateGuild('modules', gID, modulesArr);
async fetchGuild(gID) {
let guildConfig = this.axon.guildConfigs.get(gID);
if (!guildConfig) {
guildConfig = await this.initGuild(gID);
}
return guildConfig;
}

updateCommand(gID, commandArr) {
return this.updateGuild('commands', gID, commandArr);
async initAxon() {
return new AxonConfig(this.axon, {} );
}

async updateEvent(gID, eventArr) {
return this.updateGuild('listeners', gID, eventArr);
async initGuild(gID) {
return new GuildConfig(this.axon, { guildID: gID } );
}

async saveAxon(axonSchema) {
return new AxonConfig(this.axon, axonSchema);
}

async saveGuild(gID, guildSchema) {
const guildConfig = new GuildConfig(this.axon, guildSchema);
return guildConfig;
return new GuildConfig(this.axon, guildSchema);
}

async updateGuild(key, gID, value) {
Expand Down

0 comments on commit b854f61

Please sign in to comment.