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

Annotation of /trunk/src/utils/getUser.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (hide annotations)
Mon Jul 29 17:29:40 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 845 byte(s)
chore: eslint autofix
1 rakin 344 import { Message, User } from "discord.js";
2 rakin 51 import DiscordClient from "../client/Client";
3     import CommandOptions from "../types/CommandOptions";
4 rakin 186 import { parseUser } from './parseInput';
5 rakin 51
6     export default async function getUser(client: DiscordClient, msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<User | null | undefined> {
7     if (options.normalArgs[index] === undefined)
8     return null;
9    
10     const arg = await options.normalArgs[index];
11    
12 rakin 186 console.log(arg);
13    
14 rakin 51 if (arg.indexOf('#') !== -1) {
15     return await client.users.cache.find(user => user.tag === arg);
16     }
17    
18 rakin 186 const parsed = await parseUser(client, arg);
19    
20     if (parsed) {
21     return parsed;
22     }
23    
24     try {
25     const u = await client.users.fetch(arg);
26     return u;
27     }
28     catch (e) {
29     console.log(e);
30     return null;
31     }
32     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26