AstraBots.xyz Documentation

avatar

LuckyDev [Owner]

Website Founder

Greetings from Astrabots.xyz!

We are pleased to offer you a warm and hearty welcome as you embark on an exploration of Astrabots.xyz. At Astrabots.xyz, we take great pride in introducing a state-of-the-art platform that enables seamless bot management and access to vital information through our intuitive API.

In today's swiftly evolving digital environment, where automation and AI-driven solutions are progressively becoming essential, Astrabots.xyz stands as your dependable partner. Our platform has been thoughtfully crafted to meet the diverse requirements of bot enthusiasts, developers, and organizations, ensuring you unlock the complete potential of automation technologies.

/GET Requests

/api/v1/bot/:id

/GET API Endpoints

/GET
/api/v1/bot/:id

In order to make this work, you need 2 parameters.

  • botID
  • token

Example Code:

const botID = "860206392652595281";
const token = "WEBSITE_BOT_TOKEN"; // Only visible to bot's website owner(s)

fetch("https://astrabots.xyz/api/v1/bot/" + botID, {
    method: "GET",
    headers: {
        "Content-Type": "application/json",
        "Authorization": token
    }
}).then(res => res.json()).then(json => {
    console.log(json);
}).catch(err => {
    console.log(err);
});

Example Result:

{
  "username": "AstraBot",
  "owners": [
    "857177733398265876",
    "559651275877384193"
  ],
  "votes": 165,
  "rates": [
    {
      "author": "857177733398265876",
      "star": 5,
      "comment": "Pretty nice bot!",
      "date": 1664108015332
    },
    {
      "author": "559651275877384193",
      "star": 4,
      "comment": "Good bot!",
      "date": 1664108015332
    }
  ],
  "shortDesc": "AstraBot is a bot that can do many things, such as moderation, fun, utility, and more!",
  "total": {
    "votes": 165,
    "comments": 14
  },
  "tags": [
    "Fun",
    "Memes",
    "Utility",
    "Moderation"
  ]
}

Possible return errors:

  • 401 - Unauthorized! The provided token does not match the bot's token
  • 500 - Internal server error
/POST
/api/v1/bot/:id/guilds

In order to make this work, you need 2 parameters.

  • botID
  • token

Example Code:

const { Client, Intents } = require('discord.js');
const fetch = require('node-fetch'); // Import the 'node-fetch' library

const CLIENT_TOKEN = "YOUR_BOT_TOKEN"; // Replace with your bot's token

const client = new Client({
    intents: [Intents.FLAGS.GUILDS]
});

client.once('ready', () => {
    console.log(`Logged in as ${client.user.tag}`);
    updateGuildsCount();
});

async function updateGuildsCount() {
    try {
        const guildsCount = client.guilds.cache.size;

        const response = await fetch(`https://astrabots.xyz/api/v1/bot/${client.user.id}/guilds`, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Authorization": CLIENT_TOKEN
            },
            body: JSON.stringify({ guildsCount })
        });

        if (response.ok) {
            const data = await response.json();
            console.log(data);
        } else {
            console.error(`Failed to update guilds count: ${response.status} ${response.statusText}`);
        }
    } catch (error) {
        console.error(`Error updating guilds count: ${error}`);
    }
}

client.login(CLIENT_TOKEN);
            

Example Result:

{
  "status": "success",
  "message": "Successfully updated guild count!"
}

Possible return errors:

  • 401 - Unauthorized! The provided token does not match the bot's token
  • 500 - Internal server error