From c0d9abbe7048a348d43482ae8aa6209c81211843 Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Thu, 3 Jun 2021 01:49:13 -0400 Subject: [PATCH] V0.2.3 Misc typos/bugs fixed --- config.example.ts | 2 +- mod.ts | 4 ++-- src/intervals.ts | 2 +- src/lfgHandlers.ts | 19 ++++++++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/config.example.ts b/config.example.ts index 702e426..6217bf8 100644 --- a/config.example.ts +++ b/config.example.ts @@ -1,6 +1,6 @@ export const config = { "name": "Group Up", // Name of the bot - "version": "0.2.1", // Version of the bot + "version": "0.2.3", // Version of the bot "token": "the_bot_token", // Discord API Token for this bot "localtoken": "local_testing_token", // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" "prefix": "[[", // Prefix for all commands diff --git a/mod.ts b/mod.ts index 65460de..8deef07 100644 --- a/mod.ts +++ b/mod.ts @@ -361,7 +361,7 @@ startBot({ log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${JSON.stringify(e)}`); }); - const subcmd = args[0] || "help"; + const subcmd = args[0].toLowerCase() || "help"; const lfgUid = (args[1] || "").toUpperCase(); // Learn how the LFG command works @@ -687,7 +687,7 @@ startBot({ if (interact.type === DiscordInteractionTypes.MessageComponent) { if (interact.message && interact.data && (interact.data as ButtonData).customId && interact.member) { log(LT.INFO, `Handling Button ${(interact.data as ButtonData).customId}`); - console.log(LT.LOG, `Button Data | ${JSON.stringify(interact)}`); + log(LT.LOG, `Button Data | ${JSON.stringify(interact)}`); sendInteractionResponse(BigInt(interact.id), interact.token, { type: 6 diff --git a/src/intervals.ts b/src/intervals.ts index 8661a9f..8696362 100644 --- a/src/intervals.ts +++ b/src/intervals.ts @@ -116,7 +116,7 @@ const lfgNotifier = async (activeLFGPosts: Array): Promise => { editMsg += `<@${userId}>, `; await sendDirectMessage(userId, { embed: { - title: `Hello ${name}! You event in ${guildName} starts in less than 10 minutes.`, + title: `Hello ${name}! Your event in ${guildName} starts in less than 10 minutes.`, fields: [ lfg[0], { diff --git a/src/lfgHandlers.ts b/src/lfgHandlers.ts index 2b653a2..2fbbf3b 100644 --- a/src/lfgHandlers.ts +++ b/src/lfgHandlers.ts @@ -207,7 +207,7 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise } case "set_player_cnt": { if (parseInt(input)) { - currentLFG[4].name = `Members Joined: ${currentLFG[4].value === "None" ? 0 : currentLFG[4].value.split("\n").length}/${parseInt(input)}`; + currentLFG[4].name = `Members Joined: ${currentLFG[4].value === "None" ? 0 : currentLFG[4].value.split("\n").length}/${Math.abs(parseInt(input)) || 1}`; nextQuestion = wipLFG.editing ? lfgStepQuestions.set_done : lfgStepQuestions.set_time; @@ -215,7 +215,7 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise } else { editFlag = false; - nextQuestion = `Input max members "${input}" is invalid, please make sure you are only entering a number.\n\nPlease enter the max number of members for this activity:` + nextQuestion = `Input max members "${input}" is invalid, please make sure you are only entering a number.\n\n${lfgStepQuestions.set_player_cnt}` } break; } @@ -247,7 +247,7 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise lfgPeriod = "pm"; } else { lfgTime = c.startsWith("00") ? `12${c.substr(2)}` : c; - lfgPeriod = "am" + lfgPeriod = "am"; } const hourLen = lfgTime.length === 4 ? 2 : 1; @@ -255,6 +255,10 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise } else { lfgTime = c; } + } else if (c.match(/^\d/)) { + const tzIdx = c.search(/[a-zA-Z]/); + lfgTime = c.substr(0, tzIdx); + lfgTZ = determineTZ(c.substr(tzIdx)); } else { lfgTZ = determineTZ(c); } @@ -269,14 +273,15 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise } if (!lfgPeriod) { - lfgPeriod = parseInt(lfgTime.split(":")[0]) >= 12 ? "pm" : "am"; + lfgPeriod = today.getHours() >= 12 ? "pm" : "am"; } + lfgPeriod = lfgPeriod.toUpperCase(); lfgTZ = lfgTZ.toUpperCase(); lfgDate = `${lfgDate.split("/")[0]}/${lfgDate.split("/")[1]}/${today.getFullYear()}`; - console.log(`${lfgTime} ${lfgPeriod} ${lfgTZ} ${lfgDate}`); + log(LT.LOG, `Date Time Debug | ${lfgTime} ${lfgPeriod} ${lfgTZ} ${lfgDate}`); const lfgDateTime = new Date(`${lfgTime} ${lfgPeriod} ${lfgTZ} ${lfgDate}`); lfgDate = `${lfgDate.split("/")[0]}/${lfgDate.split("/")[1]}`; @@ -286,11 +291,11 @@ export const handleLFGStep = async (wipLFG: BuildingLFG, input: string): Promise currentLFG[1].value = lfgDateStr.substr(0, 1023); if (isNaN(lfgDateTime.getTime())) { - nextQuestion = `Input time "${input}" is invalid, please make sure you have the timezone set correctly.\n\n${lfgStepQuestions.set_time}`; + nextQuestion = `Input time "${input}" (parsed as "${lfgTime} ${lfgPeriod} ${lfgTZ} ${lfgDate}") is invalid, please make sure you have the timezone set correctly.\n\n${lfgStepQuestions.set_time}`; editFlag = false; } else if (lfgDateTime.getTime() <= today.getTime()) { - nextQuestion = `Input time "${input}" is in the past, please make sure you are setting up the event to be in the future.\n\n${lfgStepQuestions.set_time}`; + nextQuestion = `Input time "${input}" (parsed as "${lfgTime} ${lfgPeriod} ${lfgTZ} ${lfgDate}") is in the past, please make sure you are setting up the event to be in the future.\n\n${lfgStepQuestions.set_time}`; editFlag = false; } else {