Compare commits

..

6 Commits

Author SHA1 Message Date
e458823091 bump ver in readme 2025-07-24 03:13:09 -04:00
02fb3e5443 update to support deno 2 correctly 2025-07-24 03:01:48 -04:00
774ab87966 change preset shorthand to pr 2025-04-26 11:39:07 -04:00
548d2b8eb1 bump date 2025-04-26 00:24:37 -04:00
30547e9d6a deno fmt + l!p now sends available presets 2025-04-25 22:08:07 -04:00
5b87cfda75 deno fmt 2025-04-25 22:06:08 -04:00
10 changed files with 346 additions and 308 deletions

View File

@ -1,4 +1,4 @@
# Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.1.6 - 2025/09/21 # Logogram Discord Bot - A FFXIV Eureka Utility Bot | V1.3.0 - 2025/07/24
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,30 +1,32 @@
export const config = { export const config = {
'name': 'Logogram Bot', // Name of the bot name: 'Logogram Bot', // Name of the bot
'version': '1.1.6', // Version of the bot version: '1.3.0', // 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
'logChannel': 0n, // Discord channel ID where the bot should put startup messages and other error messages needed logChannel: 0n, // Discord channel ID where the bot should put startup messages and other error messages needed
'reportChannel': 0n, // Discord channel ID where reports will be sent when using the built-in report command reportChannel: 0n, // Discord channel ID where reports will be sent when using the built-in report command
'devServer': 0n, // Discord guild ID where testing of indev features/commands will be handled, used in conjunction with the DEVMODE bool in mod.ts devServer: 0n, // Discord guild ID where testing of indev features/commands will be handled, used in conjunction with the DEVMODE bool in mod.ts
'owner': 0n, // Discord user ID of the bot admin owner: 0n, // Discord user ID of the bot admin
'imageUrl': '', // Base URL for logos action images imageUrl: '', // Base URL for logos action images
'resultsPerPage': 5, // Results to show on each page resultsPerPage: 5, // Results to show on each page
'mneme': { // Emojis for the mnemes mneme: {
'blue': '', // Emojis for the mnemes
'cyan': '', blue: '',
'green': '', cyan: '',
'purple': '', green: '',
'red': '', purple: '',
'yellow': '', red: '',
}, yellow: '',
'jobType': { // Emojis for job type icons },
'tank': '', jobType: {
'healer': '', // Emojis for job type icons
'melee': '', tank: '',
'ranged': '', healer: '',
'magic': '', melee: '',
}, ranged: '',
}; magic: '',
},
export default config; };
export default config;

View File

@ -1,14 +1,11 @@
{ {
"compilerOptions": { "compilerOptions": {
"allowJs": true,
"lib": ["deno.worker"], "lib": ["deno.worker"],
"strict": true "strict": true
}, },
"lint": { "lint": {
"files": { "include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"],
"include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"], "exclude": [],
"exclude": []
},
"rules": { "rules": {
"tags": ["recommended"], "tags": ["recommended"],
"include": ["ban-untagged-todo"], "include": ["ban-untagged-todo"],
@ -16,16 +13,12 @@
} }
}, },
"fmt": { "fmt": {
"files": { "include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"],
"include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"], "exclude": [],
"exclude": [] "useTabs": false,
}, "lineWidth": 250,
"options": { "indentWidth": 2,
"useTabs": true, "singleQuote": true,
"lineWidth": 250, "proseWrap": "preserve"
"indentWidth": 2,
"singleQuote": true,
"proseWrap": "preserve"
}
} }
} }

5
deno.lock generated
View File

@ -1,5 +1,5 @@
{ {
"version": "3", "version": "4",
"remote": { "remote": {
"https://deno.land/std@0.99.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e", "https://deno.land/std@0.99.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e",
"https://deno.land/x/discordeno@12.0.1/mod.ts": "9c4187b459f479e23a77b0e7f0e24507a10729c7865b5c18113e79b1fbf0effa", "https://deno.land/x/discordeno@12.0.1/mod.ts": "9c4187b459f479e23a77b0e7f0e24507a10729c7865b5c18113e79b1fbf0effa",
@ -536,6 +536,9 @@
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/deps.ts": "4932522dd8d38cc322df6508d4f2e55e5fb0ec15e54fcdc81e2bf10051021608", "https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/deps.ts": "4932522dd8d38cc322df6508d4f2e55e5fb0ec15e54fcdc81e2bf10051021608",
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/mod.ts": "d9c38a41a405cf5732c9233c2391a1d7f5a12d0e464aace6f8f596fabf5f21ba", "https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/mod.ts": "d9c38a41a405cf5732c9233c2391a1d7f5a12d0e464aace6f8f596fabf5f21ba",
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/src/logger.ts": "f6ba6f7fe254fc3227a3ad48fd7c2c3aaaec8c350f0246fb3eeff075c21dc7e5", "https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/src/logger.ts": "f6ba6f7fe254fc3227a3ad48fd7c2c3aaaec8c350f0246fb3eeff075c21dc7e5",
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/deps.ts": "3ab026026d146ca5e7160b16146d5665e45487a62749a7970f8e00c0c934874d",
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/mod.ts": "d9c38a41a405cf5732c9233c2391a1d7f5a12d0e464aace6f8f596fabf5f21ba",
"https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/src/logger.ts": "b3a39724d58102dfbcdcd640a829cbfe1f083065060f68003f9c8fd49fdd658a",
"https://unpkg.com/@evan/wasm@0.0.65/target/zlib/deno.js": "36cd3f1edd2f3a6d6fd4c2376f701c2748338c132703810d4866cfa52b5e7bf9" "https://unpkg.com/@evan/wasm@0.0.65/target/zlib/deno.js": "36cd3f1edd2f3a6d6fd4c2376f701c2748338c132703810d4866cfa52b5e7bf9"
} }
} }

13
deps.ts
View File

@ -1,12 +1,5 @@
export { export { cache, cacheHandlers, DiscordActivityTypes, editBotNickname, editBotStatus, Intents, sendMessage, startBot } from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
startBot, editBotStatus, editBotNickname,
sendMessage,
Intents, DiscordActivityTypes,
cache, cacheHandlers
} from "https://deno.land/x/discordeno@12.0.1/mod.ts";
export type { export type { DiscordenoGuild, DiscordenoMessage, Embed } from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
DiscordenoMessage, DiscordenoGuild, Embed
} from "https://deno.land/x/discordeno@12.0.1/mod.ts";
export { initLog, log, LogTypes as LT } from 'https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/mod.ts'; export { initLog, log, LogTypes as LT } from 'https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/mod.ts';

View File

@ -14,7 +14,7 @@ logogram_log="/var/log/logogram-bot.log"
logogram_chdir="${logogram_root}" logogram_chdir="${logogram_root}"
command="/usr/sbin/daemon" command="/usr/sbin/daemon"
command_args="-f -R 5 -P ${pidfile} -o ${logogram_log} /usr/local/bin/deno run --allow-write=${logogram_write} --allow-net ${logogram_root}/mod.ts" command_args="-f -R 5 -P ${pidfile} -o ${logogram_log} /usr/local/bin/deno run --allow-write=${logogram_write} --allow-net --allow-import ${logogram_root}/mod.ts"
load_rc_config logogram load_rc_config logogram
run_rc_command "$1" run_rc_command "$1"

View File

@ -6,7 +6,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
PIDFile=/run/deno.pid PIDFile=/run/deno.pid
ExecStart=/root/.deno/bin/deno run --allow-write=./logs/ --allow-net /var/dbots/logogram-bot/mod.ts ExecStart=/root/.deno/bin/deno run --allow-write=./logs/ --allow-net --allow-import /var/dbots/logogram-bot/mod.ts
RestartSec=60 RestartSec=60
Restart=on-failure Restart=on-failure

413
mod.ts
View File

@ -1,17 +1,17 @@
import { import {
DiscordActivityTypes, DiscordActivityTypes,
DiscordenoGuild, DiscordenoGuild,
DiscordenoMessage, DiscordenoMessage,
editBotNickname, editBotNickname,
editBotStatus, editBotStatus,
// Log4Deno deps // Log4Deno deps
initLog, initLog,
Intents, Intents,
log, log,
LT, LT,
sendMessage, sendMessage,
// Discordeno deps // Discordeno deps
startBot, startBot,
} from './deps.ts'; } from './deps.ts';
import { constantCmds } from './src/constantCmds.ts'; import { constantCmds } from './src/constantCmds.ts';
@ -26,189 +26,226 @@ import { classToType } from './src/utils.ts';
initLog('logs', DEBUG); initLog('logs', DEBUG);
startBot({ startBot({
token: LOCALMODE ? config.localToken : config.token, token: LOCALMODE ? config.localToken : config.token,
intents: [Intents.GuildMessages, Intents.DirectMessages, Intents.Guilds], intents: [Intents.GuildMessages, Intents.DirectMessages, Intents.Guilds],
eventHandlers: { eventHandlers: {
ready: () => { ready: () => {
editBotStatus({ editBotStatus({
activities: [{ activities: [
name: 'Booting up . . .', {
type: DiscordActivityTypes.Game, name: 'Booting up . . .',
createdAt: new Date().getTime(), type: DiscordActivityTypes.Game,
}], createdAt: new Date().getTime(),
status: 'online', },
}); ],
status: 'online',
});
// setTimeout added to make sure the startup message does not error out // setTimeout added to make sure the startup message does not error out
setTimeout(() => { setTimeout(() => {
LOCALMODE && editBotNickname(config.devServer, `LOCAL - ${config.name}`); LOCALMODE && editBotNickname(config.devServer, `LOCAL - ${config.name}`);
editBotStatus({ editBotStatus({
activities: [{ activities: [
name: 'Booting Complete', {
type: DiscordActivityTypes.Game, name: 'Booting Complete',
createdAt: new Date().getTime(), type: DiscordActivityTypes.Game,
}], createdAt: new Date().getTime(),
status: 'online', },
}); ],
sendMessage(config.logChannel, `${config.name} has started, running version ${config.version}.`).catch((e) => { status: 'online',
log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`); });
}); sendMessage(config.logChannel, `${config.name} has started, running version ${config.version}.`).catch((e) => {
}, 1000); log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
}, });
guildCreate: (guild: DiscordenoGuild) => { }, 1000);
sendMessage(config.logChannel, `New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`).catch((e) => { },
log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`); guildCreate: (guild: DiscordenoGuild) => {
}); sendMessage(config.logChannel, `New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`).catch((e) => {
}, log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
guildDelete: (guild: DiscordenoGuild) => { });
sendMessage(config.logChannel, `I have been removed from: ${guild.name} (id: ${guild.id}).`).catch((e) => { },
log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`); guildDelete: (guild: DiscordenoGuild) => {
}); sendMessage(config.logChannel, `I have been removed from: ${guild.name} (id: ${guild.id}).`).catch((e) => {
}, log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
messageCreate: (message: DiscordenoMessage) => { });
// Ignore all other bots },
if (message.isBot) return; messageCreate: (message: DiscordenoMessage) => {
// Ignore all other bots
if (message.isBot) return;
// Ignore all messages that are not commands // Ignore all messages that are not commands
if (message.content.indexOf(config.prefix) !== 0) return; if (message.content.indexOf(config.prefix) !== 0) return;
// Split into standard command + args format // Split into standard command + args format
const args = message.content.slice(config.prefix.length).trim().split(/[ \n]+/g); const args = message.content
const command = args.shift()?.toLowerCase(); .slice(config.prefix.length)
.trim()
.split(/[ \n]+/g);
const command = args.shift()?.toLowerCase();
if (command === 'help' || command === 'h' || command === '?') { if (command === 'help' || command === 'h' || command === '?') {
// l!help or l!h or l!? // l!help or l!h or l!?
// Help command, prints from help file // Help command, prints from help file
message.send(constantCmds.help).catch((e) => { message.send(constantCmds.help).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)}`);
}); });
} else if (command === 'info' || command === 'i') { } else if (command === 'info' || command === 'i') {
// l!info or l!i // l!info or l!i
// Info command, prints short desc on bot and some links // Info command, prints short desc on bot and some links
message.send(constantCmds.info).catch((e) => { message.send(constantCmds.info).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)}`);
}); });
} else if (command === 'version' || command === 'v') { } else if (command === 'version' || command === 'v') {
// l!version or l!v // l!version or l!v
// Returns version of the bot // Returns version of the bot
message.send(constantCmds.version).catch((e) => { message.send(constantCmds.version).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)}`);
}); });
} else if (command === 'flowchart' || command === 'flow' || command === 'f') { } else if (command === 'flowchart' || command === 'flow' || command === 'f') {
// l!flowchart or l!flow or l!logos or l!f // l!flowchart or l!flow or l!logos or l!f
// Returns logos actions stuff // Returns logos actions stuff
message.send(constantCmds.flowchart).catch((e) => { message.send(constantCmds.flowchart).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)}`);
}); });
} else if (command === 'logograms' || command === 'logogram' || command === 'logos' || command === 'logo' || command === 'l') { } else if (command === 'logograms' || command === 'logogram' || command === 'logos' || command === 'logo' || command === 'l') {
// l!logograms or l!logograms or l!logos or l!logo or l!l // l!logograms or l!logograms or l!logos or l!logo or l!l
// Returns logos actions stuff // Returns logos actions stuff
if (!args.length) { if (!args.length) {
message.send(constantCmds.logogramsNoQuery).catch((e) => { message.send(constantCmds.logogramsNoQuery).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)}`);
}); });
} else { } else {
const params = { const params = {
class: '', class: '',
rawClass: '', rawClass: '',
isNin: false, isNin: false,
page: 1, page: 1,
debug: false, debug: false,
}; };
const classPrefixes = ['-class=', 'class=', '-c=', 'c=']; const classPrefixes = ['-class=', 'class=', '-c=', 'c='];
const pagePrefixes = ['-page=', 'page=', '-p=', 'p=']; const pagePrefixes = ['-page=', 'page=', '-p=', 'p='];
const debugPrefixes = ['-debug=', 'debug=', '-d=', 'd=']; const debugPrefixes = ['-debug=', 'debug=', '-d=', 'd='];
const allPrefixes = classPrefixes.concat(pagePrefixes).concat(debugPrefixes); const allPrefixes = classPrefixes.concat(pagePrefixes).concat(debugPrefixes);
args.forEach((arg) => { args.forEach((arg) => {
if (classPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) { // if (classPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) {
params.rawClass = arg.split('=')[1]; //
params.class = classToType(params.rawClass); params.rawClass = arg.split('=')[1];
params.isNin = params.rawClass.toLowerCase() === 'nin'; params.class = classToType(params.rawClass);
} else if (pagePrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) { params.isNin = params.rawClass.toLowerCase() === 'nin';
params.page = parseInt(arg.split('=')[1]); } else if (pagePrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) {
} else if (debugPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) { params.page = parseInt(arg.split('=')[1]);
params.debug = true; } else if (debugPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx))) {
} params.debug = true;
}); }
});
const cleanArgs = args.filter((arg) => !(allPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx)))); const cleanArgs = args.filter((arg) => !allPrefixes.some((pfx) => arg.toLowerCase().startsWith(pfx)));
const rawQuery = cleanArgs.join(' '); const rawQuery = cleanArgs.join(' ');
const query = rawQuery.toLowerCase(); const query = rawQuery.toLowerCase();
if (data.ActionNames.includes(query)) { if (data.ActionNames.includes(query)) {
log(LT.LOG, `in name matched '${query}'`); log(LT.LOG, `in name matched '${query}'`);
const singleAction: Array<number> = [data.ActionNames.indexOf(query)]; const singleAction: Array<number> = [data.ActionNames.indexOf(query)];
message.send({ message
content: 'Showing single action:', .send({
embeds: generateEmbeds(singleAction, params.debug), content: 'Showing single action:',
}).catch((e) => { embeds: generateEmbeds(singleAction, params.debug),
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); })
}); .catch((e) => {
} else if (query && data.ActionShortNames.includes(query)) { log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
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())); } else if (query && data.ActionShortNames.includes(query)) {
message.send({ log(LT.LOG, `in shorthand matched '${query}'`);
content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:', const searchResults: Array<number> = data.Actions.filter((action) => action.shorthand === query).map((action) => data.ActionNames.indexOf(action.name.toLowerCase()));
embeds: generateEmbeds(searchResults, params.debug), message
}).catch((e) => { .send({
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:',
}); embeds: generateEmbeds(searchResults, params.debug),
} else { })
log(LT.LOG, `in general search '${query}'`); .catch((e) => {
const initialSearchResults: Array<number> = data.ActionNames.filter((action) => action.includes(query)).map((action) => data.ActionNames.indexOf(action)); log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
const searchResults: Array<number> = initialSearchResults.filter((actionIdx) => });
params.class ? (data.Actions[actionIdx].jobs.includes('all-nin') && !params.isNin) || data.Actions[actionIdx].jobs.includes('all') || data.Actions[actionIdx].jobs.includes(params.class) : true } 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 searchResults: Array<number> = initialSearchResults.filter((actionIdx) =>
params.class
? (data.Actions[actionIdx].jobs.includes('all-nin') && !params.isNin) ||
data.Actions[actionIdx].jobs.includes('all') ||
data.Actions[actionIdx].jobs.includes(params.class)
: true
);
if (searchResults.length) { if (searchResults.length) {
const totalPages = Math.ceil(searchResults.length / config.resultsPerPage); const totalPages = Math.ceil(searchResults.length / config.resultsPerPage);
if (params.page > totalPages) { if (params.page > totalPages) {
params.page = totalPages; params.page = totalPages;
} }
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.send({ message
content: `${searchResults.length} result${searchResults.length > 1 ? 's' : ''} matching query: \`${userQuery}\`${paginationMessage}`, .send({
embeds: generateEmbeds(searchResults.slice((params.page - 1) * config.resultsPerPage, config.resultsPerPage * params.page), params.debug), content: `${searchResults.length} result${searchResults.length > 1 ? 's' : ''} matching query: \`${userQuery}\`${paginationMessage}`,
}).catch((e) => { embeds: generateEmbeds(searchResults.slice((params.page - 1) * config.resultsPerPage, config.resultsPerPage * params.page), params.debug),
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); })
}); .catch((e) => {
} else { log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
message.send({ });
content: `No results found matching query: \`${rawQuery}\``, } else {
}).catch((e) => { message
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); .send({
}); content: `No results found matching query: \`${rawQuery}\``,
} })
} .catch((e) => {
} log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
} else if (command === 'preset' || command === 'p') { });
// l!preset or l!p }
// Returns logos actions stuff }
const rawQuery = args.join(' '); }
const query = rawQuery.toLowerCase(); } else if (command === 'preset' || command === 'pr') {
// l!preset or l!pr
// Returns logos actions stuff
const rawQuery = args.join(' ');
const query = rawQuery.toLowerCase();
if (data.Presets.has(query)) { if (data.Presets.has(query)) {
const preset: Array<number> = data.Presets.get(query) ?? []; const preset: Array<number> = data.Presets.get(query) ?? [];
message.send({ message
content: `Showing ${rawQuery} Preset:`, .send({
embeds: generateEmbeds(preset, false), content: `Showing ${rawQuery} Preset:`,
}).catch((e) => { embeds: generateEmbeds(preset, false),
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); })
}); .catch((e) => {
} else { log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
message.send({ });
content: `No preset found matching query: \`${rawQuery}\``, } else if (!query) {
}).catch((e) => { message
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`); .send({
}); 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)}`);
});
} else {
message
.send({
content: `No preset found matching query: \`${rawQuery}\``,
})
.catch((e) => {
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
});
}
}
},
},
}); });

View File

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

View File

@ -1 +1 @@
deno run --allow-net --allow-write=./logs/ ./mod.ts deno run --allow-write=./logs/ --allow-net --allow-import ./mod.ts