3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

Formatting and initial ButtonRoles DB work

This commit is contained in:
Dark 2021-06-08 02:23:30 +02:00
parent 6ac9d2f2a2
commit 5efdf5ce95
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
108 changed files with 253 additions and 303 deletions

View file

@ -0,0 +1,50 @@
import { getRepository, Repository } from "typeorm";
import { BaseGuildRepository } from "./BaseGuildRepository";
import { ButtonRole } from "./entities/ButtonRole";
export class GuildButtonRoles extends BaseGuildRepository {
private buttonRoles: Repository<ButtonRole>;
constructor(guildId) {
super(guildId);
this.buttonRoles = getRepository(ButtonRole);
}
async getForButtonId(buttonId: string) {
return this.buttonRoles.findOne({
guild_id: this.guildId,
button_id: buttonId,
});
}
async getAllForMessageId(messageId: string) {
return this.buttonRoles.find({
guild_id: this.guildId,
message_id: messageId,
});
}
async removeForButtonId(buttonId: string) {
return this.buttonRoles.delete({
guild_id: this.guildId,
button_id: buttonId,
});
}
async removeAllForMessageId(messageId: string) {
return this.buttonRoles.delete({
guild_id: this.guildId,
message_id: messageId,
});
}
async add(messageId: string, buttonId: string, buttonGroup: string, buttonName: string) {
await this.buttonRoles.insert({
guild_id: this.guildId,
message_id: messageId,
button_id: buttonId,
button_group: buttonGroup,
button_name: buttonName,
});
}
}