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.
## Commands
@ -12,7 +12,7 @@ A Discord bot for Eureka Logos Actions and their recipes.
- Examples: `-class=healer`, `-class=drg`
- `-page=#`
- Use to view more search results
- `preset` or `p`
- `preset` or `pr`
- Shows a pre-made list of actions for convenient viewing
- `flowchart` or `flow` or `f`
- Shows a simple flowchart for best actions

View File

@ -1,6 +1,6 @@
export const config = {
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
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

29
mod.ts
View File

@ -158,7 +158,9 @@ startBot({
});
} else if (query && data.ActionShortNames.includes(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
.send({
content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:',
@ -169,7 +171,9 @@ startBot({
});
} else {
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) =>
params.class
? (data.Actions[actionIdx].jobs.includes('all-nin') && !params.isNin) ||
@ -185,9 +189,10 @@ startBot({
}
const classMessage = params.class ? ` -class=${params.rawClass}` : '';
const userQuery = `${rawQuery}${classMessage}`.trim();
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.`
: '';
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.`
: '';
message
.send({
content: `${searchResults.length} result${searchResults.length > 1 ? 's' : ''} matching query: \`${userQuery}\`${paginationMessage}`,
@ -207,8 +212,8 @@ startBot({
}
}
}
} else if (command === 'preset' || command === 'p') {
// l!preset or l!p
} else if (command === 'preset' || command === 'pr') {
// l!preset or l!pr
// Returns logos actions stuff
const rawQuery = args.join(' ');
const query = rawQuery.toLowerCase();
@ -226,12 +231,10 @@ startBot({
} else if (!query) {
message
.send({
content: `Available presets: ${
data.Presets.keys()
.toArray()
.map((p) => `\`${p}\``)
.join(', ')
}`,
content: `Available presets: ${data.Presets.keys()
.toArray()
.map((p) => `\`${p}\``)
.join(', ')}`,
})
.catch((e) => {
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);

View File

@ -4,61 +4,72 @@ const errorColor = 0xe71212;
export const constantCmds = {
help: {
embeds: [{
title: `${config.name}'s Available Commands:`,
fields: [
{
name: `\`${config.prefix}?\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}info\``,
value: 'Prints some information and links relating to the bot',
inline: true,
},
{
name: `\`${config.prefix}version\``,
value: 'Prints the bots version',
inline: true,
},
{
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',
inline: true,
},
{
name: `\`${config.prefix}preset [query]\` or \`${config.prefix}p [query]\``,
value: 'Sends information about the requested preset list',
inline: true,
},
{
name: `\`${config.prefix}flowchart]\` or \`${config.prefix}f\``,
value: 'Shows a simple flowchart for best actions',
inline: true,
},
],
}],
embeds: [
{
title: `${config.name}'s Available Commands:`,
fields: [
{
name: `\`${config.prefix}?\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}info\``,
value: 'Prints some information and links relating to the bot',
inline: true,
},
{
name: `\`${config.prefix}version\``,
value: 'Prints the bots version',
inline: true,
},
{
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',
inline: true,
},
{
name: `\`${config.prefix}preset [query]\` or \`${config.prefix}pr [query]\``,
value: 'Sends information about the requested preset list',
inline: true,
},
{
name: `\`${config.prefix}flowchart]\` or \`${config.prefix}f\``,
value: 'Shows a simple flowchart for best actions',
inline: true,
},
],
},
],
},
info: {
embeds: [{
fields: [{
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.`,
}],
}],
embeds: [
{
fields: [
{
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.`,
},
],
},
],
},
version: {
embeds: [{
title: `My current version is ${config.version}`,
}],
embeds: [
{
title: `My current version is ${config.version}`,
},
],
},
logogramsNoQuery: {
embeds: [{
color: errorColor,
title: 'No query provided!',
description: `Please type something after the command, such as \`${config.prefix}logos wisdom\`.`,
}],
embeds: [
{
color: errorColor,
title: 'No query provided!',
description: `Please type something after the command, such as \`${config.prefix}logos wisdom\`.`,
},
],
},
flowchart: 'https://ffxiv.eanm.dev/eureka/Simple-Logos-Flowchart.png',
};