Я не понимаю, что я написал неправильно. Может в новой версии discord.js или java поменяли.
Я хотел сделать echo команду.
Вот весь код:
import { MessageEmbed, TextChannel } from "discord.js";
import { ICommand } from "wokcommands";
export default {
category: "Configuration",
description: "Сообщение от имени бота",
permissions: ["ADMINISTRATOR"],
minArgs: 2,
expectedArgs: "<channel> <text>",
expectedArgsTypes: ["CHANNEL", "STRING"],
slash: "both",
testOnly: true,
guildOnly: true,
callback: ({ message, interaction, args }) => {
const channel = (message
? message.mentions.channels.first()
: interaction.options.getChannel("channel")) as TextChannel
if (!channel || channel.type !== "GUILD_TEXT") {
const embed = new MessageEmbed()
.setTitle(`ERROR`)
.setDescription(`Укажите текстовый канал.`)
.setColor(`#FF0000`)
return embed
}
args.shift()
const text = args.join(" ")
channel.send(text)
const embed = new MessageEmbed()
.setTitle(`ECHO`)
.setDescription(
`Сообщение от имени бота было отправлено.`)
.setColor(`#8CF248`)
if (interaction) {
interaction.reply({
embeds: [embed],
ephemeral: true,
})
}
}
} as ICommand
Терминал:
WOKCommands > Your bot is now running.
WOKCommands > Loaded 6 commands.
D:\botjs\node_modules\ts-node\src\index.ts:423
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
commands/send.ts:33:17 - error TS2339: Property 'send' does not exist on type 'TextChannel'.
33 channel.send(text)
~~~~
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)
[nodemon] app crashed - waiting for file changes before starting...