Update to Node 20 and Discord.js 14.

Fix empty attachment bug (#61).
This commit is contained in:
charlocharlie
2024-07-20 21:43:20 -05:00
parent 2694169da1
commit 8327775302
12 changed files with 3818 additions and 2536 deletions

View File

@@ -1,6 +1,10 @@
import { SlashCommandBuilder, SlashCommandChannelOption } from '@discordjs/builders';
import { REST } from '@discordjs/rest';
import { ChannelType, Routes } from 'discord-api-types/v10';
import {
SlashCommandChannelOption,
SlashCommandBuilder,
ChannelType,
Routes,
REST,
} from 'discord.js';
import { config } from './config';
import { packageJson } from './util';
@@ -18,21 +22,21 @@ export const messageCommand = new SlashCommandBuilder()
.setName(config.slashCommandName)
.setDescription('Generate a message from learned past messages')
.addBooleanOption((tts) =>
tts.setName('tts').setDescription('Read the message via text-to-speech.').setRequired(false)
tts.setName('tts').setDescription('Read the message via text-to-speech.').setRequired(false),
)
.addBooleanOption((debug) =>
debug
.setName('debug')
.setDescription('Follow up the generated message with the detailed sources that inspired it.')
.setRequired(false)
.setRequired(false),
)
.addStringOption((seed) =>
seed
.setName('seed')
.setDescription(
`A ${config.stateSize}-word phrase to attempt to start a generated sentence with.`
`A ${config.stateSize}-word phrase to attempt to start a generated sentence with.`,
)
.setRequired(false)
.setRequired(false),
);
/**
@@ -52,10 +56,10 @@ export const listenChannelCommand = new SlashCommandBuilder()
sub
.setName('add')
.setDescription(
`Add channels to learn from. Doesn't add the channel's past messages; re-train to do that.`
`Add channels to learn from. Doesn't add the channel's past messages; re-train to do that.`,
);
Array.from(Array(CHANNEL_OPTIONS_MAX).keys()).forEach((index) =>
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index))
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index)),
);
return sub;
})
@@ -63,42 +67,42 @@ export const listenChannelCommand = new SlashCommandBuilder()
sub
.setName('remove')
.setDescription(
`Remove channels from being learned from. Doesn't remove the channel's data; re-train to do that.`
`Remove channels from being learned from. Doesn't remove the channel's data; re-train to do that.`,
);
Array.from(Array(CHANNEL_OPTIONS_MAX).keys()).forEach((index) =>
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index))
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index)),
);
return sub;
})
.addSubcommand((sub) =>
sub
.setName('list')
.setDescription(`List the channels the bot is currently actively listening to.`)
.setDescription(`List the channels the bot is currently actively listening to.`),
)
.addSubcommand((sub) =>
sub
.setName('modify')
.setDescription(`Add or remove channels via select menu UI (first 25 text channels only)`)
.setDescription(`Add or remove channels via select menu UI (first 25 text channels only)`),
);
export const trainCommand = new SlashCommandBuilder()
.setName('train')
.setDescription(
'Train from past messages from the configured listened channels. This takes a while.'
'Train from past messages from the configured listened channels. This takes a while.',
)
.addBooleanOption((clean) =>
clean
.setName('clean')
.setDescription(
'Whether the database should be emptied before training. Default is true (recommended).'
'Whether the database should be emptied before training. Default is true (recommended).',
)
.setRequired(false)
.setRequired(false),
)
.addAttachmentOption((json) =>
json
.setName('json')
.setDescription('Train from a provided JSON file rather than channel history.')
.setRequired(false)
.setRequired(false),
);
const commands = [