3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 23:09:59 +00:00
zeppelin/src/data/GuildSelfGrantableRoles.ts

39 lines
1 KiB
TypeScript
Raw Normal View History

2019-02-19 00:02:46 +02:00
import { BaseRepository } from "./BaseRepository";
import { getRepository, Repository } from "typeorm";
import { SelfGrantableRole } from "./entities/SelfGrantableRole";
export class GuildSelfGrantableRoles extends BaseRepository {
private selfGrantableRoles: Repository<SelfGrantableRole>;
constructor(guildId) {
super(guildId);
this.selfGrantableRoles = getRepository(SelfGrantableRole);
}
async getForChannel(channelId: string): Promise<SelfGrantableRole[]> {
return this.selfGrantableRoles.find({
where: {
guild_id: this.guildId,
channel_id: channelId,
},
});
}
async delete(channelId: string, roleId: string) {
await this.selfGrantableRoles.delete({
guild_id: this.guildId,
channel_id: channelId,
role_id: roleId,
});
}
async add(channelId: string, roleId: string, aliases: string[]) {
await this.selfGrantableRoles.insert({
guild_id: this.guildId,
channel_id: channelId,
role_id: roleId,
aliases,
});
}
}