From e63818cf7a8c0b1f0bb2a2ba72db813b45fa5b4d Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Fri, 28 Apr 2023 23:40:13 -0400 Subject: [PATCH] Fix alternates DM to actually notify people and make english more endlish in message --- src/notificationSystem.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/notificationSystem.ts b/src/notificationSystem.ts index 01784e3..e8205e3 100644 --- a/src/notificationSystem.ts +++ b/src/notificationSystem.ts @@ -137,7 +137,7 @@ export const notifyEventMembers = async (bot: Bot, event: ActiveEvent, secondTry export const lockEvent = async (bot: Bot, event: ActiveEvent, secondTry = false): Promise => { const eventMessage = await bot.helpers.getMessage(event.channelId, event.messageId).catch((e: Error) => utils.commonLoggers.messageGetError('notificationSystem.ts@lock', 'get event', e)); if (eventMessage?.embeds[0].fields) { - const [currentMemberCount, maxMemberCount] = getEventMemberCount(eventMessage.embeds[0].fields[LfgEmbedIndexes.Activity].name); + const [currentMemberCount, maxMemberCount] = getEventMemberCount(eventMessage.embeds[0].fields[LfgEmbedIndexes.JoinedMembers].name); const alternates = getLfgMembers(eventMessage.embeds[0].fields[LfgEmbedIndexes.AlternateMembers].value); const memberMentionString = joinWithAnd(alternates.map((member) => `<@${member.id}>`)); @@ -146,6 +146,7 @@ export const lockEvent = async (bot: Bot, event: ActiveEvent, secondTry = false) if (alternatesNeeded) { const activityName = `\`${eventMessage.embeds[0].fields[LfgEmbedIndexes.Activity].name} ${eventMessage.embeds[0].fields[LfgEmbedIndexes.Activity].value}\``; const guildName = await getGuildName(bot, event.guildId); + const peopleShort = maxMemberCount - currentMemberCount; // Send the notifications to the members alternates.forEach(async (member) => { @@ -153,9 +154,7 @@ export const lockEvent = async (bot: Bot, event: ActiveEvent, secondTry = false) embeds: [{ color: infoColor1, title: `Hello ${member.name}! An activity in ${guildName} may need your help.`, - description: `The ${activityName} in ${guildName} that you marked yourself as an alternate for may be \`${ - maxMemberCount - currentMemberCount - }\` people short. If you are available, please join up with them.`, + description: `The ${activityName} in ${guildName} that you marked yourself as an alternate for may be \`${peopleShort}\` ${peopleShort === 1 ? 'person' : 'people'} short. If you are available, please join up with them.`, }, eventMessage.embeds[0]], }).catch((e: Error) => utils.commonLoggers.messageSendError('notificationSystem.ts@lock', 'send DM fail', e)); });