/[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 226 by rakin, Mon Jul 29 17:29:06 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    import Service from "../utils/structures/Service";
5    
6  export default class Auth {  export default class Auth extends Service {
7      constructor(protected client: DiscordClient) {      async verify(member: GuildMember, command: BaseCommand): Promise<boolean> {
   
     }  
   
     async verify(member: GuildMember, command: string): Promise<boolean> {  
8          const cmds: string[] = await this.client.config.get('global_commands');          const cmds: string[] = await this.client.config.get('global_commands');
9    
10          if (cmds.indexOf(command) !== -1) {          if (cmds.indexOf(command.getName()) !== -1) {
11              return true;              return true;
12          }          }
13    
14            if (command.ownerOnly && !this.client.config.props.global.owners.includes(member.user.id)) {
15                return false;
16            }
17    
18          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'))) {
19              let restricted: string[] = [];              let restricted: string[] = [];
20              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 26  export default class Auth {
26                  }                  }
27              }              }
28    
29              return restricted.indexOf(command) === -1;              return restricted.indexOf(command.getName()) === -1;
30          }          }
31    
32          return false;          return false;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26