Can you join a roblox group through the roblox API?

Hello everyone!

I am attempting to make a Discord to Roblox ranking bot (but will have more features), but the biggest problem I am having right now is trying to make it so the bot joins the group when they run the /setup command.

My command so far:


const { SlashCommandBuulder, EmbedBuilder, ModalBuilder, ActionRowBuilder, TextRowBuilder } = require('discord.js');
const serverSchema = require('../../Models/Server.js');
const request = require('request');

module.exports = {
  data: new SlashCommandBuilder()
    .setName('setup')
    .setDescription('Sets up the bot for your server.'),
  async execute(interaction) {
    const server = await serverSchema.findOne({ serverId: interaction.guild.id });

    if (server.robloxGroupId == 0 && server.botJoined == false) {
      const setupModal1 = new ModalBuilder()
        .setCustomId('setupModal1')
        .setTitle('Setup');

      const robloxGroupIdInput = new TextRowBuilder()
        .setCustomId('robloxGroupIdInput')
        .setLabel('Roblox Group ID')
        .setStyle(1)
        .setPlaceholder('Enter the Roblox Group ID')
        .setRequired(true);

      const robloxGroupIdActionRow = new ActionRowBuilder()
        .addComponents(setupModal1);

      setupModal1.addComponents(robloxGroupIdActionRow);

      const filter = (interaction) => interaction.customId === 'setupModal1';

      const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });

      if (interaction.isModalSubmit()) {
        const robloxGroupId = interaction.fields.getTextInputValue('robloxGroupIdInput');

        if (isNaN(robloxGroupId)) {
          await interaction.reply({ content: 'Invalid Roblox Group ID. Please enter a valid number.', ephemeral: true });
          return;
        }

        try {
          const headers = { authorization: `Bearer ${process.env.ROBLOX_API_KEY}`,"content-type": "application/json"" };
          
          await request.get(`https://groups.roblox.com/v1/groups/${robloxGroupId}`, {
            method: "POST",
            headers: headers,
            json: true,
          }, async (error, response, body) => {
            if (error) {
              console.error(error);
              await interaction.reply({ content: 'An error occurred while checking the Roblox Group ID.', ephemeral: true });
              return;
            }
            if (response.statusCode === 200) {
              const server = await serverSchema.findOne({ serverId: interaction.guild.id });
              if (server) {
                server.robloxGroupId = robloxGroupId;
                await server.save();
              } else {
                const newServer = new serverSchema({
                  serverId: interaction.guild.id,
                  robloxGroupId: robloxGroupId,
                });
                await newServer.save();
              }
              await interaction.reply({ content: 'Roblox Group ID set successfully.', ephemeral: true });
            } else {
              await interaction.reply({ content: 'Invalid Roblox Group ID. Please enter a valid number.', ephemeral: true });
            }
          }
        }catch (error) {
          
        }
      }
    }
  },
};

If someone could help me with this command that would be great.

Thanks,
Joe

What exactly is broken?

I can’t figure out if there is or isn’t a API for it. Some posts on the devforum say that there is and some say that there isn’t.

Basically im trying to figure out what the link is and the headers needed for it

1 Like

There is an endpoint to join a Roblox Group, however, it’s captcha protected and extremely hard to use.

/v1/groups/{groupId}/users
Joins a group

P.s: I’ve edited your title to be more clear.

1 Like

So is it still doable with captcha? If so how would I be able to?

It’s doable but extremely difficult, it will required captcha solving and due to the fact that this can be maliciously exploited I can’t provide more feedback on that.

1 Like

Alright no worries. Thanks for the help :+1:

This topic was automatically closed after 7 days. New replies are no longer allowed.