update to support deno 2 correctly

This commit is contained in:
Ean Milligan 2025-07-24 03:01:48 -04:00
parent 774ab87966
commit 02fb3e5443
8 changed files with 21 additions and 22 deletions

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.1', // 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

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"
} }
} }

View File

@ -2,4 +2,4 @@ export { cache, cacheHandlers, DiscordActivityTypes, editBotNickname, editBotSta
export type { DiscordenoGuild, DiscordenoMessage, Embed } from 'https://deno.land/x/discordeno@12.0.1/mod.ts'; export type { DiscordenoGuild, DiscordenoMessage, 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

17
mod.ts
View File

@ -158,9 +158,7 @@ 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) => const searchResults: Array<number> = data.Actions.filter((action) => action.shorthand === query).map((action) => data.ActionNames.indexOf(action.name.toLowerCase()));
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:',
@ -171,9 +169,7 @@ 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) => const initialSearchResults: Array<number> = data.ActionNames.filter((action) => action.includes(query)).map((action) => data.ActionNames.indexOf(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) ||
@ -189,8 +185,7 @@ 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 = const paginationMessage = searchResults.length > config.resultsPerPage
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
@ -231,10 +226,12 @@ startBot({
} else if (!query) { } else if (!query) {
message message
.send({ .send({
content: `Available presets: ${data.Presets.keys() content: `Available presets: ${
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

@ -25,8 +25,7 @@ export const constantCmds = {
}, },
{ {
name: `\`${config.prefix}logograms [query]\` or \`${config.prefix}l [query]\``, name: `\`${config.prefix}logograms [query]\` or \`${config.prefix}l [query]\``,
value: 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',
'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,
}, },
{ {

View File

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