1 |
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 |
} |