2023-11-20 00:27:23 +01:00
|
|
|
import { Guild, Role, User } from "discord.js";
|
2023-11-20 00:17:02 +01:00
|
|
|
import { ExtendedClient } from "../structures/client";
|
2023-11-20 00:27:23 +01:00
|
|
|
import { GuildMember } from "discord.js";
|
2023-11-20 00:17:02 +01:00
|
|
|
|
|
|
|
export default class RoleController {
|
|
|
|
|
|
|
|
constructor(private client: ExtendedClient) { }
|
|
|
|
private getMediaRoleForGuild(guildId: string): Role {
|
|
|
|
throw new Error("Method not implemented.");
|
|
|
|
}
|
2023-11-20 00:27:23 +01:00
|
|
|
public async addRoleToUser(member: GuildMember, role: Role, guildId: string, requestId: string) {
|
|
|
|
return await member.roles.add(role)
|
2023-11-20 00:17:02 +01:00
|
|
|
}
|
2023-11-20 00:27:23 +01:00
|
|
|
private async removeRoleFromUser(member: GuildMember, role: any, guildId: string, requestId: string) {
|
|
|
|
return await member.roles.remove(role)
|
2023-11-20 00:17:02 +01:00
|
|
|
}
|
|
|
|
|
2023-11-20 00:27:23 +01:00
|
|
|
public async addMediaRoleToUser(user: User, guild: Guild, requestId: string) {
|
|
|
|
const roleToAdd: Role = this.getMediaRoleForGuild(guild.id)
|
|
|
|
const guildMember = await guild.members.fetch(user)
|
|
|
|
return this.addRoleToUser(guildMember, roleToAdd, guild.id, requestId)
|
2023-11-20 00:17:02 +01:00
|
|
|
}
|
2023-11-20 00:27:23 +01:00
|
|
|
public async removeMediaRoleFromUser(user: User, guild: Guild, requestId: string) {
|
|
|
|
const roleToRemove: Role = this.getMediaRoleForGuild(guild.id)
|
|
|
|
const guildMember = await guild.members.fetch(user)
|
|
|
|
return this.removeRoleFromUser(guildMember, roleToRemove, guild.id, requestId)
|
2023-11-20 00:17:02 +01:00
|
|
|
}
|
|
|
|
}
|