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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (hide annotations)
Mon Jul 29 17:28:23 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 858 byte(s)
Release version 2.0
1 rakin 51 import { CommandInteraction, GuildMember, Message, User } from "discord.js";
2     import DiscordClient from "../client/Client";
3     import CommandOptions from "../types/CommandOptions";
4     import InteractionOptions from "../types/InteractionOptions";
5    
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     console.log('here');
11    
12     if (msgInteraction.mentions.users?.at(index))
13     return await msgInteraction.mentions.users?.at(index);
14    
15     console.log(2);
16    
17     const arg = await options.normalArgs[index];
18    
19     if (arg.indexOf('#') !== -1) {
20     return await client.users.cache.find(user => user.tag === arg);
21     }
22    
23     return await client.users.fetch(arg);
24     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26