Ошибка:
D:\botjs\node_modules\ts-node\src\index.ts:423
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
commands/page.ts:75:33 - error TS2339: Property 'createMessageComponentCollector' does not exist on type 'TextChannel'.
75 collector = channel.createMessageComponentCollector({ filter, time })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at createTSError (D:\botjs\node_modules\ts-node\src\index.ts:423:12)
at reportTSError (D:\botjs\node_modules\ts-node\src\index.ts:427:19)
at getOutput (D:\botjs\node_modules\ts-node\src\index.ts:554:36)
at Object.compile (D:\botjs\node_modules\ts-node\src\index.ts:760:32)
at Module.m._compile (D:\botjs\node_modules\ts-node\src\index.ts:839:43)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .ts] (D:\botjs\node_modules\ts-node\src\index.ts:842:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
Вот весь код файла:
import {
Interaction,
Message,
MessageActionRow,
MessageButton,
MessageEmbed,
} from "discord.js"
import { ICommand } from "wokcommands"
const embeds: MessageEmbed[] = []
const pages = {} as {
[key: string]: number
}
for (let a = 0; a < 4; ++a) {
embeds.push(
new MessageEmbed()
.setDescription(`Page ${a + 1}`)
)
}
const getRow = (id: string) => {
const row = new MessageActionRow()
row.addComponents(
new MessageButton()
.setCustomId("prev_embed")
.setStyle("SECONDARY")
.setEmoji("⏮")
.setDisabled(pages[id] === 0)
)
row.addComponents(
new MessageButton()
.setCustomId("next_embed")
.setStyle("SECONDARY")
.setEmoji("⏭")
.setDisabled(pages[id] === embeds.length - 1)
)
return row
}
export default {
category: "Pages",
description: "Страницы с embed",
slash: "both",
testOnly: true,
callback: async ({ user, message, interaction, channel }) => {
const id = user.id
pages[id] = pages[id] || 0
const embed = embeds[pages[id]]
let reply: Message | undefined
let collector
const filter = (i: Interaction) => i.user.id === user.id
const time = 1000 * 60 * 5
if (message) {
reply = await message.reply({
embeds: [embed],
components: [getRow(id)],
})
collector = reply.createMessageComponentCollector({ filter, time })
} else {
interaction.reply({
ephemeral: true,
embeds: [embed],
components: [getRow(id)],
})
collector = channel.createMessageComponentCollector({ filter, time })
}
collector.on("collect", (btnInt) => {
if (!btnInt) {
return
}
btnInt.deferUpdate()
if (
btnInt.customId !== "prev_embed" &&
btnInt.customId !== "next_embed"
) {
return
}
if (btnInt.customId === "prev_embed" && pages[id] > 0) {
--pages[id]
} else if (
btnInt.customId === "next_embed" &&
pages[id] < embeds.length - 1
) {
++pages[id]
}
if (reply) {
reply.edit({
embeds: [embeds[pages[id]]],
components: [getRow(id)],
})
} else {
interaction.editReply({
embeds: [embeds[pages[id]]],
components: [getRow(id)],
})
}
})
},
} as ICommand