Nexus
Discord
  • 📗Getting Started
    • Nexus Website
  • 👥Contributors
  • 🤝Code of Conduct
  • 🚨License
  • 📔Contributing
  • git
    • 🍎Installing Git on MacOS
    • 🪟Installing Git on Windows
    • 🐧Installing Git on Linux
    • 🛠️Git Guide
  • Building the Bot
    • Before you begin
    • First Steps
    • The .env file
    • Custom Bot Functions
  • Commands
    • Creating Commands
    • Creating User Installed Commands
    • Creating Developer Commands
    • Developer Guild Commands
    • Autocomplete
  • Client Modifications
    • client.m
  • handler
    • Handling Discord Events
    • Handling Components
  • Scripts
    • Our customs scripts
    • package.json
    • cleardb
    • db
    • client
    • fetch
    • reset
  • Database
    • MongoDB Connection
    • MongoDB Schemas
  • Resources
    • Privacy Policy
    • Terms of Service
    • NodeJS Download
    • Discord.js
    • Discord.js v14 Guide
    • Discord.js v14 Docs
  • Code Editors
    • Finding your best Code editor
    • Visual Studio IDE Download
    • Visual Studio Code Download
    • VS Code Insiders Download
    • Jetbrains WebStorm Download
    • Jetbrains Fleet Download
    • Jetbrains Aqua Download
Powered by GitBook
On this page
  1. Scripts

fetch

this script fetches all commands of your discord bot and logs them in the console.

const { REST, Routes } = require('discord.js');
const chalk = require('chalk');
require('dotenv').config();

const { TOKEN, ID } = process.env;

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

(async () => {
    try {
        console.log(chalk.yellow('Fetching application (/) commands.'));

        let commands;
        commands = await rest.get(
            Routes.applicationCommands(ID)
        );
        console.log(chalk.cyan('Listing global commands:'));

        if (commands.length === 0) {
            console.log(chalk.red('No commands found.'));
        } else {
            commands.forEach(command => {
                console.log(chalk.green(`Name: ${command.name}, Description: ${command.description}, ID: ${command.id}`));
            });
        }
    } catch (error) {
        console.error(chalk.red('Error fetching commands:', error));
    }
})();
PreviousclientNextreset

Last updated 9 months ago