I have been trying to write new bot on my own looking at different projects which are written in python. Since they are written in python I have no clue how to migrate them to javascript therefore I am searching through documentation. Yet, I couldn't find anything like tree
or CommandTree
anywhere in those documentations. I use discord.js .
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
client.on('ready', async () => {
await client.user.setActivity({ type: 'WATCHING', name: loadConfigs.activity_name });
if (!fs.existsSync(`${process.env.DATA_PATH}tracked_accounts.db`)) {
initDB();
}
// TODO: Handle tree.on_error and load cogs
log.info(`${client.user.tag} is online`);
const slashCommands = **await client.tree.sync(); //?!?!??**
log.info(`Synced ${slashCommands.length} slash commands`);
});
Basically, what is the equivalent of python code to javascript in here. I want to sync slash commands.
discord.js does not treat command is this sort of way, it is up to the user to deal with how they are loaded and how the events are listened to.
I would recommend looking through this guide, which shows how to implement commands: https://discordjs.guide/creating-your-bot/slash-commands.html