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 = {
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
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

View File

@ -1,5 +1,5 @@
{
"version": "3",
"version": "4",
"remote": {
"https://deno.land/std@0.99.0/encoding/base64.ts": "eecae390f1f1d1cae6f6c6d732ede5276bf4b9cd29b1d281678c054dc5cc009e",
"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/mod.ts": "d9c38a41a405cf5732c9233c2391a1d7f5a12d0e464aace6f8f596fabf5f21ba",
"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"
}
}

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 { 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}"
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
run_rc_command "$1"

View File

@ -6,7 +6,7 @@ After=network.target
[Service]
Type=simple
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
Restart=on-failure

25
mod.ts
View File

@ -158,9 +158,7 @@ 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:',
@ -171,9 +169,7 @@ 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) ||
@ -189,10 +185,9 @@ 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}`,
@ -231,10 +226,12 @@ 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

@ -25,8 +25,7 @@ export const constantCmds = {
},
{
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,
},
{

View File

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