ContextMenuCommandBuilder.setDMPermission does nothing

I want for my context menu to be inaccessible in DMs. My Context Menu class:
class ContextMenu extends ContextMenuCommandBuilder {
constructor(client, data) {
super();
this.setName(data.name);
this.setDMPermission(data.dm_permission);
this.setType(data.type);
this.setDefaultMemberPermissions(data.default_member_permissions);
}
}
class ContextMenu extends ContextMenuCommandBuilder {
constructor(client, data) {
super();
this.setName(data.name);
this.setDMPermission(data.dm_permission);
this.setType(data.type);
this.setDefaultMemberPermissions(data.default_member_permissions);
}
}
Initialization:
class TestContextMenu extends ContextMenu {
constructor(client) {
super(client, {
type: ApplicationCommandType.Message,
name: "testing",
default_member_permissions: PermissionFlagsBits.ManageMessages,
dm_permission: false

});
}
}
class TestContextMenu extends ContextMenu {
constructor(client) {
super(client, {
type: ApplicationCommandType.Message,
name: "testing",
default_member_permissions: PermissionFlagsBits.ManageMessages,
dm_permission: false

});
}
}
D.js docs (https://discord.js.org/#/docs/builders/main/class/ContextMenuCommandBuilder?scrollTo=setDMPermission) says it accepts null, undefined and boolean, so instead of dm_permission tried all valid values (null, undefined, true and false) and none of them restricted the context menu. The object that is sent to the API is
[
TestContextMenu {
name: 'testing',
type: 3,
default_permission: undefined,
default_member_permissions: '8192',
dm_permission: false
}
]
[
TestContextMenu {
name: 'testing',
type: 3,
default_permission: undefined,
default_member_permissions: '8192',
dm_permission: false
}
]
1 Reply
Stew
Stew2y ago
It works in DMs, tried from 2 different accounts Even restarted discord client to clear potential cache i'm using client.application.commands.set to set my comands so i assume it clears the previous commands so maybe I should first set commands to an empty array and then set it to my desired array of commands? ok I will try if this works, but in general it's better to use the client.application.commands.edit? this worked