So my goal is to have a command that shows all the bots commands and the attached user permissions. I have the function to fetch the list of commands

```js
var commands = await interaction.guild.commands.fetch()
    .catch(error => {
        interaction.reply({content: 'Unknown Error', ephemeral: true})
    })

```

And this all works fine, i get a nice collection of my commands, my question is, (which i have been unable to solve for 2 hours). Is how can i iterate over this collection and get the perms for each command, i know how to get the perms for a single command with this

```js
var perms = await interaction.guild.commands.permissions.fetch({command: command.id})

```

but how can i get a JSON list with all the perms for each command that also can accommodate for perms being undefined (as some commands dont have attached perms)

The issue i have been having is that a function to do so like this

```js
await commands.each(async (command) => {
    await interaction.guild.commands.permissions.fetch({command: command.id})
        .then(perms => {
            console.log(`**${command.name}** \`${command.id}\``)
            fields.push({title: command.id, value: perms})
        })
        .catch(error => {
            //Triggered if command has no perms
            fields.push({title: command.id, value: 'None'})
        })
})

```

with this the code afterwards that uses fields continues before the fields is filled meaning my message is always empty. How can i make the following code wait for this loop to have fully finished