Update dependencies to latest

This commit is contained in:
Charlie Laabs
2022-05-20 21:47:51 -05:00
parent 0d7a388b3c
commit 0042fda285
4 changed files with 608 additions and 558 deletions

1088
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "markov-discord",
"version": "2.1.0",
"version": "2.1.1",
"description": "A conversational Markov chain bot for Discord",
"main": "dist/index.js",
"scripts": {
@@ -31,47 +31,47 @@
},
"license": "MIT",
"dependencies": {
"@discordjs/builders": "^0.12.0",
"@discordjs/rest": "^0.3.0",
"@discordjs/builders": "^0.13.0",
"@discordjs/rest": "^0.4.1",
"@types/fs-extra": "^9.0.13",
"better-sqlite3": "^7.5.0",
"better-sqlite3": "^7.5.3",
"bufferutil": "^4.0.6",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"date-fns": "^2.28.0",
"discord-api-types": "^0.26.1",
"discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"discord-api-types": "^0.33.0",
"discord.js": "^13.7.0",
"dotenv": "^16.0.1",
"erlpack": "github:discord/erlpack",
"fs-extra": "^10.0.1",
"fs-extra": "^10.1.0",
"json5": "^2.2.1",
"markov-strings-db": "^4.2.0",
"pino": "^7.9.2",
"pino-pretty": "^7.6.0",
"pino": "^7.11.0",
"pino-pretty": "^7.6.1",
"reflect-metadata": "^0.1.13",
"simple-eta": "^3.0.2",
"source-map-support": "^0.5.21",
"typeorm": "^0.3.3",
"typeorm": "^0.3.6",
"utf-8-validate": "^5.0.9",
"zlib-sync": "^0.1.7"
},
"devDependencies": {
"@types/node": "^16.11.21",
"@types/node": "^16.11.36",
"@types/validator": "^13.7.2",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.12.0",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"eslint": "^8.16.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"pm2": "^5.2.0",
"prettier": "^2.6.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-node": "^10.7.0",
"typedoc": "^0.22.13",
"typedoc": "^0.22.15",
"types-package-json": "^2.0.39",
"typescript": "^4.6.3"
"typescript": "^4.6.4"
},
"engines": {
"node": "16"

View File

@@ -1,6 +1,6 @@
import { SlashCommandBuilder, SlashCommandChannelOption } from '@discordjs/builders';
import { REST } from '@discordjs/rest';
import { ChannelType, Routes } from 'discord-api-types/v9';
import { ChannelType, Routes } from 'discord-api-types/v10';
import { config } from './config';
import { packageJson } from './util';
@@ -43,7 +43,7 @@ const channelOptionsGenerator = (builder: SlashCommandChannelOption, index: numb
.setName(`channel-${index + 1}`)
.setDescription('A text channel')
.setRequired(index === 0)
.addChannelType(ChannelType.GuildText);
.addChannelTypes(ChannelType.GuildText);
export const listenChannelCommand = new SlashCommandBuilder()
.setName('listen')
@@ -96,7 +96,7 @@ const commands = [
];
export async function deployCommands(clientId: string) {
const rest = new REST({ version: '9' }).setToken(config.token);
const rest = new REST({ version: '10' }).setToken(config.token);
if (config.devGuildId) {
await rest.put(Routes.applicationGuildCommands(clientId, config.devGuildId), {
body: commands,

View File

@@ -12,7 +12,7 @@ import type { PackageJsonPerson } from 'types-package-json';
import makeEta from 'simple-eta';
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
import addSeconds from 'date-fns/addSeconds';
import type { APIInteractionGuildMember, APISelectMenuComponent } from 'discord-api-types';
import type { APIInteractionGuildMember, APISelectMenuComponent } from 'discord-api-types/v9';
import L from './logger';
import { Channel } from './entity/Channel';
import { Guild } from './entity/Guild';
@@ -39,6 +39,11 @@ interface SelectMenuChannel {
name?: string;
}
/**
* Reply options that can be used in both MessageOptions and InteractionReplyOptions
*/
type AgnosticReplyOptions = Omit<Discord.MessageOptions, 'reply' | 'stickers' | 'flags'>;
const INVALID_PERMISSIONS_MESSAGE = 'You do not have the permissions for this action.';
const INVALID_GUILD_MESSAGE = 'This action must be performed within a server.';
@@ -436,9 +441,9 @@ async function saveGuildMessageHistory(
}
interface GenerateResponse {
message?: Discord.MessageOptions;
debug?: Discord.MessageOptions;
error?: Discord.MessageOptions;
message?: AgnosticReplyOptions;
debug?: AgnosticReplyOptions;
error?: AgnosticReplyOptions;
}
interface GenerateOptions {
@@ -475,7 +480,7 @@ async function generateResponse(
const response = await markov.generate<MarkovDataCustom>(markovGenerateOptions);
L.info({ string: response.string }, 'Generated response text');
L.debug({ response }, 'Generated response object');
const messageOpts: Discord.MessageOptions = {
const messageOpts: AgnosticReplyOptions = {
tts,
allowedMentions: { repliedUser: false, parse: [] },
};
@@ -543,10 +548,13 @@ function getChannelsFromInteraction(
return textChannels;
}
function helpMessage(): Discord.MessageOptions {
function helpMessage(): AgnosticReplyOptions {
const avatarURL = client.user.avatarURL() || undefined;
const embed = new Discord.MessageEmbed()
.setAuthor(client.user.username || packageJson().name, avatarURL)
.setAuthor({
name: client.user.username || packageJson().name,
iconURL: avatarURL,
})
.setThumbnail(avatarURL as string)
.setDescription(
`A Markov chain chatbot that speaks based on learned messages from previous chat input.`
@@ -575,9 +583,11 @@ function helpMessage(): Discord.MessageOptions {
`${config.messageCommandPrefix} tts or /${messageCommand.name} tts: True`,
`Runs the ${config.messageCommandPrefix} command and reads it with text-to-speech.`
)
.setFooter(
`${packageJson().name} ${getVersion()} by ${(packageJson().author as PackageJsonPerson).name}`
);
.setFooter({
text: `${packageJson().name} ${getVersion()} by ${
(packageJson().author as PackageJsonPerson).name
}`,
});
return {
embeds: [embed],
};
@@ -596,11 +606,11 @@ function generateInviteUrl(): string {
});
}
function inviteMessage(): Discord.MessageOptions {
function inviteMessage(): AgnosticReplyOptions {
const avatarURL = client.user.avatarURL() || undefined;
const inviteUrl = generateInviteUrl();
const embed = new Discord.MessageEmbed()
.setAuthor(`Invite ${client.user?.username}`, avatarURL)
.setAuthor({ name: `Invite ${client.user?.username}`, iconURL: avatarURL })
.setThumbnail(avatarURL as string)
.addField('Invite', `[Invite ${client.user.username} to your server](${inviteUrl})`);
return { embeds: [embed] };