/[sudobot]/trunk/src/services/Auth.ts
ViewVC logotype

Diff of /trunk/src/services/Auth.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 58 by rakin, Mon Jul 29 17:28:25 2024 UTC
# Line 1  Line 1 
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');
# Line 24  export default class Auth { Line 29  export default class Auth {
29                  }                  }
30              }              }
31    
32              return restricted.indexOf(command) === -1;              return restricted.indexOf(command.getName()) === -1;
33          }          }
34    
35          return false;          return false;

Legend:
Removed from v.51  
changed lines
  Added in v.58

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26