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:
parent
6ac9d2f2a2
commit
5efdf5ce95
108 changed files with 253 additions and 303 deletions
50
backend/src/data/GuildButtonRoles.ts
Normal file
50
backend/src/data/GuildButtonRoles.ts
Normal 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,
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue