mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 21:35:02 +00:00
Finished Starboard (Pre Override test)
This commit is contained in:
parent
92402662e6
commit
d82f5fbc46
9 changed files with 464 additions and 244 deletions
43
backend/src/data/GuildStarboardReactions.ts
Normal file
43
backend/src/data/GuildStarboardReactions.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { Repository, getRepository } from "typeorm";
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue