create context menus

I get no error, but no context Menus are created after start the bot:

const rest = new REST({ version: '9' }).setToken(TOKEN);

module.exports = (client) => {
const contextMenus = [];

fs.readdirSync('./contextMenus/').forEach(async dir => {
const files = fs.readdirSync(`./contextMenus/${dir}/`).filter(file => file.endsWith('.js'));

for(const file of files) {
const contextMenu = require(`../contextMenus/${dir}/${file}`);
new ContextMenuCommandBuilder()
.setName(contextMenu.name)
.setType(contextMenu.type);



contextMenus.push({
name: contextMenu.name,
type: contextMenu.type,
default_permission: contextMenu.default_permission ? contextMenu.default_permission : null,
default_member_permissions: contextMenu.default_member_permissions ? PermissionsBitField.resolve(contextMenu.default_member_permissions).toString() : null
});

if(contextMenu.name) {
client.contextMenus.set(contextMenu.name, contextMenu)
table.addRow(file.split('.js')[0], '✅')

} else {
table.addRow(file.split('.js')[0], '⛔')
}
}

});
console.log(chalk.hex("4c0bad")(table.toString()));

(async () => {
try {
//await rest.put(
//Routes.contextMenuCommand(CLIENT_ID),
// { body: contextMenu }
// );

console.log(chalk.blue('Context Menus • Registered'))
} catch (error) {
console.log(error);
}
})();
};

const rest = new REST({ version: '9' }).setToken(TOKEN);

module.exports = (client) => {
const contextMenus = [];

fs.readdirSync('./contextMenus/').forEach(async dir => {
const files = fs.readdirSync(`./contextMenus/${dir}/`).filter(file => file.endsWith('.js'));

for(const file of files) {
const contextMenu = require(`../contextMenus/${dir}/${file}`);
new ContextMenuCommandBuilder()
.setName(contextMenu.name)
.setType(contextMenu.type);



contextMenus.push({
name: contextMenu.name,
type: contextMenu.type,
default_permission: contextMenu.default_permission ? contextMenu.default_permission : null,
default_member_permissions: contextMenu.default_member_permissions ? PermissionsBitField.resolve(contextMenu.default_member_permissions).toString() : null
});

if(contextMenu.name) {
client.contextMenus.set(contextMenu.name, contextMenu)
table.addRow(file.split('.js')[0], '✅')

} else {
table.addRow(file.split('.js')[0], '⛔')
}
}

});
console.log(chalk.hex("4c0bad")(table.toString()));

(async () => {
try {
//await rest.put(
//Routes.contextMenuCommand(CLIENT_ID),
// { body: contextMenu }
// );

console.log(chalk.blue('Context Menus • Registered'))
} catch (error) {
console.log(error);
}
})();
};
3 Replies
d.js toolkit
d.js toolkit16mo 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!
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Black_Wither
Black_WitherOP16mo ago
yes because I dont know why and I found no solution oh I found a solution, i thinked that it isnt the same like slash Commands and edit applicationCommands to contextMenuCommands and this was my problem
Want results from more Discord servers?
Add your server