I am trying to (in discord.js) modify the perms of who can access a slash command to allow mods to access one that is (by default) locked. The code below is what I'm using (in my index.js file) and it's been built using the guide. The only real change was removing the await's because I got an error:
await is only valid in async functions and the top level bodies of modules
The error I keep getting now is:
TypeError: Cannot read properties of undefined (reading 'permissions')
if (!client.application?.owner) client.application?.fetch();
const aboutcommand = client.guilds.cache.get('aguildid')?.commands.fetch('acommandid');
const modperms = [
{
id: 'aroleid',
type: 'ROLE',
permission: false,
},
];
aboutcommand.permissions.add({ modperms });