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:
@@ -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,
|
||||
|
||||
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 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] };
|
||||
|
||||
Reference in New Issue
Block a user