Команда, которой не существует - PullRequest
0 голосов
/ 03 августа 2020
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
    if (!message.member.hasPermission("MANAGE_GUILD")) return message.reply("You don't have enough permission");

    let contSend = args.splice(1).join(' ');

    let chanSendFind = message.mentions.channels.first() ? message.mentions.channels.first().id : true;

    if (chanSendFind === true) return message.reply(`you need to specify a channel to send this message in. {prefix}send #<channel_name> <content>`);
    if (!contSend) return message.reply('I can\'t send an empty message.');

    bot.channels.get(chanSendFind).send(contSend)
        .then(() => message.react(`✅`))
        .catch(console.error);
}
(node:4) UnhandledPromiseRejectionWarning: TypeError: bot.channels.get is not a function

2020-08-03T09:46:19.027003+00:00 app[worker.1]:     at Object.module.exports.run (/app/commands/send.js:12:18)

2020-08-03T09:46:19.027012+00:00 app[worker.1]:     at Client.<anonymous> (/app/bot.js:39:21)

2020-08-03T09:46:19.027012+00:00 app[worker.1]:     at Client.emit (events.js:327:22)

2020-08-03T09:46:19.027013+00:00 app[worker.1]:     at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)

2020-08-03T09:46:19.027014+00:00 app[worker.1]:     at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)

2020-08-03T09:46:19.027015+00:00 app[worker.1]:     at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)

2020-08-03T09:46:19.027015+00:00 app[worker.1]:     at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)

2020-08-03T09:46:19.027015+00:00 app[worker.1]:     at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)

2020-08-03T09:46:19.027017+00:00 app[worker.1]:     at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:125:16)

2020-08-03T09:46:19.027017+00:00 app[worker.1]:     at WebSocket.emit (events.js:315:20)

2020-08-03T09:46:19.027107+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

2020-08-03T09:46:19.027180+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Мой бот выдает ошибку при отправке команды. Я не знаю, почему, пожалуйста, помогите.

1 Ответ

2 голосов
/ 03 августа 2020

Вам необходимо добавить cache:

bot.channels.cache.get(chanSendFind).send(contSend)
    .then(() => message.react(`✅`))
    .catch(console.error);

Для получения дополнительной информации прочтите Discord. js руководство по переходу или проверьте Discord. js документы .

...