OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Problems with createdTimestamp discord.js V14.15.3

  • Thread starter Thread starter cotu
  • Start date Start date
C

cotu

Guest
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.editReply({embeds: [thinked], ephemeral: true})

        }
}

And the error is this one:

Code:
TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
    at Object.execute (C:\Users\cotug\Desktop\DiscordBots\EJGames\commands\utility\ping.js:13:58)
    at Object.execute (C:\Users\cotug\Desktop\DiscordBots\EJGames\events\interactionCreate.js:16:18)
    at Client.<anonymous> (C:\Users\cotug\Desktop\DiscordBots\EJGames\main.js:37:44)
    at Client.emit (node:events:519:28)
    at InteractionCreateAction.handle (C:\Users\cotug\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (C:\Users\cotug\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:\Users\cotug\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
    at WebSocketManager.<anonymous> (C:\Users\cotug\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
    at WebSocketManager.emit (C:\Users\cotug\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
    at WebSocketShard.<anonymous> (C:\Users\cotug\node_modules\@discordjs\ws\dist\index.js:1190:51)

I tried to search it up but doesn't work with anything

<p>My problem is the i get an error where <code>interaction.createdTimestamp</code>, is undefined</p>
<pre class="lang-js prettyprint-override"><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.Y2...ZfYnlfaWQmY3Q9cw/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.editReply({embeds: [thinked], ephemeral: true})

}
}
</code></pre>
<p>And the error is this one:</p>
<pre><code>TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
at Object.execute (C:\Users\cotug\Desktop\DiscordBots\EJGames\commands\utility\ping.js:13:58)
at Object.execute (C:\Users\cotug\Desktop\DiscordBots\EJGames\events\interactionCreate.js:16:18)
at Client.<anonymous> (C:\Users\cotug\Desktop\DiscordBots\EJGames\main.js:37:44)
at Client.emit (node:events:519:28)
at InteractionCreateAction.handle (C:\Users\cotug\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\cotug\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\cotug\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\cotug\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\cotug\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (C:\Users\cotug\node_modules\@discordjs\ws\dist\index.js:1190:51)

</code></pre>
<p>I tried to search it up but doesn't work with anything</p>
 
Top