[英]I am trying to make a discord.js avatar command, and the mentioning portion doesn't work correctly
[英]I am trying to make a discord.js ping command with latency but it shows this error
我正在嘗試制作一個顯示延遲的 ping 命令,但我遇到了一個錯誤,我不知道為什么會顯示它,這是錯誤 -
TypeError: Cannot read properties of undefined (reading 'ping')
at Object.execute (C:\Users\Ayush Kumar\Desktop\AniVenture\commands\utility\ping.js:10:74)
at Client.<anonymous> (C:\Users\Ayush Kumar\Desktop\AniVenture\index.js:78:11)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketManager.js:350:31)
at WebSocketShard.onPacket (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
at WebSocketShard.onMessage (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
at WebSocket.onMessage (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:390:28)
ping.js 中的代碼 -
const Discord = require("discord.js");
module.exports = {
name: 'ping',
cooldown: 4,
execute(message, client) {
const bot = message.createdTimestamp - Date.now();
const ping = new Discord.MessageEmbed()
.setTitle("Pong! :ping_pong:")
.setDescription(`Bot latency: \`${bot}ms\`\n API latency: \`${client.ws.ping}ms\``)
.setColor("#31e8b7")
.setTimestamp()
.setFooter(`${message.author.tag}`);
message.channel.send({ embeds: [ping] });
},
};
我正在使用 discord.js v13,請告訴我如何解決此錯誤,謝謝。
用(客戶端,消息)交換你的(消息,客戶端)
execute(client, message) {
const bot = message.createdTimestamp - Date.now();
const ping = new Discord.MessageEmbed()
.setTitle("Pong! :ping_pong:")
.setDescription(`Bot latency: \`${bot}ms\`\n API latency: \`${client.ws.ping}ms\``)
.setColor("#31e8b7")
.setTimestamp()
.setFooter(`${message.author.tag}`);
message.channel.send({ embeds: [ping] });
},
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.