change preset shorthand to pr

This commit is contained in:
Ean Milligan 2025-04-26 11:39:07 -04:00
parent 548d2b8eb1
commit 774ab87966
4 changed files with 79 additions and 65 deletions

View File

@ -1,4 +1,4 @@
# Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.2.0 - 2025/04/25 # Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.2.1 - 2025/04/25
A Discord bot for Eureka Logos Actions and their recipes. A Discord bot for Eureka Logos Actions and their recipes.
## Commands ## Commands
@ -12,7 +12,7 @@ A Discord bot for Eureka Logos Actions and their recipes.
- Examples: `-class=healer`, `-class=drg` - Examples: `-class=healer`, `-class=drg`
- `-page=#` - `-page=#`
- Use to view more search results - Use to view more search results
- `preset` or `p` - `preset` or `pr`
- Shows a pre-made list of actions for convenient viewing - Shows a pre-made list of actions for convenient viewing
- `flowchart` or `flow` or `f` - `flowchart` or `flow` or `f`
- Shows a simple flowchart for best actions - Shows a simple flowchart for best actions

View File

@ -1,6 +1,6 @@
export const config = { export const config = {
name: 'Logogram Bot', // Name of the bot name: 'Logogram Bot', // Name of the bot
version: '1.2.0', // Version of the bot version: '1.2.1', // Version of the bot
token: 'the_bot_token', // Discord API Token for this 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" 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 prefix: 'l!', // Prefix for all commands

21
mod.ts
View File

@ -158,7 +158,9 @@ startBot({
}); });
} else if (query && data.ActionShortNames.includes(query)) { } else if (query && data.ActionShortNames.includes(query)) {
log(LT.LOG, `in shorthand matched '${query}'`); log(LT.LOG, `in shorthand matched '${query}'`);
const searchResults: Array<number> = data.Actions.filter((action) => action.shorthand === query).map((action) => data.ActionNames.indexOf(action.name.toLowerCase())); const searchResults: Array<number> = data.Actions.filter((action) => action.shorthand === query).map((action) =>
data.ActionNames.indexOf(action.name.toLowerCase())
);
message message
.send({ .send({
content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:', content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:',
@ -169,7 +171,9 @@ startBot({
}); });
} else { } else {
log(LT.LOG, `in general search '${query}'`); log(LT.LOG, `in general search '${query}'`);
const initialSearchResults: Array<number> = data.ActionNames.filter((action) => action.includes(query)).map((action) => data.ActionNames.indexOf(action)); const initialSearchResults: Array<number> = data.ActionNames.filter((action) => action.includes(query)).map((action) =>
data.ActionNames.indexOf(action)
);
const searchResults: Array<number> = initialSearchResults.filter((actionIdx) => const searchResults: Array<number> = initialSearchResults.filter((actionIdx) =>
params.class params.class
? (data.Actions[actionIdx].jobs.includes('all-nin') && !params.isNin) || ? (data.Actions[actionIdx].jobs.includes('all-nin') && !params.isNin) ||
@ -185,7 +189,8 @@ startBot({
} }
const classMessage = params.class ? ` -class=${params.rawClass}` : ''; const classMessage = params.class ? ` -class=${params.rawClass}` : '';
const userQuery = `${rawQuery}${classMessage}`.trim(); const userQuery = `${rawQuery}${classMessage}`.trim();
const paginationMessage = searchResults.length > config.resultsPerPage const paginationMessage =
searchResults.length > config.resultsPerPage
? `\nShowing page ${params.page} of ${totalPages}\n\nTo see more results, please run \`${config.prefix}logos ${userQuery} -page=#\`, where # is the page number you wish to see.` ? `\nShowing page ${params.page} of ${totalPages}\n\nTo see more results, please run \`${config.prefix}logos ${userQuery} -page=#\`, where # is the page number you wish to see.`
: ''; : '';
message message
@ -207,8 +212,8 @@ startBot({
} }
} }
} }
} else if (command === 'preset' || command === 'p') { } else if (command === 'preset' || command === 'pr') {
// l!preset or l!p // l!preset or l!pr
// Returns logos actions stuff // Returns logos actions stuff
const rawQuery = args.join(' '); const rawQuery = args.join(' ');
const query = rawQuery.toLowerCase(); const query = rawQuery.toLowerCase();
@ -226,12 +231,10 @@ startBot({
} else if (!query) { } else if (!query) {
message message
.send({ .send({
content: `Available presets: ${ content: `Available presets: ${data.Presets.keys()
data.Presets.keys()
.toArray() .toArray()
.map((p) => `\`${p}\``) .map((p) => `\`${p}\``)
.join(', ') .join(', ')}`,
}`,
}) })
.catch((e) => { .catch((e) => {
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);

View File

@ -4,7 +4,8 @@ const errorColor = 0xe71212;
export const constantCmds = { export const constantCmds = {
help: { help: {
embeds: [{ embeds: [
{
title: `${config.name}'s Available Commands:`, title: `${config.name}'s Available Commands:`,
fields: [ fields: [
{ {
@ -24,11 +25,12 @@ export const constantCmds = {
}, },
{ {
name: `\`${config.prefix}logograms [query]\` or \`${config.prefix}l [query]\``, name: `\`${config.prefix}logograms [query]\` or \`${config.prefix}l [query]\``,
value: 'Sends information about the requested logogram, or logograms matching the query\nCan use `-class=abbr` to further filter the results, or `-page=#` to view more results', value:
'Sends information about the requested logogram, or logograms matching the query\nCan use `-class=abbr` to further filter the results, or `-page=#` to view more results',
inline: true, inline: true,
}, },
{ {
name: `\`${config.prefix}preset [query]\` or \`${config.prefix}p [query]\``, name: `\`${config.prefix}preset [query]\` or \`${config.prefix}pr [query]\``,
value: 'Sends information about the requested preset list', value: 'Sends information about the requested preset list',
inline: true, inline: true,
}, },
@ -38,27 +40,36 @@ export const constantCmds = {
inline: true, inline: true,
}, },
], ],
}], },
],
}, },
info: { info: {
embeds: [{ embeds: [
fields: [{ {
fields: [
{
name: `${config.name}, a Discord bot for Eureka Logogram Actions.`, name: `${config.name}, a Discord bot for Eureka Logogram Actions.`,
value: `${config.name} is developed by Ean AKA Burn_E99.\n\nFINAL FANTASY XIV SQUARE ENIX CO., LTD. FINAL FANTASY is a registered trademark of Square Enix Holdings Co., Ltd. All material used under license.`, value: `${config.name} is developed by Ean AKA Burn_E99.\n\nFINAL FANTASY XIV SQUARE ENIX CO., LTD. FINAL FANTASY is a registered trademark of Square Enix Holdings Co., Ltd. All material used under license.`,
}], },
}], ],
},
],
}, },
version: { version: {
embeds: [{ embeds: [
{
title: `My current version is ${config.version}`, title: `My current version is ${config.version}`,
}], },
],
}, },
logogramsNoQuery: { logogramsNoQuery: {
embeds: [{ embeds: [
{
color: errorColor, color: errorColor,
title: 'No query provided!', title: 'No query provided!',
description: `Please type something after the command, such as \`${config.prefix}logos wisdom\`.`, description: `Please type something after the command, such as \`${config.prefix}logos wisdom\`.`,
}], },
],
}, },
flowchart: 'https://ffxiv.eanm.dev/eureka/Simple-Logos-Flowchart.png', flowchart: 'https://ffxiv.eanm.dev/eureka/Simple-Logos-Flowchart.png',
}; };