1 |
import { CommandInteraction, GuildMember, Message, User } from "discord.js"; |
2 |
import CommandOptions from "../types/CommandOptions"; |
3 |
|
4 |
export default async function getMember(msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<GuildMember | null | undefined> { |
5 |
if (options.normalArgs[index] === undefined) |
6 |
return null; |
7 |
|
8 |
console.log('here'); |
9 |
|
10 |
if (msgInteraction.mentions.members?.at(index)) |
11 |
return await msgInteraction.mentions.members?.at(index); |
12 |
|
13 |
console.log(2); |
14 |
|
15 |
|
16 |
const arg = await options.normalArgs[index]; |
17 |
|
18 |
if (arg.indexOf('#') !== -1) { |
19 |
return await msgInteraction.guild?.members.cache.find(m => m.user.tag === arg); |
20 |
} |
21 |
|
22 |
return await msgInteraction.guild?.members.fetch(arg); |
23 |
} |