deno fmt + l!p now sends available presets
This commit is contained in:
parent
5b87cfda75
commit
30547e9d6a
|
@ -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.2.0 - 2025/09/21
|
||||
A Discord bot for Eureka Logos Actions and their recipes.
|
||||
|
||||
## Commands
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
export const config = {
|
||||
'name': 'Logogram Bot', // Name of the bot
|
||||
'version': '1.1.6', // 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
|
||||
'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
|
||||
'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
|
||||
'imageUrl': '', // Base URL for logos action images
|
||||
'resultsPerPage': 5, // Results to show on each page
|
||||
'mneme': { // Emojis for the mnemes
|
||||
'blue': '',
|
||||
'cyan': '',
|
||||
'green': '',
|
||||
'purple': '',
|
||||
'red': '',
|
||||
'yellow': '',
|
||||
name: 'Logogram Bot', // Name of the bot
|
||||
version: '1.2.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
|
||||
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
|
||||
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
|
||||
imageUrl: '', // Base URL for logos action images
|
||||
resultsPerPage: 5, // Results to show on each page
|
||||
mneme: {
|
||||
// Emojis for the mnemes
|
||||
blue: '',
|
||||
cyan: '',
|
||||
green: '',
|
||||
purple: '',
|
||||
red: '',
|
||||
yellow: '',
|
||||
},
|
||||
'jobType': { // Emojis for job type icons
|
||||
'tank': '',
|
||||
'healer': '',
|
||||
'melee': '',
|
||||
'ranged': '',
|
||||
'magic': '',
|
||||
jobType: {
|
||||
// Emojis for job type icons
|
||||
tank: '',
|
||||
healer: '',
|
||||
melee: '',
|
||||
ranged: '',
|
||||
magic: '',
|
||||
},
|
||||
};
|
||||
|
||||
|
|
77
mod.ts
77
mod.ts
|
@ -31,11 +31,13 @@ startBot({
|
|||
eventHandlers: {
|
||||
ready: () => {
|
||||
editBotStatus({
|
||||
activities: [{
|
||||
activities: [
|
||||
{
|
||||
name: 'Booting up . . .',
|
||||
type: DiscordActivityTypes.Game,
|
||||
createdAt: new Date().getTime(),
|
||||
}],
|
||||
},
|
||||
],
|
||||
status: 'online',
|
||||
});
|
||||
|
||||
|
@ -43,11 +45,13 @@ startBot({
|
|||
setTimeout(() => {
|
||||
LOCALMODE && editBotNickname(config.devServer, `LOCAL - ${config.name}`);
|
||||
editBotStatus({
|
||||
activities: [{
|
||||
activities: [
|
||||
{
|
||||
name: 'Booting Complete',
|
||||
type: DiscordActivityTypes.Game,
|
||||
createdAt: new Date().getTime(),
|
||||
}],
|
||||
},
|
||||
],
|
||||
status: 'online',
|
||||
});
|
||||
sendMessage(config.logChannel, `${config.name} has started, running version ${config.version}.`).catch((e) => {
|
||||
|
@ -73,7 +77,10 @@ startBot({
|
|||
if (message.content.indexOf(config.prefix) !== 0) return;
|
||||
|
||||
// Split into standard command + args format
|
||||
const args = message.content.slice(config.prefix.length).trim().split(/[ \n]+/g);
|
||||
const args = message.content
|
||||
.slice(config.prefix.length)
|
||||
.trim()
|
||||
.split(/[ \n]+/g);
|
||||
const command = args.shift()?.toLowerCase();
|
||||
|
||||
if (command === 'help' || command === 'h' || command === '?') {
|
||||
|
@ -122,7 +129,8 @@ startBot({
|
|||
const allPrefixes = classPrefixes.concat(pagePrefixes).concat(debugPrefixes);
|
||||
|
||||
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.isNin = params.rawClass.toLowerCase() === 'nin';
|
||||
|
@ -133,33 +141,41 @@ startBot({
|
|||
}
|
||||
});
|
||||
|
||||
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 query = rawQuery.toLowerCase();
|
||||
|
||||
if (data.ActionNames.includes(query)) {
|
||||
log(LT.LOG, `in name matched '${query}'`);
|
||||
const singleAction: Array<number> = [data.ActionNames.indexOf(query)];
|
||||
message.send({
|
||||
message
|
||||
.send({
|
||||
content: 'Showing single action:',
|
||||
embeds: generateEmbeds(singleAction, params.debug),
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
} 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()));
|
||||
message.send({
|
||||
message
|
||||
.send({
|
||||
content: searchResults.length > 1 ? `Showing ${searchResults.length} actions:` : 'Showing single action:',
|
||||
embeds: generateEmbeds(searchResults, params.debug),
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
} 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
|
||||
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) {
|
||||
|
@ -172,16 +188,20 @@ startBot({
|
|||
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({
|
||||
message
|
||||
.send({
|
||||
content: `${searchResults.length} result${searchResults.length > 1 ? 's' : ''} matching query: \`${userQuery}\`${paginationMessage}`,
|
||||
embeds: generateEmbeds(searchResults.slice((params.page - 1) * config.resultsPerPage, config.resultsPerPage * params.page), params.debug),
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
} else {
|
||||
message.send({
|
||||
message
|
||||
.send({
|
||||
content: `No results found matching query: \`${rawQuery}\``,
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
|
@ -195,16 +215,33 @@ startBot({
|
|||
|
||||
if (data.Presets.has(query)) {
|
||||
const preset: Array<number> = data.Presets.get(query) ?? [];
|
||||
message.send({
|
||||
message
|
||||
.send({
|
||||
content: `Showing ${rawQuery} Preset:`,
|
||||
embeds: generateEmbeds(preset, false),
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
} else if (!query) {
|
||||
message
|
||||
.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({
|
||||
message
|
||||
.send({
|
||||
content: `No preset found matching query: \`${rawQuery}\``,
|
||||
}).catch((e) => {
|
||||
})
|
||||
.catch((e) => {
|
||||
log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue