Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Update To v1.3.2 (#5)
Browse files Browse the repository at this point in the history
Addition Of RolePlay API
  • Loading branch information
BearTS authored Feb 8, 2021
1 parent c44e492 commit b5f6711
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ tamako.animalfact('dog')
.then(res => console.log(res))
```

## image(name)
## image(type)
Returns an image link

`name` can be any of the following:
| | | | | | | | |
| - | - | - | - | - | - | - | - |
| bird | dog | cat | dog | fox | koala | panda | redpanda |
`type` can be any of the following:
| | | | | | | | | | |
| - | - | - | - | - | - | - | - | - | - |
| bird | dog | cat | dog | fox | koala | panda | redpanda | tamako | mai |

Example
```js
Expand All @@ -149,6 +149,23 @@ tamako.image('dog')
.then(res => console.log(res))
```

## roleplay(type)
Returns a gif image link

`type` can be any of the following:
| | | | | | | | | | | | | | | | |
| - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| baka | blush | cry | disgust | feed | happy | holdhands | hug | kiss | pat | poke | slap | sleep | smug | wave | wink |

Example
```js
const { TAMAKOAPI } = require('tamako-api');
const tamako = new TAMAKOAPI();

tamako.roleplay('hug')
.then(res => console.log(res))
```

# Events
`error` - Returns an error if an error is returned from the API.
Example
Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export class API {
public pokemon(name: string): Promise<Object>;
public animequote(): Promise<String>;
public animalfact(name: string): Promise<Object>;
public image(name: string): Promise<Object>;
public image(type: string): Promise<Object>;
public roleplay(type: string): Promise<Object>;
public joke(): Promise<String>;
public on(error): error
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "tamako-api",
"version": "1.2.5",
"version": "1.3.2",
"description": "A package for using the Tamako API Easily!",
"main": "index.js",
"scripts": {
"test": "echo \" no test specified\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/BearTS/tamako-api/.git"
"url": "git+https://github.com/Tamako-Tech/tamako-api/.git"
},
"keywords": [
"API",
Expand All @@ -22,9 +22,9 @@
"author": "Bear#3437 <[email protected], https://tamako.tech>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/BearTS/tamako-api/issues"
"url": "https://github.com/Tamako-Tech/tamako-api/issues"
},
"homepage": "https://github.com/BearTS/tamako-api#readme",
"homepage": "https://github.com/Tamako-Tech/tamako-api#readme",
"dependencies": {
"node-fetch": "^2.6.1"
}
Expand Down
29 changes: 25 additions & 4 deletions src/tamakoapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,33 @@ class TAMAKOAPI extends EventEmitter {


/**Returns an image
* @name animalfact
* @param {string} name Type to query
* @name image
* @param {string} type Type of query
* @returns {string} url URL link to the type of image
*/
async image(name) {
const res = await fetch(`${base}/image/${encodeURIComponent(name)}`);
async image(type) {
const res = await fetch(`${base}/image/${type}`);
if (res.status == 401) {
this.emit("error", "Check With Bear#3437");
return undefined;
}

const response = await res.json();
if (response.error) {
this.emit('error', response.error);
return undefined;
}
return response.url;
};


/**Returns an Roleplay gif link
* @name roleplay
* @param {string} type Type of query
* @returns {string} url GIF link to the type of roleplay
*/
async roleplay(type) {
const res = await fetch(`${base}/roleplay/${type}`);
if (res.status == 401) {
this.emit("error", "Check With Bear#3437");
return undefined;
Expand Down

0 comments on commit b5f6711

Please sign in to comment.