My problem is the i get an error where interaction.createdTimestamp
, is undefined
<code>const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Responds with bot and your ping'),
async execute(client, interaction){
const thinking = new EmbedBuilder()
.setColor('Red')
.setAuthor({name: 'I am thinking', iconURL: 'https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcmEydTFmcTAzMGR4dmYzc2pvdnpwdmlpb3FseHpnaDlkbHBybnAxNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/TNRDoCRLlOqgbtqQh0/giphy.gif'})
const thinked = new EmbedBuilder()
.addFields(
{name: 'Ping', value: `${interaction.createdTimestamp - Date.now()}ms`},
{name: 'API latency', value: `${Math.round(client.ws.ping)}ms`}
)
await interaction.reply({embeds: [thinking], ephemeral: true});
await wait(2_000);
await interaction.editRply({embeds: [thinked], ephemeral: true})
}
}
</code>
<code>const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Responds with bot and your ping'),
async execute(client, interaction){
const thinking = new EmbedBuilder()
.setColor('Red')
.setAuthor({name: 'I am thinking', iconURL: 'https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcmEydTFmcTAzMGR4dmYzc2pvdnpwdmlpb3FseHpnaDlkbHBybnAxNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/TNRDoCRLlOqgbtqQh0/giphy.gif'})
const thinked = new EmbedBuilder()
.addFields(
{name: 'Ping', value: `${interaction.createdTimestamp - Date.now()}ms`},
{name: 'API latency', value: `${Math.round(client.ws.ping)}ms`}
)
await interaction.reply({embeds: [thinking], ephemeral: true});
await wait(2_000);
await interaction.editRply({embeds: [thinked], ephemeral: true})
}
}
</code>
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Responds with bot and your ping'),
async execute(client, interaction){
const thinking = new EmbedBuilder()
.setColor('Red')
.setAuthor({name: 'I am thinking', iconURL: 'https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcmEydTFmcTAzMGR4dmYzc2pvdnpwdmlpb3FseHpnaDlkbHBybnAxNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/TNRDoCRLlOqgbtqQh0/giphy.gif'})
const thinked = new EmbedBuilder()
.addFields(
{name: 'Ping', value: `${interaction.createdTimestamp - Date.now()}ms`},
{name: 'API latency', value: `${Math.round(client.ws.ping)}ms`}
)
await interaction.reply({embeds: [thinking], ephemeral: true});
await wait(2_000);
await interaction.editRply({embeds: [thinked], ephemeral: true})
}
}
And the error is this one:
<code>TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
at Object.execute (C:UserscotugDesktopDiscordBotsEJGamescommandsutilityping.js:13:58)
at Object.execute (C:UserscotugDesktopDiscordBotsEJGameseventsinteractionCreate.js:16:18)
at Client.<anonymous> (C:UserscotugDesktopDiscordBotsEJGamesmain.js:37:44)
at Client.emit (node:events:519:28)
at InteractionCreateAction.handle (C:Userscotugnode_modulesdiscord.jssrcclientactionsInteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:Userscotugnode_modulesdiscord.jssrcclientwebsockethandlersINTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:239:12)
at WebSocketManager.emit (C:Userscotugnode_modules@vladfranguasync_event_emitterdistindex.cjs:282:31)
at WebSocketShard.<anonymous> (C:Userscotugnode_modules@discordjswsdistindex.js:1190:51)
</code>
<code>TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
at Object.execute (C:UserscotugDesktopDiscordBotsEJGamescommandsutilityping.js:13:58)
at Object.execute (C:UserscotugDesktopDiscordBotsEJGameseventsinteractionCreate.js:16:18)
at Client.<anonymous> (C:UserscotugDesktopDiscordBotsEJGamesmain.js:37:44)
at Client.emit (node:events:519:28)
at InteractionCreateAction.handle (C:Userscotugnode_modulesdiscord.jssrcclientactionsInteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:Userscotugnode_modulesdiscord.jssrcclientwebsockethandlersINTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:239:12)
at WebSocketManager.emit (C:Userscotugnode_modules@vladfranguasync_event_emitterdistindex.cjs:282:31)
at WebSocketShard.<anonymous> (C:Userscotugnode_modules@discordjswsdistindex.js:1190:51)
</code>
TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
at Object.execute (C:UserscotugDesktopDiscordBotsEJGamescommandsutilityping.js:13:58)
at Object.execute (C:UserscotugDesktopDiscordBotsEJGameseventsinteractionCreate.js:16:18)
at Client.<anonymous> (C:UserscotugDesktopDiscordBotsEJGamesmain.js:37:44)
at Client.emit (node:events:519:28)
at InteractionCreateAction.handle (C:Userscotugnode_modulesdiscord.jssrcclientactionsInteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:Userscotugnode_modulesdiscord.jssrcclientwebsockethandlersINTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:Userscotugnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:239:12)
at WebSocketManager.emit (C:Userscotugnode_modules@vladfranguasync_event_emitterdistindex.cjs:282:31)
at WebSocketShard.<anonymous> (C:Userscotugnode_modules@discordjswsdistindex.js:1190:51)
I tried to search it up but doesn’t work with anything
New contributor
cotu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.