add hideRaw flag

This commit is contained in:
Ean Milligan 2025-05-05 16:08:18 -04:00
parent 3bda7a1187
commit 2fe2c5f296
5 changed files with 13 additions and 4 deletions

View File

@ -5,7 +5,7 @@ meta {
} }
get { 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 body: none
auth: inherit auth: inherit
} }
@ -17,6 +17,7 @@ params:query {
documentation: All items below are optional. Flags do not need values. documentation: All items below are optional. Flags do not need values.
nd: [no-details-flag] nd: [no-details-flag]
snd: [super-no-details-flag] snd: [super-no-details-flag]
hr: [hide-raw-roll-details-flag]
s: [spoiler-results-flag] s: [spoiler-results-flag]
m-or-max: [max-roll-flag, cannot be used with n flag] m-or-max: [max-roll-flag, cannot be used with n flag]
min: [[min-roll-flag, cannot be used with n or max] min: [[min-roll-flag, cannot be used with n or max]

View File

@ -35,6 +35,7 @@ export interface RollFormat {
export interface RollModifiers { export interface RollModifiers {
noDetails: boolean; noDetails: boolean;
superNoDetails: boolean; superNoDetails: boolean;
hideRaw: boolean;
spoiler: string; spoiler: string;
maxRoll: boolean; maxRoll: boolean;
minRoll: boolean; minRoll: boolean;

View File

@ -6,6 +6,7 @@ export const getModifiers = (args: string[]): RollModifiers => {
const modifiers: RollModifiers = { const modifiers: RollModifiers = {
noDetails: false, noDetails: false,
superNoDetails: false, superNoDetails: false,
hideRaw: false,
spoiler: '', spoiler: '',
maxRoll: false, maxRoll: false,
minRoll: false, minRoll: false,
@ -34,6 +35,9 @@ export const getModifiers = (args: string[]): RollModifiers => {
case '-snd': case '-snd':
modifiers.superNoDetails = true; modifiers.superNoDetails = true;
break; break;
case '-hr':
modifiers.hideRaw = true;
break;
case '-s': case '-s':
modifiers.spoiler = '||'; modifiers.spoiler = '||';
break; break;

View File

@ -102,12 +102,13 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR
}, },
}; };
} else { } else {
const line1Details = modifiers.hideRaw ? '' : `<@${authorId}>${returnDetails.line1}\n`;
if (modifiers.gmRoll) { 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) // Roll is a GM Roll, send this in the pub channel (this funciton will be ran again to get details for the GMs)
return { return {
embed: { embed: {
color: infoColor2, 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 modifiers.gms
.map((gm) => (gm.startsWith('<') ? gm : `<@${gm}>`)) .map((gm) => (gm.startsWith('<') ? gm : `<@${gm}>`))
.join(' ') .join(' ')
@ -129,7 +130,7 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR
loggingEnabled && log(LT.LOG, `${returnDetails.line3} |&| ${details}`); 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 // Embed desc limit is 4096
if (baseDesc.length + details.length < 4090) { if (baseDesc.length + details.length < 4090) {

View File

@ -84,6 +84,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
const modifiers: RollModifiers = { const modifiers: RollModifiers = {
noDetails: query.has('nd'), noDetails: query.has('nd'),
superNoDetails: query.has('snd'), superNoDetails: query.has('snd'),
hideRaw: query.has('hr'),
spoiler: query.has('s') ? '||' : '', spoiler: query.has('s') ? '||' : '',
maxRoll: query.has('m') || query.has('max'), maxRoll: query.has('m') || query.has('max'),
minRoll: query.has('min'), minRoll: query.has('min'),
@ -93,8 +94,9 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
order: query.has('o') ? query.get('o')?.toLowerCase() || '' : '', order: query.has('o') ? query.get('o')?.toLowerCase() || '' : '',
count: query.has('c'), count: query.has('c'),
commaTotals: query.has('ct'), commaTotals: query.has('ct'),
valid: true,
apiWarn: hideWarn ? '' : apiWarning, apiWarn: hideWarn ? '' : apiWarning,
valid: true,
error: new Error(),
}; };
return new Promise<Response>((resolve) => { return new Promise<Response>((resolve) => {