I recently have been using discord.js to make slash commands but made a typo. Instead of making it say /help, I made it say /hlep. I tried to find its its id by using console.log(client.api.applications(client.user.id).commands.get())
, but it just said Promise { <pending> }
in console and I don't know what to do.
As client.api.applications(client.user.id).commands.get()
is asynchronous, it returns a Promise instead of an object.
From MDN:
A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason.
A pending promise can either be fulfilled with a value or rejected with a reason (error).
Either use the .then
function, to run code when the Promise fulfils:
client.api.applications(client.user.id).commands.get().then((result) => {
console.log(result);
// You may also put other code here to be run when it is fulfilled.
});
... or use it in an asynchronous function like so:
let result = await client.api.applications(client.user.id).commands.get();
console.log(result);