mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 03:01:04 -05:00
Update dependencies to latest
This commit is contained in:
1088
package-lock.json
generated
1088
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "markov-discord",
|
"name": "markov-discord",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"description": "A conversational Markov chain bot for Discord",
|
"description": "A conversational Markov chain bot for Discord",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -31,47 +31,47 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.12.0",
|
"@discordjs/builders": "^0.13.0",
|
||||||
"@discordjs/rest": "^0.3.0",
|
"@discordjs/rest": "^0.4.1",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"better-sqlite3": "^7.5.0",
|
"better-sqlite3": "^7.5.3",
|
||||||
"bufferutil": "^4.0.6",
|
"bufferutil": "^4.0.6",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.13.2",
|
"class-validator": "^0.13.2",
|
||||||
"date-fns": "^2.28.0",
|
"date-fns": "^2.28.0",
|
||||||
"discord-api-types": "^0.26.1",
|
"discord-api-types": "^0.33.0",
|
||||||
"discord.js": "^13.6.0",
|
"discord.js": "^13.7.0",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.1",
|
||||||
"erlpack": "github:discord/erlpack",
|
"erlpack": "github:discord/erlpack",
|
||||||
"fs-extra": "^10.0.1",
|
"fs-extra": "^10.1.0",
|
||||||
"json5": "^2.2.1",
|
"json5": "^2.2.1",
|
||||||
"markov-strings-db": "^4.2.0",
|
"markov-strings-db": "^4.2.0",
|
||||||
"pino": "^7.9.2",
|
"pino": "^7.11.0",
|
||||||
"pino-pretty": "^7.6.0",
|
"pino-pretty": "^7.6.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"simple-eta": "^3.0.2",
|
"simple-eta": "^3.0.2",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"typeorm": "^0.3.3",
|
"typeorm": "^0.3.6",
|
||||||
"utf-8-validate": "^5.0.9",
|
"utf-8-validate": "^5.0.9",
|
||||||
"zlib-sync": "^0.1.7"
|
"zlib-sync": "^0.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.11.21",
|
"@types/node": "^16.11.36",
|
||||||
"@types/validator": "^13.7.2",
|
"@types/validator": "^13.7.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
||||||
"@typescript-eslint/parser": "^5.16.0",
|
"@typescript-eslint/parser": "^5.25.0",
|
||||||
"eslint": "^8.12.0",
|
"eslint": "^8.16.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-config-prettier": "^8.5.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",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"pm2": "^5.2.0",
|
"pm2": "^5.2.0",
|
||||||
"prettier": "^2.6.1",
|
"prettier": "^2.6.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.7.0",
|
||||||
"typedoc": "^0.22.13",
|
"typedoc": "^0.22.15",
|
||||||
"types-package-json": "^2.0.39",
|
"types-package-json": "^2.0.39",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "16"
|
"node": "16"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SlashCommandBuilder, SlashCommandChannelOption } from '@discordjs/builders';
|
import { SlashCommandBuilder, SlashCommandChannelOption } from '@discordjs/builders';
|
||||||
import { REST } from '@discordjs/rest';
|
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 { config } from './config';
|
||||||
import { packageJson } from './util';
|
import { packageJson } from './util';
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ const channelOptionsGenerator = (builder: SlashCommandChannelOption, index: numb
|
|||||||
.setName(`channel-${index + 1}`)
|
.setName(`channel-${index + 1}`)
|
||||||
.setDescription('A text channel')
|
.setDescription('A text channel')
|
||||||
.setRequired(index === 0)
|
.setRequired(index === 0)
|
||||||
.addChannelType(ChannelType.GuildText);
|
.addChannelTypes(ChannelType.GuildText);
|
||||||
|
|
||||||
export const listenChannelCommand = new SlashCommandBuilder()
|
export const listenChannelCommand = new SlashCommandBuilder()
|
||||||
.setName('listen')
|
.setName('listen')
|
||||||
@@ -96,7 +96,7 @@ const commands = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export async function deployCommands(clientId: string) {
|
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) {
|
if (config.devGuildId) {
|
||||||
await rest.put(Routes.applicationGuildCommands(clientId, config.devGuildId), {
|
await rest.put(Routes.applicationGuildCommands(clientId, config.devGuildId), {
|
||||||
body: commands,
|
body: commands,
|
||||||
|
|||||||
34
src/index.ts
34
src/index.ts
@@ -12,7 +12,7 @@ import type { PackageJsonPerson } from 'types-package-json';
|
|||||||
import makeEta from 'simple-eta';
|
import makeEta from 'simple-eta';
|
||||||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||||
import addSeconds from 'date-fns/addSeconds';
|
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 L from './logger';
|
||||||
import { Channel } from './entity/Channel';
|
import { Channel } from './entity/Channel';
|
||||||
import { Guild } from './entity/Guild';
|
import { Guild } from './entity/Guild';
|
||||||
@@ -39,6 +39,11 @@ interface SelectMenuChannel {
|
|||||||
name?: string;
|
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_PERMISSIONS_MESSAGE = 'You do not have the permissions for this action.';
|
||||||
const INVALID_GUILD_MESSAGE = 'This action must be performed within a server.';
|
const INVALID_GUILD_MESSAGE = 'This action must be performed within a server.';
|
||||||
|
|
||||||
@@ -436,9 +441,9 @@ async function saveGuildMessageHistory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface GenerateResponse {
|
interface GenerateResponse {
|
||||||
message?: Discord.MessageOptions;
|
message?: AgnosticReplyOptions;
|
||||||
debug?: Discord.MessageOptions;
|
debug?: AgnosticReplyOptions;
|
||||||
error?: Discord.MessageOptions;
|
error?: AgnosticReplyOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GenerateOptions {
|
interface GenerateOptions {
|
||||||
@@ -475,7 +480,7 @@ async function generateResponse(
|
|||||||
const response = await markov.generate<MarkovDataCustom>(markovGenerateOptions);
|
const response = await markov.generate<MarkovDataCustom>(markovGenerateOptions);
|
||||||
L.info({ string: response.string }, 'Generated response text');
|
L.info({ string: response.string }, 'Generated response text');
|
||||||
L.debug({ response }, 'Generated response object');
|
L.debug({ response }, 'Generated response object');
|
||||||
const messageOpts: Discord.MessageOptions = {
|
const messageOpts: AgnosticReplyOptions = {
|
||||||
tts,
|
tts,
|
||||||
allowedMentions: { repliedUser: false, parse: [] },
|
allowedMentions: { repliedUser: false, parse: [] },
|
||||||
};
|
};
|
||||||
@@ -543,10 +548,13 @@ function getChannelsFromInteraction(
|
|||||||
return textChannels;
|
return textChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
function helpMessage(): Discord.MessageOptions {
|
function helpMessage(): AgnosticReplyOptions {
|
||||||
const avatarURL = client.user.avatarURL() || undefined;
|
const avatarURL = client.user.avatarURL() || undefined;
|
||||||
const embed = new Discord.MessageEmbed()
|
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)
|
.setThumbnail(avatarURL as string)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`A Markov chain chatbot that speaks based on learned messages from previous chat input.`
|
`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`,
|
`${config.messageCommandPrefix} tts or /${messageCommand.name} tts: True`,
|
||||||
`Runs the ${config.messageCommandPrefix} command and reads it with text-to-speech.`
|
`Runs the ${config.messageCommandPrefix} command and reads it with text-to-speech.`
|
||||||
)
|
)
|
||||||
.setFooter(
|
.setFooter({
|
||||||
`${packageJson().name} ${getVersion()} by ${(packageJson().author as PackageJsonPerson).name}`
|
text: `${packageJson().name} ${getVersion()} by ${
|
||||||
);
|
(packageJson().author as PackageJsonPerson).name
|
||||||
|
}`,
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
};
|
};
|
||||||
@@ -596,11 +606,11 @@ function generateInviteUrl(): string {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function inviteMessage(): Discord.MessageOptions {
|
function inviteMessage(): AgnosticReplyOptions {
|
||||||
const avatarURL = client.user.avatarURL() || undefined;
|
const avatarURL = client.user.avatarURL() || undefined;
|
||||||
const inviteUrl = generateInviteUrl();
|
const inviteUrl = generateInviteUrl();
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setAuthor(`Invite ${client.user?.username}`, avatarURL)
|
.setAuthor({ name: `Invite ${client.user?.username}`, iconURL: avatarURL })
|
||||||
.setThumbnail(avatarURL as string)
|
.setThumbnail(avatarURL as string)
|
||||||
.addField('Invite', `[Invite ${client.user.username} to your server](${inviteUrl})`);
|
.addField('Invite', `[Invite ${client.user.username} to your server](${inviteUrl})`);
|
||||||
return { embeds: [embed] };
|
return { embeds: [embed] };
|
||||||
|
|||||||
Reference in New Issue
Block a user