mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Split BaseRepository into non-guild and guild
BaseRepository includes all the non-guild-specific functionality, such as with() and getRelations(). BaseGuildRepository includes guild-specific functionality, such as getInstance().
This commit is contained in:
parent
1aa549e391
commit
d54897acdd
39 changed files with 162 additions and 156 deletions
|
@ -1,9 +1,9 @@
|
|||
import { BaseRepository } from "./BaseRepository";
|
||||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { getRepository, Repository } from "typeorm";
|
||||
import { Starboard } from "./entities/Starboard";
|
||||
import { StarboardMessage } from "./entities/StarboardMessage";
|
||||
|
||||
export class GuildStarboards extends BaseRepository {
|
||||
export class GuildStarboards extends BaseGuildRepository {
|
||||
private starboards: Repository<Starboard>;
|
||||
private starboardMessages: Repository<StarboardMessage>;
|
||||
|
||||
|
@ -17,8 +17,8 @@ export class GuildStarboards extends BaseRepository {
|
|||
return this.starboards.findOne({
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
channel_id: channelId
|
||||
}
|
||||
channel_id: channelId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ export class GuildStarboards extends BaseRepository {
|
|||
return this.starboards.find({
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
emoji
|
||||
}
|
||||
emoji,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ export class GuildStarboards extends BaseRepository {
|
|||
relations: this.getRelations(),
|
||||
where: {
|
||||
starboard_id: starboardId,
|
||||
message_id: messageId
|
||||
}
|
||||
message_id: messageId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ export class GuildStarboards extends BaseRepository {
|
|||
return this.starboardMessages.find({
|
||||
relations: this.getRelations(),
|
||||
where: {
|
||||
message_id: id
|
||||
}
|
||||
message_id: id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,14 +54,14 @@ export class GuildStarboards extends BaseRepository {
|
|||
await this.starboardMessages.insert({
|
||||
starboard_id: starboardId,
|
||||
message_id: messageId,
|
||||
starboard_message_id: starboardMessageId
|
||||
starboard_message_id: starboardMessageId,
|
||||
});
|
||||
}
|
||||
|
||||
async deleteStarboardMessage(starboardId, messageId): Promise<void> {
|
||||
await this.starboardMessages.delete({
|
||||
starboard_id: starboardId,
|
||||
message_id: messageId
|
||||
message_id: messageId,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -71,14 +71,14 @@ export class GuildStarboards extends BaseRepository {
|
|||
channel_id: channelId,
|
||||
channel_whitelist: channelWhitelist ? channelWhitelist.join(",") : null,
|
||||
emoji,
|
||||
reactions_required: reactionsRequired
|
||||
reactions_required: reactionsRequired,
|
||||
});
|
||||
}
|
||||
|
||||
async delete(channelId: string): Promise<void> {
|
||||
await this.starboards.delete({
|
||||
guild_id: this.guildId,
|
||||
channel_id: channelId
|
||||
channel_id: channelId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue