From 4e79bfd01bf0d7fb901a7caafcef0fa3a55b93cd Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Wed, 4 Sep 2024 02:43:01 -0400 Subject: [PATCH] Add job icons to logogram response --- README.md | 2 +- config.example.ts | 9 ++++++++- deno.json | 2 +- src/generateActionEmbeds.ts | 22 ++++++++++++++++++---- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8339d73..90d7829 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.0.0 - 2025/09/02 +# Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.1.0 - 2025/09/04 A Discord bot for Eureka Logos Actions and their recipes. ## Commands diff --git a/config.example.ts b/config.example.ts index de136aa..bd74298 100755 --- a/config.example.ts +++ b/config.example.ts @@ -1,6 +1,6 @@ export const config = { 'name': 'Logogram Bot', // Name of the bot - 'version': '1.0.0', // Version of the bot + 'version': '1.1.0', // 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': 'l!', // Prefix for all commands @@ -18,6 +18,13 @@ export const config = { 'red': '', 'yellow': '', }, + 'jobType': { // Emojis for job type icons + 'tank': '', + 'healer': '', + 'melee': '', + 'ranged': '', + 'magic': '', + }, }; export default config; diff --git a/deno.json b/deno.json index d53d386..28ae94d 100755 --- a/deno.json +++ b/deno.json @@ -22,7 +22,7 @@ }, "options": { "useTabs": true, - "lineWidth": 200, + "lineWidth": 250, "indentWidth": 2, "singleQuote": true, "proseWrap": "preserve" diff --git a/src/generateActionEmbeds.ts b/src/generateActionEmbeds.ts index bc49a03..6bbdd79 100644 --- a/src/generateActionEmbeds.ts +++ b/src/generateActionEmbeds.ts @@ -44,21 +44,35 @@ const getMnemeEmoji = (id: string): string => { } }; +const getActionUses = (uses: number): string => uses === Infinity ? '∞' : `${uses}`; +const getActionCast = (cast: number): string => cast === 0 ? 'Instant' : `${cast}s`; const getHumanDuration = (duration: number) => { if (duration < 60) { return `${duration}s`; } else if (duration < (60 * 60)) { return `${Math.round(duration / 60 * 10) / 10}m`; } else { - return `${Math.round(duration / 60 / 60 * 10) / 10}h` + return `${Math.round(duration / 60 / 60 * 10) / 10}h`; } }; +const getJobs = (jobs: Array): string => { + let jobIcons = ''; + + if (jobs.includes('tank') || jobs[0].startsWith('all')) jobIcons += config.jobType.tank; + if (jobs.includes('healer') || jobs[0].startsWith('all')) jobIcons += config.jobType.healer; + if (jobs.includes('melee') || jobs[0].startsWith('all')) jobIcons += config.jobType.melee; + if (jobs.includes('ranged') || jobs[0].startsWith('all')) jobIcons += config.jobType.ranged; + if (jobs.includes('magic') || jobs[0].startsWith('all')) jobIcons += config.jobType.magic; + if (jobs.includes('all-nin')) jobIcons += ' (Excludes Ninja)'; + + return jobIcons; +}; + const generateActionEmbed = (action: LogosAction): Embed => ({ title: action.name, - description: `**${action.type}** | ${action.duration ? `**Duration:** ${getHumanDuration(action.duration)} | ` : ''}**Uses:** ${action.uses === Infinity ? '∞' : action.uses} | **Cast:** ${ - action.cast === 0 ? 'Instant' : `${action.cast}s` - } | **Recast:** ${action.recast}s + description: `**${action.type}** | ${action.duration ? `**Duration:** ${getHumanDuration(action.duration)} | ` : ''}**Uses:** ${getActionUses(action.uses)} | **Cast:** ${getActionCast(action.cast)} | **Recast:** ${action.recast}s +${getJobs(action.jobs)} ${action.description}`, thumbnail: { url: `${config.imageUrl}${action.imageId}.png`,