From 2fe2c5f2966509cfb6a992f4f70b60aa98c4d5a2 Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Mon, 5 May 2025 16:08:18 -0400 Subject: [PATCH] add hideRaw flag --- .bruno/Authenticated/Roll Requests/Roll Dice.bru | 3 ++- src/artigen/dice/dice.d.ts | 1 + src/artigen/dice/getModifiers.ts | 4 ++++ src/artigen/utils/embeds.ts | 5 +++-- src/endpoints/gets/apiRoll.ts | 4 +++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.bruno/Authenticated/Roll Requests/Roll Dice.bru b/.bruno/Authenticated/Roll Requests/Roll Dice.bru index dcc8b5f..35ba6d1 100644 --- a/.bruno/Authenticated/Roll Requests/Roll Dice.bru +++ b/.bruno/Authenticated/Roll Requests/Roll Dice.bru @@ -5,7 +5,7 @@ meta { } get { - url: http://localhost:8166/api/roll?user=[discord-user-id]&channel=[discord-channel-id]&rollstr=[artificer-roll-cmd]&documentation=All items below are optional. Flags do not need values.&nd=[no-details-flag]&snd=[super-no-details-flag]&s=[spoiler-results-flag]&m-or-max=[max-roll-flag, cannot be used with n flag]&min=[[min-roll-flag, cannot be used with n or max]&n=[nominal-roll-flag, cannot be used with max or min flag]&gms=[csv-of-discord-user-ids-to-be-dmed-results]&o=[order-rolls, must be a or d]&c=[count-flag] + url: http://localhost:8166/api/roll?user=[discord-user-id]&channel=[discord-channel-id]&rollstr=[artificer-roll-cmd]&documentation=All items below are optional. Flags do not need values.&nd=[no-details-flag]&snd=[super-no-details-flag]&hr=[hide-raw-roll-details-flag]&s=[spoiler-results-flag]&m-or-max=[max-roll-flag, cannot be used with n flag]&min=[[min-roll-flag, cannot be used with n or max]&n=[nominal-roll-flag, cannot be used with max or min flag]&gms=[csv-of-discord-user-ids-to-be-dmed-results]&o=[order-rolls, must be a or d]&c=[count-flag] body: none auth: inherit } @@ -17,6 +17,7 @@ params:query { documentation: All items below are optional. Flags do not need values. nd: [no-details-flag] snd: [super-no-details-flag] + hr: [hide-raw-roll-details-flag] s: [spoiler-results-flag] m-or-max: [max-roll-flag, cannot be used with n flag] min: [[min-roll-flag, cannot be used with n or max] diff --git a/src/artigen/dice/dice.d.ts b/src/artigen/dice/dice.d.ts index 78b1af3..bd098bd 100644 --- a/src/artigen/dice/dice.d.ts +++ b/src/artigen/dice/dice.d.ts @@ -35,6 +35,7 @@ export interface RollFormat { export interface RollModifiers { noDetails: boolean; superNoDetails: boolean; + hideRaw: boolean; spoiler: string; maxRoll: boolean; minRoll: boolean; diff --git a/src/artigen/dice/getModifiers.ts b/src/artigen/dice/getModifiers.ts index f6a1424..1be2a9e 100644 --- a/src/artigen/dice/getModifiers.ts +++ b/src/artigen/dice/getModifiers.ts @@ -6,6 +6,7 @@ export const getModifiers = (args: string[]): RollModifiers => { const modifiers: RollModifiers = { noDetails: false, superNoDetails: false, + hideRaw: false, spoiler: '', maxRoll: false, minRoll: false, @@ -34,6 +35,9 @@ export const getModifiers = (args: string[]): RollModifiers => { case '-snd': modifiers.superNoDetails = true; break; + case '-hr': + modifiers.hideRaw = true; + break; case '-s': modifiers.spoiler = '||'; break; diff --git a/src/artigen/utils/embeds.ts b/src/artigen/utils/embeds.ts index 58fa14f..c15afec 100644 --- a/src/artigen/utils/embeds.ts +++ b/src/artigen/utils/embeds.ts @@ -102,12 +102,13 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR }, }; } else { + const line1Details = modifiers.hideRaw ? '' : `<@${authorId}>${returnDetails.line1}\n`; if (modifiers.gmRoll) { // Roll is a GM Roll, send this in the pub channel (this funciton will be ran again to get details for the GMs) return { embed: { color: infoColor2, - description: `<@${authorId}>${returnDetails.line1}\n\nResults have been messaged to the following GMs: ${ + description: `${line1Details}${line1Details ? '\n' : ''}Results have been messaged to the following GMs: ${ modifiers.gms .map((gm) => (gm.startsWith('<') ? gm : `<@${gm}>`)) .join(' ') @@ -129,7 +130,7 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR loggingEnabled && log(LT.LOG, `${returnDetails.line3} |&| ${details}`); } - const baseDesc = `<@${authorId}>${returnDetails.line1}\n**${line2Details.shift()}:**\n${line2Details.join(': ')}`; + const baseDesc = `${line1Details}**${line2Details.shift()}:**\n${line2Details.join(': ')}`; // Embed desc limit is 4096 if (baseDesc.length + details.length < 4090) { diff --git a/src/endpoints/gets/apiRoll.ts b/src/endpoints/gets/apiRoll.ts index 009c9cc..27d134e 100644 --- a/src/endpoints/gets/apiRoll.ts +++ b/src/endpoints/gets/apiRoll.ts @@ -84,6 +84,7 @@ export const apiRoll = async (query: Map, apiUserid: bigint): Pr const modifiers: RollModifiers = { noDetails: query.has('nd'), superNoDetails: query.has('snd'), + hideRaw: query.has('hr'), spoiler: query.has('s') ? '||' : '', maxRoll: query.has('m') || query.has('max'), minRoll: query.has('min'), @@ -93,8 +94,9 @@ export const apiRoll = async (query: Map, apiUserid: bigint): Pr order: query.has('o') ? query.get('o')?.toLowerCase() || '' : '', count: query.has('c'), commaTotals: query.has('ct'), - valid: true, apiWarn: hideWarn ? '' : apiWarning, + valid: true, + error: new Error(), }; return new Promise((resolve) => {