add comma totals decorator

This commit is contained in:
Ean Milligan 2025-04-29 18:02:51 -04:00
parent 861d1e00cd
commit b9c7fac984
6 changed files with 21 additions and 4 deletions

View File

@ -131,6 +131,7 @@ The Artificer comes with a few supplemental commands to the main rolling command
* `-n` - Nominal Roll - Rolls the theoretical nominal roll, cannot be used with `-m`, `-max`, or `-min`
* `-gm @user1 @user2 ... @userN` - GM Roll - Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs
* `-o a` or `-o d` - Order Roll - Rolls the requested roll and orders the results in the requested direction
* `-ct` - Comma Totals - Adds commas to totals for readability
* The results have some formatting applied on them to provide details on what happened during this roll.
* Critical successes will be **bolded**
* Critical fails will be <ins>underlined</ins>

View File

@ -25,8 +25,9 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
gmRoll: false,
gms: [],
order: '',
valid: false,
count: false,
commaTotals: false,
valid: false,
apiWarn: '',
};
@ -99,6 +100,9 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
modifiers.order = args[i].toLowerCase()[0];
break;
case '-ct':
modifiers.commaTotals = true;
break;
default:
// Default case should not mess with the array
defaultCase = true;

View File

@ -71,6 +71,11 @@ Available directions:
\`d\` - Descending (greatest to least)`,
inline: true,
},
{
name: '`-ct` - Comma Totals',
value: 'Adds commas to totals for readability',
inline: true,
},
],
},
],

View File

@ -91,6 +91,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
gms: query.has('gms') ? (query.get('gms') || '').split(',') : [],
order: query.has('o') ? query.get('o')?.toLowerCase() || '' : '',
count: query.has('c'),
commaTotals: query.has('ct'),
valid: true,
apiWarn: hideWarn ? '' : apiWarning,
};

1
src/mod.d.ts vendored
View File

@ -22,6 +22,7 @@ export type RollModifiers = {
gms: string[];
order: string;
count: boolean;
commaTotals: boolean;
valid: boolean;
apiWarn: string;
};

View File

@ -258,13 +258,18 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
// Populate line2 (the results) and line3 (the details) with their data
if (modifiers.order === '') {
line2 += `${preFormat}${e.rollTotal}${postFormat}${escapeCharacters(e.rollPostFormat, '|*_~`')} `;
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${
escapeCharacters(
e.rollPostFormat,
'|*_~`',
)
} `;
} else {
// If order is on, turn rolls into csv without formatting
line2 += `${preFormat}${e.rollTotal}${postFormat}, `;
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;
}
line3 += `\`${e.initConfig}\` = ${e.rollDetails} = ${preFormat}${e.rollTotal}${postFormat}\n`;
line3 += `\`${e.initConfig}\` = ${e.rollDetails} = ${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}\n`;
});
// If order is on, remove trailing ", "