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

189
Views
How do you grant access to the server information (guilds, members, applications.commands) for your discord application?

Hey guys I'm currently developing a discord application that is connected to a firebase app. In this discord application I created a command /init-hub that allow user to create a document in this firebase firestore with the reference equal to the discord server id (one hub = one server).

Here is my problem,

I created this command :

 run: async (client: Client, interaction: BaseCommandInteraction) => {
        if (!interaction.guildId) {
            await interaction.followUp({
                ephemeral: true,
                content: 'Unable to create HUB for this server, contact us'
            });
            return;
        }

        const content = "Hub generated";
        // Get firestore db
        const db = admin.firestore();
        // ID OF THE SERVER
        const guild = client.guilds.cache.get(interaction.guildId);
        console.log(guild);

The log returned here is "undefined" but before I remove my app from my server and add it again (I Had an issue) this function worked perfectly.

Should I change the way I'm "fetching" my guild ? is there another way to do it with just the ID ?

I think my problem is coming from the "scope" or permissions in the invite URL for my application if anybody could tell me how I should create this URL here is mine :

https://discord.com/api/oauth2/authorize?client_id=[CLIENT_ID]&redirect_uri=https%3A%2F%2Fdiscordapp.com%2Foauth2%2Fauthorize%3F%26client_id%3D[CLIENT_ID]%26scope%3Dguilds%2520applications.commands&response_type=code&scope=guilds%20guilds.members.read%20rpc.voice.read%20applications.commands

Also in my discord client I specified those Intents :

const client = new Client({
    intents: [
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_VOICE_STATES,
        Intents.FLAGS.GUILD_MEMBERS,
        Intents.FLAGS.DIRECT_MESSAGES,
    ]
});

UPDATE :

When I try with this code :

const guild = await client.guilds.fetch(interaction.guildId);

I receive this error : DiscordAPIError: Missing Access

about 4 years ago · Juan Pablo Isaza
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!