【发布时间】:2021-11-07 10:27:31
【问题描述】:
enter image description here 我希望我的 keytritz 机器人在标题为 naruto / Naruto 时对嵌入做出反应,但在第一个中我得到一个错误(#1)但它不影响功能但在第二个嵌入中(#2)我得到了一个错误keytritz 机器人没有反应也没有评论 ,我留下一个链接,两个机器人的代码在哪里, mudae 机器人不是我的。 https://mega.nz/folder/IIUHEabJ#IIaRNcMgUS2gC-d_lZXQZw https://top.gg/bot/432610292342587392
代码 Keytritz:
for(var i = 0; i < message.embeds.length; i++) {
message.channel.send(message.content.embeds);
if(message.embeds[i].title.includes("naruto")){
message.react(" ")
message.channel.send("Detected");
break;
}
}
嵌入 lxXxandresxXxl
if(message.content.startsWith(prefix+"r")) {
message.channel.send({ embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.displayAvatarURL()
},
title: "This is an naruto embed",
url: "http://google.com",
description: "This is a test embed to showcase what they look like and what they can do.",
fields: [{
name: "Fields",
value: "They can have different fields with small headlines."
},
{
name: "Masked links",
value: "You can put [masked links](http://google.com) inside of rich embeds."
},
{
name: "Markdown",
value: "You can put all the *usual* **__Markdown__** inside of them."
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.displayAvatarURL(),
text: "© Example"
}
}
});
}
错误 1#
(node:1744) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
at async RequestHandler.push (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:1744) 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(). (rejection id: 1)
(node:1744) [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.
错误2#
if(message.embeds[i].title.includes("naruto")){
^
TypeError: Cannot read property 'includes' of null
at Client.<anonymous> (/app/server.js:90:36)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:196:13)
at Receiver.receiverOnMessage (/rbd/pnpm-volume/8bd4e7c9-1711-40fc-be45-7d082848ec2a/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/node_modules/ws/lib/websocket.js:983:20)
【问题讨论】:
标签: javascript node.js discord discord.js