Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

404
Views
Use Slash Commands in all servers where have a bot without GuildID (Discord.js v12)

I want people to be able to use Slash Commands against my bot on any server, as long as the bot is there. I have further granted the bot application.commands permission. I was referencing this answer, but it seems to require the server's GuildID. Can I allow anyone using Slash Commands to come to my bot without a GuildID? And how do people use it? (I use Commands Handler)

sorry for my bad english

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You probably want to use a global slash command. Global meaning that it works across all guilds the bot is in and you don't need to provide any guild id.

client.on("ready", () => {

    // Register global slash command
    client.api.applications(client.user.id).commands.post({
        data: {
            name: "hello",
            description: "Say 'Hello, World!'"
        }
    });

    // Listen for an interaction (e.g. user typed command)
    client.ws.on("INTERACTION_CREATE", (interaction) => {
        // Access command properties
        const commandId = interaction.data.id;
        const commandName = interaction.data.name;
        
        // Reply only to commands with name 'hello'
        if (commandName == "hello") {
            // Reply to an interaction
            client.api.interactions(interaction.id, interaction.token).callback.post({
                data: {
                    type: 4,
                    data: {
                        content: "Hello, World!"
                    }
                }
            });
        }
    });

});

This is how would a user use your command:

enter image description here

And the reply looks like this:

enter image description here

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!