Add job icons to logogram response

This commit is contained in:
Ean Milligan 2024-09-04 02:43:01 -04:00
parent 50a258b4a5
commit 4e79bfd01b
4 changed files with 28 additions and 7 deletions

View File

@ -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

View File

@ -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;

View File

@ -22,7 +22,7 @@
},
"options": {
"useTabs": true,
"lineWidth": 200,
"lineWidth": 250,
"indentWidth": 2,
"singleQuote": true,
"proseWrap": "preserve"

View File

@ -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>): 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`,