Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/onlyf0ur/spiget-deno

Simple Spiget API wrapper for Deno
https://github.com/onlyf0ur/spiget-deno

deno deno-module denoland spiget spiget-api spigotmc wrapper

Last synced: about 1 month ago
JSON representation

Simple Spiget API wrapper for Deno

Awesome Lists containing this project

README

        

# Spiget-Deno
Simple Spiget API wrapper for Deno

### Example
```ts
import { Spiget } from 'https://deno.land/x/[email protected]/mod.ts';

const example_user_id = 12345; // Change this

const spiget = new Spiget();
const author = await spiget.getAuthor(example_user_id);

if (author == null) {
console.log('Couldn\'t find an author with that id.');
} else {
console.log(`Username: ${author.username}`);
// etc.

const resources = await author.getResources();
if (!resources.length) {
console.log('This user doesn\'t have any resources.');
} else {
const resource = resources[0];

console.log(`Resource Name: ${resource.name}`);
console.log(`Tag: ${resource.tag}`);
console.log(`Likes: ${resource.likes}`);
console.log(`Downloads: ${resource.downloads}`);
// etc.

const reviews = await resource.getReviews();
if (!reviews.length) {
console.log('This resource doesn\'t have any reviews.');
} else {
const review = reviews[0];

console.log(`Rating: ${resource.downloads}/5`);
console.log(`Date: ${review.date.toLocaleString()}`);
// etc.
}
}
}
```