1 |
import { GuildMember } from "discord.js"; |
import { GuildMember } from "discord.js"; |
|
import DiscordClient from "../client/Client"; |
|
2 |
import BaseCommand from "../utils/structures/BaseCommand"; |
import BaseCommand from "../utils/structures/BaseCommand"; |
3 |
|
import Service from "../utils/structures/Service"; |
4 |
|
|
5 |
export default class Auth { |
export default class Auth extends Service { |
|
constructor(protected client: DiscordClient) { |
|
|
|
|
|
} |
|
|
|
|
6 |
async verify(member: GuildMember, command: BaseCommand): Promise<boolean> { |
async verify(member: GuildMember, command: BaseCommand): Promise<boolean> { |
7 |
|
if (command.ownerOnly && !this.client.config.props.global.owners.includes(member.user.id)) { |
8 |
|
return false; |
9 |
|
} |
10 |
|
|
11 |
const cmds: string[] = await this.client.config.get('global_commands'); |
const cmds: string[] = await this.client.config.get('global_commands'); |
12 |
|
|
13 |
if (cmds.indexOf(command.getName()) !== -1) { |
if (cmds.indexOf(command.getName()) !== -1) { |
14 |
return true; |
return true; |
15 |
} |
} |
16 |
|
|
|
if (command.ownerOnly && !this.client.config.props.global.owners.includes(member.user.id)) { |
|
|
return false; |
|
|
} |
|
|
|
|
17 |
if (await member.roles.cache.has(await this.client.config.get('mod_role'))) { |
if (await member.roles.cache.has(await this.client.config.get('mod_role'))) { |
18 |
let restricted: string[] = []; |
let restricted: string[] = []; |
19 |
const roleCommands: { [key: string]: string[] } = await this.client.config.get('role_commands'); |
const roleCommands: { [key: string]: string[] } = await this.client.config.get('role_commands'); |