Romejanic / slasher

A framework to simplify the creation of Discord bots.
MIT License
3 stars 2 forks source link

timestamps issue? #1

Closed Legit4K closed 3 years ago

Legit4K commented 3 years ago

Describe the bug Using slasher, I'm unable to access the createdTimestamp property from a reply.

To Reproduce Steps to reproduce the behavior:

    async execute(ctx, client) {
        let wait = await ctx.reply(`\`pinging...\``);

        let ping = new MessageEmbed()
            .setTitle("BOT LATENCY / PING")
            .setColor("RANDOM")
            .addField("Response Time", `${wait.createdTimestamp - ctx.createdTimestamp}ms`)
            .addField("API Latency", `${Math.round(client.ws.ping)}ms`)
        await ctx.edit(ping);
    }

Expected behavior Using discord.js interactions, I would be able to access the timestamp of an interaction reply. I can't do that here 🤔

Screenshots none

Environment (please complete the following information):

Additional context

TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
Romejanic commented 3 years ago

Please refer to the CommandContext docs.

ctx isn't the interaction itself, it's a context object with information about it. To access that field you'll need to use ctx.command.createdTimestamp.

Legit4K commented 3 years ago

Yeah, I tried that too same issue (it can be accessed through ctx.command but not from wait whereas through the native interactions api in discord.js it can be done using wait.createdTimestamp)

Legit4K commented 3 years ago

I've discovered an alternative way to measure the ping so it's not a big deal I suppose