我试图使一个不和谐的ping命令与延迟,但它显示了这个错误



我试图使ping命令显示延迟,但我面临一个错误,我不知道为什么它显示它,这是错误-

TypeError: Cannot read properties of undefined (reading 'ping')
at Object.execute (C:UsersAyush KumarDesktopAniVenturecommandsutilityping.js:10:74)
at Client.<anonymous> (C:UsersAyush KumarDesktopAniVentureindex.js:78:11)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (C:UsersAyush KumarDesktopAniVenturenode_modulesdiscord.jssrcclientactionsMessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:UsersAyush KumarDesktopAniVenturenode_modulesdiscord.jssrcclientwebsockethandlersMESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:UsersAyush KumarDesktopAniVenturenode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:350:31)
at WebSocketShard.onPacket (C:UsersAyush KumarDesktopAniVenturenode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:443:22)
at WebSocketShard.onMessage (C:UsersAyush KumarDesktopAniVenturenode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:300:10)
at WebSocket.onMessage (C:UsersAyush KumarDesktopAniVenturenode_moduleswslibevent-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,请告诉我如何修复这个错误,谢谢你。

将(message, client)与(client, message)交换

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] });
},
};

相关内容

  • 没有找到相关文章

最新更新