1 |
import { GuildMember } from "discord.js"; |
import { GuildMember } from "discord.js"; |
2 |
import DiscordClient from "../client/Client"; |
import DiscordClient from "../client/Client"; |
3 |
|
import BaseCommand from "../utils/structures/BaseCommand"; |
4 |
|
|
5 |
export default class Auth { |
export default class Auth { |
6 |
constructor(protected client: DiscordClient) { |
constructor(protected client: DiscordClient) { |
7 |
|
|
8 |
} |
} |
9 |
|
|
10 |
async verify(member: GuildMember, command: string): Promise<boolean> { |
async verify(member: GuildMember, command: BaseCommand): Promise<boolean> { |
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) !== -1) { |
if (cmds.indexOf(command.getName()) !== -1) { |
14 |
return true; |
return true; |
15 |
} |
} |
16 |
|
|
17 |
|
if (command.ownerOnly && !this.client.config.props.global.owners.includes(member.user.id)) { |
18 |
|
return false; |
19 |
|
} |
20 |
|
|
21 |
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'))) { |
22 |
let restricted: string[] = []; |
let restricted: string[] = []; |
23 |
const roleCommands: { [key: string]: string[] } = await this.client.config.get('role_commands'); |
const roleCommands: { [key: string]: string[] } = await this.client.config.get('role_commands'); |
29 |
} |
} |
30 |
} |
} |
31 |
|
|
32 |
return restricted.indexOf(command) === -1; |
return restricted.indexOf(command.getName()) === -1; |
33 |
} |
} |
34 |
|
|
35 |
return false; |
return false; |