deno fmt & initialize join/leave/alternate buttons

This commit is contained in:
Ean Milligan (Bastion) 2023-04-07 01:37:04 -04:00
parent 871398a28d
commit d60668e86f
5 changed files with 61 additions and 15 deletions

View File

@ -4,5 +4,17 @@ import { createCustomEventButton } from './event-creation/step1a-openCustomModal
import { verifyCustomEventButton } from './event-creation/step1b-verifyCustomActivity.ts'; import { verifyCustomEventButton } from './event-creation/step1b-verifyCustomActivity.ts';
import { finalizeEventButton } from './event-creation/step2-finalize.ts'; import { finalizeEventButton } from './event-creation/step2-finalize.ts';
import { createEventButton } from './event-creation/step3-createEvent.ts'; import { createEventButton } from './event-creation/step3-createEvent.ts';
import { joinEventButton } from './live-event/joinEvent.ts';
import { leaveEventButton } from './live-event/leaveEvent.ts';
import { alternateEventButton } from './live-event/alternateEvent.ts';
export const buttons: Array<Button> = [gameSelectionButton, createCustomEventButton, verifyCustomEventButton, finalizeEventButton, createEventButton]; export const buttons: Array<Button> = [
gameSelectionButton,
createCustomEventButton,
verifyCustomEventButton,
finalizeEventButton,
createEventButton,
joinEventButton,
leaveEventButton,
alternateEventButton,
];

View File

@ -17,6 +17,9 @@ import { successColor } from '../../commandUtils.ts';
import { LFGMember } from '../../types/commandTypes.ts'; import { LFGMember } from '../../types/commandTypes.ts';
import { customId as gameSelCustomId } from './step1-gameSelection.ts'; import { customId as gameSelCustomId } from './step1-gameSelection.ts';
import { customId as createEventCustomId } from './step3-createEvent.ts'; import { customId as createEventCustomId } from './step3-createEvent.ts';
import { customId as joinEventCustomId } from '../live-event/joinEvent.ts';
import { customId as leaveEventCustomId } from '../live-event/leaveEvent.ts';
import { customId as alternateEventCustomId } from '../live-event/alternateEvent.ts';
// Discord Interaction Tokens last 15 minutes, we will self kill after 14.5 minutes // Discord Interaction Tokens last 15 minutes, we will self kill after 14.5 minutes
const tokenTimeoutS = (15 * 60) - 30; const tokenTimeoutS = (15 * 60) - 30;
@ -111,17 +114,17 @@ export const generateLFGButtons = (whitelist: boolean): [ButtonComponent, Button
type: MessageComponentTypes.Button, type: MessageComponentTypes.Button,
label: `${whitelist ? 'Request to ' : ''}Join`, label: `${whitelist ? 'Request to ' : ''}Join`,
style: ButtonStyles.Success, style: ButtonStyles.Success,
customId: `joinEvent${whitelist ? idSeparator : ''}`, // TODO: replace with proper id customId: `${joinEventCustomId}${whitelist ? idSeparator : ''}`,
}, { }, {
type: MessageComponentTypes.Button, type: MessageComponentTypes.Button,
label: 'Leave', label: 'Leave',
style: ButtonStyles.Danger, style: ButtonStyles.Danger,
customId: 'leaveEvent', // TODO: replace with proper id customId: leaveEventCustomId,
}, { }, {
type: MessageComponentTypes.Button, type: MessageComponentTypes.Button,
label: `Join as Alternate`, label: `Join as Alternate`,
style: ButtonStyles.Primary, style: ButtonStyles.Primary,
customId: 'alternateEvent', // TODO: replace with proper id customId: alternateEventCustomId,
}, { }, {
type: MessageComponentTypes.Button, type: MessageComponentTypes.Button,
label: '', label: '',
@ -143,19 +146,20 @@ export const generateLFGButtons = (whitelist: boolean): [ButtonComponent, Button
// Get Member Counts from the title // Get Member Counts from the title
export const getEventMemberCount = (rawMemberTitle: string): [number, number] => { export const getEventMemberCount = (rawMemberTitle: string): [number, number] => {
const [rawCurrentCount, rawMaxCount] = rawMemberTitle.split('/'); const [rawCurrentCount, rawMaxCount] = rawMemberTitle.split('/');
const currentMemberCount = parseInt(rawCurrentCount.split(':')[1] || '0') const currentMemberCount = parseInt(rawCurrentCount.split(':')[1] || '0');
const maxMemberCount = parseInt(rawMaxCount || '0'); const maxMemberCount = parseInt(rawMaxCount || '0');
return [currentMemberCount, maxMemberCount] return [currentMemberCount, maxMemberCount];
}; };
// Get LFGMember objects from string list // Get LFGMember objects from string list
export const getLfgMembers = (rawMemberList: string): Array<LFGMember> => rawMemberList.split('\n').map((rawMember) => { export const getLfgMembers = (rawMemberList: string): Array<LFGMember> =>
rawMemberList.split('\n').map((rawMember) => {
const [memberName, memberMention] = rawMember.split('-'); const [memberName, memberMention] = rawMember.split('-');
const lfgMember: LFGMember = { const lfgMember: LFGMember = {
id: BigInt(memberMention.split('<@')[1].split('>')[0].trim() || '0'), id: BigInt(memberMention.split('<@')[1].split('>')[0].trim() || '0'),
name: memberName.trim(), name: memberName.trim(),
joined: rawMember.endsWith('*'), joined: rawMember.endsWith('*'),
} };
return lfgMember; return lfgMember;
}); });

View File

@ -0,0 +1,10 @@
import { Bot, Interaction } from '../../../deps.ts';
export const customId = 'alternateEvent';
export const execute = async (bot: Bot, interaction: Interaction) => {};
export const alternateEventButton = {
customId,
execute,
};

View File

@ -0,0 +1,10 @@
import { Bot, Interaction } from '../../../deps.ts';
export const customId = 'joinEvent';
export const execute = async (bot: Bot, interaction: Interaction) => {};
export const joinEventButton = {
customId,
execute,
};

View File

@ -0,0 +1,10 @@
import { Bot, Interaction } from '../../../deps.ts';
export const customId = 'leaveEvent';
export const execute = async (bot: Bot, interaction: Interaction) => {};
export const leaveEventButton = {
customId,
execute,
};