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

Contents of /trunk/src/utils/getMember.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (show annotations)
Mon Jul 29 17:28:23 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 774 byte(s)
Release version 2.0
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 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26