Add getters for LFGMembers
This commit is contained in:
parent
025d1cb4c1
commit
871398a28d
|
@ -140,9 +140,29 @@ export const generateLFGButtons = (whitelist: boolean): [ButtonComponent, Button
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const generateMemberTitle = (memberList: Array<LFGMember>, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`;
|
// Get Member Counts from the title
|
||||||
const generateMemberList = (memberList: Array<LFGMember>): string => memberList.length ? memberList.map((member) => `${member.name} - <@${member.id}>`).join('\n') : 'None';
|
export const getEventMemberCount = (rawMemberTitle: string): [number, number] => {
|
||||||
const generateAlternateList = (alternateList: Array<LFGMember>): string =>
|
const [rawCurrentCount, rawMaxCount] = rawMemberTitle.split('/');
|
||||||
|
const currentMemberCount = parseInt(rawCurrentCount.split(':')[1] || '0')
|
||||||
|
const maxMemberCount = parseInt(rawMaxCount || '0');
|
||||||
|
return [currentMemberCount, maxMemberCount]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get LFGMember objects from string list
|
||||||
|
export const getLfgMembers = (rawMemberList: string): Array<LFGMember> => rawMemberList.split('\n').map((rawMember) => {
|
||||||
|
const [memberName, memberMention] = rawMember.split('-');
|
||||||
|
const lfgMember: LFGMember = {
|
||||||
|
id: BigInt(memberMention.split('<@')[1].split('>')[0].trim() || '0'),
|
||||||
|
name: memberName.trim(),
|
||||||
|
joined: rawMember.endsWith('*'),
|
||||||
|
}
|
||||||
|
return lfgMember;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Member List generators
|
||||||
|
export const generateMemberTitle = (memberList: Array<LFGMember>, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`;
|
||||||
|
export const generateMemberList = (memberList: Array<LFGMember>): string => memberList.length ? memberList.map((member) => `${member.name} - <@${member.id}>`).join('\n') : 'None';
|
||||||
|
export const generateAlternateList = (alternateList: Array<LFGMember>): string =>
|
||||||
alternateList.length ? alternateList.map((member) => `${member.name} - <@${member.id}>${member.joined ? ' *' : ''}`).join('\n') : 'None';
|
alternateList.length ? alternateList.map((member) => `${member.name} - <@${member.id}>${member.joined ? ' *' : ''}`).join('\n') : 'None';
|
||||||
|
|
||||||
export enum LfgEmbedIndexes {
|
export enum LfgEmbedIndexes {
|
||||||
|
|
Loading…
Reference in New Issue