2019-11-09 00:48:38 +01:00
|
|
|
import { BaseGuildRepository } from "./BaseGuildRepository";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { getRepository, Repository } from "typeorm";
|
2019-11-09 00:48:38 +01:00
|
|
|
import { StarboardReaction } from "./entities/StarboardReaction";
|
|
|
|
|
|
|
|
export class GuildStarboardReactions extends BaseGuildRepository {
|
|
|
|
private allStarboardReactions: Repository<StarboardReaction>;
|
|
|
|
|
|
|
|
constructor(guildId) {
|
|
|
|
super(guildId);
|
|
|
|
this.allStarboardReactions = getRepository(StarboardReaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
async getAllReactionsForMessageId(messageId: string) {
|
|
|
|
return this.allStarboardReactions
|
|
|
|
.createQueryBuilder()
|
|
|
|
.where("guild_id = :gid", { gid: this.guildId })
|
|
|
|
.andWhere("message_id = :msgid", { msgid: messageId })
|
|
|
|
.getMany();
|
|
|
|
}
|
|
|
|
|
|
|
|
async createStarboardReaction(messageId: string, reactorId: string) {
|
|
|
|
await this.allStarboardReactions.insert({
|
|
|
|
message_id: messageId,
|
|
|
|
reactor_id: reactorId,
|
|
|
|
guild_id: this.guildId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteAllStarboardReactionsForMessageId(messageId: string) {
|
|
|
|
await this.allStarboardReactions.delete({
|
|
|
|
guild_id: this.guildId,
|
|
|
|
message_id: messageId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteStarboardReaction(messageId: string, reactorId: string) {
|
|
|
|
await this.allStarboardReactions.delete({
|
|
|
|
guild_id: this.guildId,
|
|
|
|
reactor_id: reactorId,
|
|
|
|
message_id: messageId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|