How to fetch the commandID of the command that was just executed

Hey there! I'm using discord.js v13.8.0 and I'm trying to get the command id of the command when its executed so I can do something like: ${user} used the </command:0> command, here is some of my interactionCreate file:
8 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
vance_
vance_2y ago
As you can see it's undefined
vance_
vance_2y ago
Here's what I'm doing currently:
let cmd = await client.application.commands.fetch()
return logs.send(`The ${command.name} (${cmd.id}) command was executed by **${interaction.user.tag}** in **${interaction.guild.name}** (**${client.commandsRan}**) commands ran`);
let cmd = await client.application.commands.fetch()
return logs.send(`The ${command.name} (${cmd.id}) command was executed by **${interaction.user.tag}** in **${interaction.guild.name}** (**${client.commandsRan}**) commands ran`);
(when a user uses a command this happens)
if (interaction.isCommand()) {
let command = client.slashCommands.find(
(x) => x.name == interaction.commandName

//the } is not closed as there is code below too
if (interaction.isCommand()) {
let command = client.slashCommands.find(
(x) => x.name == interaction.commandName

//the } is not closed as there is code below too
(my interaction command structure)
Syjalo
Syjalo2y ago
You didn't pass any parameters to the fetch so it fetches all commands and your cmd is a Collection of commands.
vance_
vance_2y ago
so should I just add client.application.commands.fetch(command)? because that should fetch cmd or command
d.js docs
d.js docs2y ago
property CommandInteraction#commandId The invoked application command's id
vance_
vance_2y ago
its undefined though ah wait you mean interaction.commandId
d.js docs
d.js docs2y ago
property CommandInteraction#commandId The invoked application command's id