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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (hide annotations)
Mon Jul 29 17:28:56 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 824 byte(s)
fix: mention reading strategy (#41)

* fix(commands): ban related commands not working when banning users outside of the server

* fix(utils): reading users/members in the wrong way
1 rakin 51 import { CommandInteraction, GuildMember, Message, User } from "discord.js";
2     import CommandOptions from "../types/CommandOptions";
3 rakin 186 import { parseMember } from './parseInput';
4 rakin 51
5     export default async function getMember(msgInteraction: Message, options: CommandOptions, index: number = 0): Promise<GuildMember | null | undefined> {
6     if (options.normalArgs[index] === undefined)
7     return null;
8    
9     const arg = await options.normalArgs[index];
10    
11     if (arg.indexOf('#') !== -1) {
12     return await msgInteraction.guild?.members.cache.find(m => m.user.tag === arg);
13     }
14    
15 rakin 186 const parsed = await parseMember(msgInteraction.guild!, arg);
16    
17     if (parsed) {
18     return parsed;
19     }
20    
21     try {
22     return await msgInteraction.guild?.members.fetch(arg);
23     }
24     catch (e) {
25     console.log(e);
26     return null;
27     }
28     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26