/[sudobot]/trunk/src/utils/getUser.ts
ViewVC logotype

Diff of /trunk/src/utils/getUser.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 186 by rakin, Mon Jul 29 17:28:56 2024 UTC
# Line 2  import { CommandInteraction, GuildMember Line 2  import { CommandInteraction, GuildMember
2  import DiscordClient from "../client/Client";  import DiscordClient from "../client/Client";
3  import CommandOptions from "../types/CommandOptions";  import CommandOptions from "../types/CommandOptions";
4  import InteractionOptions from "../types/InteractionOptions";  import InteractionOptions from "../types/InteractionOptions";
5    import { parseUser } from './parseInput';
6    
7  export default async function getUser(client: DiscordClient, msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<User | null | undefined> {  export default async function getUser(client: DiscordClient, msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<User | null | undefined> {
8      if (options.normalArgs[index] === undefined)      if (options.normalArgs[index] === undefined)
9          return null;          return null;
10            
     console.log('here');  
       
     if (msgInteraction.mentions.users?.at(index))  
         return await msgInteraction.mentions.users?.at(index);  
   
     console.log(2);  
       
11      const arg = await options.normalArgs[index];      const arg = await options.normalArgs[index];
12    
13        console.log(arg);
14    
15      if (arg.indexOf('#') !== -1) {      if (arg.indexOf('#') !== -1) {
16          return await client.users.cache.find(user => user.tag === arg);          return await client.users.cache.find(user => user.tag === arg);
17      }      }
18    
     return await client.users.fetch(arg);  
 }  
19        const parsed = await parseUser(client, arg);
20    
21        if (parsed) {
22            return parsed;
23        }
24    
25        try {
26            const u = await client.users.fetch(arg);
27            return u;
28        }
29        catch (e) {
30            console.log(e);
31            return null;
32        }
33    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26