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

209
Views
How can I access to the guild IDs (Discord Bot)
client.once('ready', () => {
    console.log("STARTTTTTTT");

    const guildId = // ??
    const guild = client.guilds.cache.get(guildId)
    let commands

    if (guild) {
        commands = guild.commands
    } else {
        commands = client.application?.commands
    }

    commands?.create({
        name: "lena",
        description: "LENAAAAAAAAAA",
        options: [
            {
                name: 'name',
                description: "LENAAAAAAA",
                required: true,
                type: Discord.Constants.ApplicationCommandOptionTypes.STRING
            },
            {
                name: 'text',
                description: "LENAAA",
                required: false,
                type: Discord.Constants.ApplicationCommandOptionTypes.STRING
            },
        ]
    })
})

In line 4 you can see that I need to define on Guild Ids, the question I am asking myself is how do I access all of them, how do I access all the servers that my discord bot is on?

Or is there a simpler way?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Using client.guilds.cache

console.log(client.guilds.cache) // Collection of all guild objects

To get it as an array:

console.log([...client.guilds.cache.values()])

To get all IDs

console.log(client.guilds.cache.map(g => g.id)) // Array of IDs
about 4 years ago · Juan Pablo Isaza 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!