Skip to content

Commit

Permalink
Separate sources
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaUrsa committed Jan 25, 2024
1 parent 97d0773 commit 7bb16b8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
35 changes: 30 additions & 5 deletions src/discord/commands/global/d.combo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,37 @@ export const dCombo: SlashCommand = {
.setDescription(`${resultsData.definition}${noteString}`);

if (resultsData.sources) {
const sourceArray = resultsData.sources.map(source => `* [${source.title}](${source.url})\n`);
embed.addFields({
name: 'Sources',
value: sourceArray.join(''),
inline: false,
// const sourceArray = resultsData.sources.map(source => `* [${source.title}](${source.url})\n`);

const experiences = [] as string[];
const journals = [] as string[];

resultsData.sources.forEach(source => {
if (source.url.includes('erowid.org/experiences')) {
experiences.push(`* [${source.title}](${source.url})\n`);
} else {
journals.push(`* [${source.title}](${source.url})\n`);
}
});

// log.debug(F, `Experiences: ${experiences}`);
// log.debug(F, `Journals: ${journals}`);

if (journals.length > 0) {
embed.addFields({
name: '⚗️ Research Articles',
value: journals.join(''),
inline: false,
});
}

if (experiences.length > 0) {
embed.addFields({
name: `<:erowidLogo:${env.EMOJI_EROWID}> Erowid Experiences`,
value: experiences.join(''),
inline: false,
});
}
}
embed.addFields(
{
Expand Down
21 changes: 12 additions & 9 deletions src/global/commands/g.combo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import comboJsonData from '../../../assets/data/tripsitCombos.json';
import drugJsonData from '../../../assets/data/tripsitDB.json';
import comboDefs from '../../../assets/data/combo_definitions.json';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const F = f(__filename);

type DrugData = {
Expand Down Expand Up @@ -50,7 +51,11 @@ export async function combo(
interactionCategoryA: string;
interactionCategoryB: string;
note?: string;
source?: string;
sources?: {
author: string;
title: string;
url: string;
}[];
}> {
let drugAName = drugAInput.toLowerCase();
let drugBName = drugBInput.toLowerCase();
Expand Down Expand Up @@ -167,7 +172,7 @@ export async function combo(
options: allDrugNames,
};
}
log.debug(F, `drugAComboData: ${JSON.stringify(drugAComboData)}`);
// log.debug(F, `drugAComboData: ${JSON.stringify(drugAComboData)}`);

const drugBComboData = Object.keys(drugData).includes(drugBName.toLowerCase())
? (drugData[drugBName.toLowerCase()]).combos
Expand All @@ -180,7 +185,7 @@ export async function combo(
options: allDrugNames,
};
}
log.debug(F, `drugBComboData: ${JSON.stringify(drugBComboData)}`);
// log.debug(F, `drugBComboData: ${JSON.stringify(drugBComboData)}`);

let comboInfo = {} as Combo;
// Check if drugB is in drugA's combo list
Expand All @@ -196,11 +201,13 @@ export async function combo(
};
}

log.debug(F, `comboInfo: ${JSON.stringify(comboInfo)}`);
// log.debug(F, `comboInfo: ${JSON.stringify(comboInfo)}`);

const comboDef = comboDefs.find(def => def.status === comboInfo.status) as ComboDef;

const response = {
// log.info(F, `response: ${JSON.stringify(response, null, 2)}`);

return {
result: comboInfo.status,
interactionCategoryA: drugAName,
interactionCategoryB: drugBName,
Expand All @@ -211,8 +218,4 @@ export async function combo(
note: comboInfo.note,
sources: comboInfo.sources,
};

log.info(F, `response: ${JSON.stringify(response, null, 2)}`);

return response;
}
1 change: 1 addition & 0 deletions src/global/utils/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const env = {

EMOJI_THUMB_UP: isProd ? '979721167332052992' : '👍',
EMOJI_THUMB_DOWN: isProd ? '979721915390369822' : '👎',
EMOJI_EROWID: isProd ? '1200132633519194153' : '1200136990788685956',

OPENAI_API_ORG: process.env.OPENAI_API_ORG ?? '',
OPENAI_API_KEY: process.env.OPENAI_API_KEY ?? '',
Expand Down

0 comments on commit 7bb16b8

Please sign in to comment.