Skip to content

Commit

Permalink
3.0.8 (#48)
Browse files Browse the repository at this point in the history
* Docs changes

* Whoops

* Update README.md

* Add auto-respond with 200

* Remove span from header
  • Loading branch information
jpbberry committed Mar 2, 2021
1 parent 5bd55a1 commit 2bb947e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ An official module for interacting with the Top.<span>gg API

# Introduction

The base client is Topgg.Api, and it takes your top.<span>gg token and provides you with plenty of methods to interact with the API.
The base client is Topgg.Api, and it takes your Top.<span>gg token and provides you with plenty of methods to interact with the API.

Your Top.<span>gg token can be found [here](https://top.gg/api/docs#mybots)
Your Top.<span>gg token can be found at `top.gg/bot/(BOT_ID)/webhooks` and copying the token.

You can also setup webhooks via Topgg.Webhook, look down below at the examples for how to do so!

# Links

[Documentation](https://topggjs.rtfd.io)

[API Reference](https://top.gg/api/docs) | [GitHub](https://github.com/top-gg/node-sdk) | [NPM](https://npmjs.com/package/@top-gg/sdk) | [Discord Server](https://discord.gg/EYHTgJX)
[API Reference](https://docs.top.gg) | [GitHub](https://github.com/top-gg/node-sdk) | [NPM](https://npmjs.com/package/@top-gg/sdk) | [Discord Server](https://discord.gg/EYHTgJX)

# Auto-Posting

Expand Down Expand Up @@ -65,4 +65,4 @@ app.post('/dblwebhook', webhook.middleware(), (req, res) => {
app.listen(3000) // your port
```
With this example, your webhook dashboard should look like this:
![](https://i.imgur.com/wFlp4Hg.png)
![](https://i.imgur.com/wFlp4Hg.png)
7 changes: 4 additions & 3 deletions docs/Api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Top.gg API Client for Posting stats or Fetching data

**Kind**: global class
**Link**: https://top.gg/api/docs
**Link**: https://topggjs.rtfd.io <- Library docs
**Link**: https://docs.top.gg <- API Reference

* [Api](#Api)
* [new Api(token, options)](#new_Api_new)
Expand Down Expand Up @@ -201,10 +202,10 @@ await client.getVotes()
<a name="Api+hasVoted"></a>

### api.hasVoted(id) ⇒ <code>Boolean</code>
Get whether or not a user has voted
Get whether or not a user has voted in the last 12 hours

**Kind**: instance method of [<code>Api</code>](#Api)
**Returns**: <code>Boolean</code> - Whether the user has voted
**Returns**: <code>Boolean</code> - Whether the user has voted in the last 12 hours

| Param | Type | Description |
| --- | --- | --- |
Expand Down
6 changes: 6 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Change Log

## 3.0.8
- Change docs URL
- Fix typos in a few method docs
- Specified that .hasVoted() is last 12 hours
- Auto-respond with status 200 as per docs

## 3.0.7
- Add new BotInfo.bannerUrl to typings

Expand Down
2 changes: 1 addition & 1 deletion docs/master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

NPM Package <https://npmjs.com/@top-gg/sdk>
GitHub <https://github.com/top-gg/node-sdk>
API Reference <https://top.gg/api/docs>
API Reference <https://docs.top.gg>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@top-gg/sdk",
"version": "3.0.7",
"version": "3.0.8",
"description": "Official Top.gg Node SDK",
"main": "./dist/index.js",
"scripts": {
Expand All @@ -18,7 +18,7 @@
"bugs": {
"url": "https://github.com/top-gg/node-sdk/issues"
},
"homepage": "https://github.com/top-gg/node-sdk#readme",
"homepage": "https://topggjs.rtfd.io",
"devDependencies": {
"@types/node-fetch": "^2.5.7",
"@types/node": "^14.14.10",
Expand Down
14 changes: 8 additions & 6 deletions src/structs/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ interface APIOptions {
/**
* Top.gg Token
*/
token: any
token?: string
}

/**
* Top.gg API Client for Posting stats or Fetching data
* @link https://top.gg/api/docs
* @example
* const Topgg = require(`@top-gg/sdk`)
*
* const api = new Topgg.Api('Your top.gg token')
* @link https://topggjs.rtfd.io <- Library docs
* @link https://docs.top.gg <- API Reference
*/
export class Api extends EventEmitter {
private options: APIOptions
Expand All @@ -25,10 +26,11 @@ export class Api extends EventEmitter {
* @param {string} token Token or options
* @param {object?} options API Options
*/
constructor (token: string, options?: APIOptions) {
constructor (token: string, options: APIOptions = {}) {
super()
this.options = {
token: token
token: token,
...options
}
}

Expand Down Expand Up @@ -225,9 +227,9 @@ export class Api extends EventEmitter {
}

/**
* Get whether or not a user has voted
* Get whether or not a user has voted in the last 12 hours
* @param {Snowflake} id User ID
* @returns {Boolean} Whether the user has voted
* @returns {Boolean} Whether the user has voted in the last 12 hours
* @example
* await client.hasVoted('205680187394752512')
* // => true/false
Expand Down
1 change: 1 addition & 0 deletions src/structs/Webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class Webhook {
return async (req, res, next) => {
const response = await this._parseRequest(req, res)
if (!response) return
res.sendStatus(200)
req.vote = response
next()
}
Expand Down

0 comments on commit 2bb947e

Please sign in to comment.