Slash Command Guild Permission Overwrite

Hello there. I'll make this quick. In sort, I am making a command that applies slash command permission overwrites to servers based on a file it reads. Now, I did manage to write everything that sets up the properties object to be applied to the guild.commands.permissions.set() function, but for some reason, it just does not accept it. Here is an overview of the important chunks of code:
const guildPermissions: {id: string, permissions: ApplicationCommandPermissions[]}[] = []

{ // This is a loop
const permissions: ApplicationCommandPermissions[] = []

{ // This is also a loop
permissions.push({
id: roleId,
type: ApplicationCommandPermissionType.Role,
permission: true
})
}

guildPermissions.push({
id: commandId,
permissions,
})
}

guild.commands.permissions.set({
token: process.env.DISCORD_TOKEN,
permissions: guildPermissions // The "permissions" key is highlighted red with an error
})
const guildPermissions: {id: string, permissions: ApplicationCommandPermissions[]}[] = []

{ // This is a loop
const permissions: ApplicationCommandPermissions[] = []

{ // This is also a loop
permissions.push({
id: roleId,
type: ApplicationCommandPermissionType.Role,
permission: true
})
}

guildPermissions.push({
id: commandId,
permissions,
})
}

guild.commands.permissions.set({
token: process.env.DISCORD_TOKEN,
permissions: guildPermissions // The "permissions" key is highlighted red with an error
})
The error I get is the following:
Type '{ id: string; permissions: ApplicationCommandPermissions[]; }[]' is not assignable to type 'readonly ApplicationCommandPermissions[]'.
Type '{ id: string; permissions: ApplicationCommandPermissions[]; }' is missing the following properties from type 'ApplicationCommandPermissions': type, permissionts(2322)
index.d.ts(4620, 3): The expected type comes from property 'permissions' which is declared here on type '{ command: ApplicationCommandResolvable; } & EditApplicationCommandPermissionsMixin'
Type '{ id: string; permissions: ApplicationCommandPermissions[]; }[]' is not assignable to type 'readonly ApplicationCommandPermissions[]'.
Type '{ id: string; permissions: ApplicationCommandPermissions[]; }' is missing the following properties from type 'ApplicationCommandPermissions': type, permissionts(2322)
index.d.ts(4620, 3): The expected type comes from property 'permissions' which is declared here on type '{ command: ApplicationCommandResolvable; } & EditApplicationCommandPermissionsMixin'
I am unsure whether I am doing something wrong or this is a TS issue. If anyone knows how I could solve this, then it would be very helpful. Thank you for your time and help, I truly appreciate it.
4 Replies
d.js toolkit
d.js toolkitβ€’15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Batimius
BatimiusOPβ€’15mo ago
Here is the entire function if it is of any help:
πŸŒΊπŸ‡«πŸ‡· Shigu :3 🌺
You're missing a type property.
d.js docs
d.js docsβ€’15mo ago
interface ApplicationCommandPermissions The object returned when fetching permissions for an application command.
Want results from more Discord servers?
Add your server