mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 20:55:01 +00:00
38 lines
1,015 B
TypeScript
38 lines
1,015 B
TypeScript
import { Repository } from "typeorm";
|
|
import { BaseGuildRepository } from "./BaseGuildRepository";
|
|
import { dataSource } from "./dataSource";
|
|
import { RoleButtonsItem } from "./entities/RoleButtonsItem";
|
|
|
|
export class GuildRoleButtons extends BaseGuildRepository {
|
|
private roleButtons: Repository<RoleButtonsItem>;
|
|
|
|
constructor(guildId) {
|
|
super(guildId);
|
|
this.roleButtons = dataSource.getRepository(RoleButtonsItem);
|
|
}
|
|
|
|
getSavedRoleButtons(): Promise<RoleButtonsItem[]> {
|
|
return this.roleButtons.find({
|
|
where: {
|
|
guild_id: this.guildId,
|
|
},
|
|
});
|
|
}
|
|
|
|
async deleteRoleButtonItem(name: string): Promise<void> {
|
|
await this.roleButtons.delete({
|
|
guild_id: this.guildId,
|
|
name,
|
|
});
|
|
}
|
|
|
|
async saveRoleButtonItem(name: string, channelId: string, messageId: string, hash: string): Promise<void> {
|
|
await this.roleButtons.insert({
|
|
guild_id: this.guildId,
|
|
name,
|
|
channel_id: channelId,
|
|
message_id: messageId,
|
|
hash,
|
|
});
|
|
}
|
|
}
|