mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Add SelfGrantableRoles
This commit is contained in:
parent
8cb382979b
commit
457d57fb8c
6 changed files with 368 additions and 5 deletions
38
src/data/GuildSelfGrantableRoles.ts
Normal file
38
src/data/GuildSelfGrantableRoles.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
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,
|
||||
});
|
||||
}
|
||||
}
|
16
src/data/entities/SelfGrantableRole.ts
Normal file
16
src/data/entities/SelfGrantableRole.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Entity, Column, PrimaryColumn } from "typeorm";
|
||||
|
||||
@Entity("self_grantable_roles")
|
||||
export class SelfGrantableRole {
|
||||
@Column()
|
||||
@PrimaryColumn()
|
||||
id: number;
|
||||
|
||||
@Column() guild_id: string;
|
||||
|
||||
@Column() channel_id: string;
|
||||
|
||||
@Column() role_id: string;
|
||||
|
||||
@Column("simple-array") aliases: string[];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue