# Javascript

> NPM package: [**`elara-services`**](https://npmjs.org/package/elara-services)

## Base

```javascript
const s = require("elara-services"), 
      services = new s("YOUR API KEY");
```

## Support

```javascript
let support = services.support;
// Returns the support link.
```

## Docs

```javascript
let docs = services.docs;
// Returns the docs page link.
```

## Ping

```javascript
let res= await services.ping();
if(res.status !== true) return console.log(res.message);
// Returns {status: true, time: 12345}
```

## Pastebin

```javascript
// GET

let res = await services.paste.get("ID");
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, key: "ID", content: "The paste content", url: "URL", title: "The title of the paste", created: "Date", expire: "Date"}

// ----------------------------------------------------------------
// POST

let res = await services.paste.post("Title", "Content"); 
// Optional ("title", "content", true) | 'true' is making the paste private
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, id: "ID", url: "URL"}
```

## Hastebin

```javascript
// GET

let res = await services.haste.get("ID");
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, id: "ID", url: "URL", content: "The data"}

// -----------------------------------------------------------

// POST

let res = await services.haste.post("Content");
// Optional ("content", {url: "hastebin URL", extension: "js"})
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, id: "ID", url: "URL"}
// -----------------------------------------------------------
```

## DBL([top.gg](https://top.gg/))

```javascript
// GET
//------------------------------------------------------------
let res = await services.api.dbl.get("Your DBL Token", "ID");
if(res.status !== true) return console.log(res.message);
console.log(res) // To see what it returns, too much there to list!

// -----------------------------------------------------------
// POST
let res = await services.api.dbl.post("Your DBL token", "ID", servers_count, shards_count);
// "shards_count" is optional.. 
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, message: "Stats posted to DBL(top.gg)"}
```

## Translate

```javascript
let res = await services.api.translate("to_Lang", "message to translate");
if(res.status !== true) return console.log(res.message);
// Returns: {
//    status: true,
//    message: "The trasnlated message",
//    extra: {
//        raw: {}, // The raw object for the translation
//        from: {
//            full: "English",
//            iso: "en"
//        },
//        to: {
//            full: "French",
//            iso: "fr"
//        }
//    }
//}
```

## Invites

```javascript
let res = await services.api.invites("type");
// Types: nitro, global, both (Default is both)
if(res.status !== true) return console.log(res.message);
// Returns
//- Nitro & Global: {status: true, invites: []} 
//- Both: {status: true, global: [], nitro: []}

```

## 8ball

```javascript
let res = await services.api.ball();
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, text: "OK", image: "URL"}
```

## NPM

```javascript
let res = await services.api.npm("package name");
if(res.status !== true) return console.log(res.message);
// Returns:
{
    status: true,
    name: "",
    url: "",
    tags: [],
    description: "",
    latest: "",
    maintainers: [],
    author: "",
    license: "",
    created: "",
    updated: "",
    pages: {
        bugs: "",
        home: "",
        download: "",
        repository: ""
    },
    readme: ""
}
```

## Facts

```javascript
let res = await services.api.facts("type");
// Types: random, all (Default is "random")
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, fact: "Random Fact"};
// or
// Returns: {status: true, facts: []} | If "all" is returned
```

## Time

```javascript
let res = await services.api.time("place", true);
// If true it will return all.
if(res.status !== true) return console.log(res.message);
// Returns: 
{
    status: true,
    name: "EST",
    place: "America/New_York"
}
// OR
{
    status: true,
    times: [] // Array of the supported times
}
```

## Dog Breeds

```javascript
let res = await services.api.dogbreed(optional_type, optional_breed);
// Types: list, random (default is random)
// Breeds: Use: "type: list" to see all of the supported breeds.
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, image: "URL"}
// OR
// Returns: {status: true, list: [], bot_fields: []}
// "bot_fields" are mapped out for Discord Bot embed fields
```

## Memes

```javascript
let res = await services.api.memes(optional_clean);
// optional_clean: boolean, if it's true it will only return clean memes, if false it will return everything
if(res.status !== true) return console.log(res.message);
// Returns: {status: true, image: "URL"}
```

## Discord.js-Docs

```javascript
let res = await services.api.docs("Search", "Project, default is normal d.js", "Branch, default is 'stable'");
if(res.status !== true) return console.log(res.message);
console.log(res); // To see what it returns.
```

## Platform

```javascript
// Mixer
let res = await services.api.platform.mixer("USERNAME");

// Twitch
let res = await services.api.platform.twitch("CLIENT-ID", "USERNAME OR USER ID");

// YouTube-Stats
let res = await services.api.platform.ytstats("CLIENT_ID", "CHANNEL_ID_OR_NAME");

// YouTube-Search
let res = await services.api.platform.ytsearch("CLIENT_ID", "Search Query", "type, default is 'video'");

// IMDB
let res = await services.api.platform.imdb("CLIENT_ID", "name of the show or movie");

// Fortnite
let res = await services.api.platform.fortnite("CLIENT_ID", "Username", "platform, default is 'pc'");

// Paladins
let res = await services.api.platform.paladins("DEV_ID", "DEV_AUTH", "USERNAME", "PLATFORM, default is 'pc'");

// Roblox
let res = await services.api.platform.roblox("Discord User ID");

// Roblox-Group
let res = await services.api.platform.robloxgroup("Group ID");

// Picarto
let res = await services.api.platform.picarto("username or ID");

if(res.status !== true) return console.log(res.message);
console.log(res); // To see what each of them returns
```

## Photos

```javascript
let res = await services.api.photos("type");
// Current types as of 1/15/2020
// cats, dogs, pugs, blobs, penguins, pandas, hugs, husky, cookies, pokes, garfield, cards, boops
if(res.status !== true) return console.log(res.message);
// Returns {status: true, image: "URL"}
```

## Math

```javascript
let res = await services.api.math("2+2");
if(res.status !== true) return console.log(res.message);
// Returns: 
{
    status: true, 
    answer: "Some answer"
}
```

## Auto Moderation

```javascript
// Image

let res = await services.automod.images("YOUR API TOKEN", ["image", "urls", "to", "check"], optional_percent);
// Default percent is: 89
if(res.status !== true) return console.log(res);
// Returns: 
{
    status: true, 
    images: [], // Returns any images that was filtered as "adult"
    full: [
    // Example object
    {
        percent: 90, 
        url: "URL", 
        raw: {} // Raw response from the moderatecontent API 
    }
    ]
}
// -----------------------------------------------------------------
// Words
let res = await services.automod.words("Message String", ["The", "filter", "word", "list"], optional_emojisList);
// optional_emojiList: Array of the emojis you want to see if they are included in the message string.
if(res.status !== true) return console.log(res);
// Returns: 
{
    status: true,
    filtered: ["Array of the filtered words in the message string"]
}

//------------------------------------------------------------------
// Links
let res = await services.automod.links("message string", options);
// options: {regexp: true, prefix: "."};
if(res.status !== true) return console.log(res);
// Returns:
{
    status: true,
    links: true,
    message: "The message string"
}
```
