Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit fbca8c7

Browse files
committed
2.0.0
1 parent dbd081e commit fbca8c7

File tree

8 files changed

+517
-301
lines changed

8 files changed

+517
-301
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
### April
66

7+
#### 2.0.0
8+
- Source Code Refactoring
9+
- Implemented Callbacks Endpoint
10+
- Updated README
11+
- Updated style
12+
- Updated `TypeScript Specials` article
13+
- Updated examples
14+
715
#### 1.1.0
816
- Source Code Refactoring
917
- Dependencies Switch

README.md

Lines changed: 83 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
2+
<div align="center">
3+
14
# BPAPI
25

36
[![NPM: Version](https://img.shields.io/npm/v/@nightnutsky/bpapi?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@nightnutsky/bpapi)
47
[![GitHub: Stars](https://img.shields.io/github/stars/NightNutSky/bpapi?logo=github&style=for-the-badge)](https://github.com/NightNutSky/bpapi/stargazers)
58
[![GitHub: Source Code](https://img.shields.io/badge/Source%20Code-GitHub-green?logo=github&style=for-the-badge)](https://github.com/NightNutSky/bpapi)
69

7-
BPAPI allows you to retrieve and work with information from [BDFD](https://botdesignerdiscord.com) [Public API](https://nilpointer-software.github.io/bdfd-wiki/nightly/resources/api.html) more easier.
10+
BPAPI allows you to work with [BDFD](https://botdesignerdiscord.com) [Public API](https://nilpointer-software.github.io/bdfd-wiki/nightly/resources/api.html) more easier and pretty!
11+
12+
</div>
13+
814

915
# Install
1016
```sh
@@ -22,7 +28,7 @@ To get started, you should import/require BPAPI:
2228
```js
2329
const { functionInfo } = require("@nightnutsky/bpapi");
2430
```
25-
- TypeScript
31+
- TypeScript (Recommended to use)
2632
- Import all functions:
2733
```ts
2834
import * as bpapi from "@nightnutsky/bpapi";
@@ -31,191 +37,96 @@ To get started, you should import/require BPAPI:
3137
```ts
3238
import { functionInfo } from "@nightnutsky/bpapi";
3339
```
34-
## Code Examples
35-
36-
### functionInfo()
37-
```js
38-
/**
39-
*
40-
* @param functionTag A tag (i.e `$addButton[]`, `$nomention`) of the function. Supports non-completed tags (i.e `$addBu` will be represented as `$addButton[]`)
41-
* @returns A promise containing information about the specified function. If could't find the function, `undefined` is returned.
42-
*/
40+
## Some Code Examples
41+
42+
### BDFD Functions
43+
44+
```ts
4345
functionInfo('$replaceT').then(info => {
4446
if (info) {
45-
const tag = info.tag,
46-
description = info.description,
47-
intents = info.intents;
48-
49-
console.log(`${tag}:\nDescription: ${description}\nIntents: ${intents}`);
47+
const {
48+
description,
49+
intents,
50+
tag
51+
} = info;
52+
someFunction(RESPONSE.Success, `The function with the \`${tag}\` tag has the following description: \`${description}\` and requires ${intents} intents.`);
5053
} else {
51-
console.log('Could not find the specified function!')
54+
someFunction(RESPONSE.Fail, 'Could not find the function!');
5255
}
5356
});
5457
```
5558

56-
### functionList()
57-
```js
58-
/**
59-
*
60-
* @returns A promise containing an array of functions with their information
61-
*/
62-
functionList().then(list => {
63-
console.log('Functions That Require Intents:');
64-
for (const functionInfo of list) {
65-
if (functionInfo.intents != 'None') {
66-
const tag = functionInfo.tag,
67-
intents = functionInfo.intents;
68-
69-
console.log(`${tag}: ${intents} Intent`);
70-
}
71-
}
72-
});
73-
```
59+
### BDFD Callbacks
7460

75-
### functionTagList()
76-
```js
77-
/**
78-
*
79-
* @returns A promise containing an array of function tags
80-
*/
81-
functionTagList().then(tagList => {
82-
console.log('Functions That Start With "n":');
83-
for (const functionTag of tagList) {
84-
if (functionTag.includes('$n')) {
85-
console.log(functionTag);
86-
}
61+
```ts
62+
callbackInfo('$onJ').then(info => {
63+
if (info) {
64+
const {
65+
name
66+
} = info;
67+
const premium = info.premium ? 'requires' : "doesn't require";
68+
someFunction(RESPONSE.Success, `The callback with the \`${name}\` name ${premium} premium hosting time.`);
69+
} else {
70+
someFunction(RESPONSE.Fail, 'Could not find the callback!');
8771
}
8872
});
8973
```
74+
9075
## TypeScript Specials
9176
If you ever worked with TypeScript, then you know that you can (and sometimes must) assign types for your consts, etc.
9277

93-
If you want to work with plain BDFD Public API, for example, do request to the `api/function_list` endpoint yourself, BPAPI can help you using one of its type - `PublicAPIResponse`.\
94-
Import this type and assign it to the request's response.
95-
96-
> Original BDFD Public API's response is a bit different and contains unused or deprecated (and now unused) properties. Unlike BDFD Public API, BPAPI only shows actual and a bit modified properties for your comfort.
97-
98-
| Showcase |
99-
| :------: |
100-
| ![Showcase](https://user-images.githubusercontent.com/70456337/230720560-c425f057-d09c-4e91-8f68-8f9312d07455.png) |
101-
| ![Showcase](https://user-images.githubusercontent.com/70456337/230720600-f89d6185-ae72-47c8-ab37-cee6f1d6a9e5.png) |
102-
103-
104-
## Raw Returns
105-
106-
<details><summary>Expand</summary>
107-
108-
### functionInfo()
109-
```json
110-
{
111-
"tag": "$replaceText[Text;Sample;New;(Amount)]",
112-
"description": "Replaces 'sample' from 'text' to 'new' 'how many' times. Set 'how many' to -1 to replace everything",
113-
"arguments": [
114-
{
115-
"name": "Text",
116-
"type": "String",
117-
"required": true,
118-
"empty": true
119-
},
120-
{
121-
"name": "Sample",
122-
"type": "String",
123-
"required": true,
124-
"empty": true
125-
},
126-
{
127-
"name": "New",
128-
"type": "String",
129-
"required": true,
130-
"empty": true
131-
},
132-
{
133-
"name": "Amount",
134-
"type": "Integer",
135-
"required": false
136-
}
137-
],
138-
"intents": "None",
139-
"premium": false
140-
}
141-
```
78+
### Types For BDFD Public API
79+
If you want to work with plain BDFD Public API, for example, do request to endpoints yourself, BPAPI can help you using types.
14280

143-
### functionList()
144-
```json
145-
[
146-
...,
147-
{
148-
"tag": "$userJoinedDiscord[User ID;(Format)]",
149-
"description": "Returns date when given user joined discord. You can also give your own date format",
150-
"arguments": [
151-
{
152-
"name": "User ID",
153-
"type": "Snowflake",
154-
"required": true
155-
},
156-
{
157-
"name": "Format",
158-
"description": "Uses GoLang date format",
159-
"type": "String",
160-
"required": false
161-
}
162-
],
163-
"intents": "None",
164-
"premium": false
165-
},
166-
{
167-
"tag": "$userJoined[User ID;(Format)]",
168-
"description": "Returns date when given user joined the guild. You can also give your own date format",
169-
"arguments": [
170-
{
171-
"name": "User ID",
172-
"type": "Snowflake",
173-
"required": true
174-
},
175-
{
176-
"name": "Format",
177-
"description": "Uses GoLang date format",
178-
"type": "String",
179-
"required": false
180-
}
181-
],
182-
"intents": "Members",
183-
"premium": false
184-
},
185-
...
186-
]
187-
```
81+
Currently, BPAPI has types for request's responses - `FunctionsResponse` and `CallbacksResponse`.
82+
83+
#### `FunctionsResponse`
84+
85+
![FunctionsResponse](https://user-images.githubusercontent.com/70456337/231560564-e590a2e4-5b40-4ee3-a39d-f41362c98e1f.png)
86+
87+
#### `CallbacksResponse`
18888

189-
### functionTagList()
190-
```json
191-
[
192-
...,
193-
"$userInfo[]",
194-
"$userJoinedDiscord[]",
195-
"$userJoined[]",
196-
"$userLeaderboard[]",
197-
"$userPerms[]",
198-
"$userReacted[]",
199-
"$userRoles[]",
200-
"$userServerAvatar[]",
201-
"$username",
202-
"$username[]",
203-
"$varExistError[]",
204-
"$varExists[]",
205-
"$var[]",
206-
"$variablesCount[]",
207-
"$webhookAvatarURL[]",
208-
"$webhookColor[]",
209-
"$webhookContent[]",
210-
"$webhookCreate[]",
211-
"$webhookDelete[]",
212-
"$webhookDescription[]",
213-
"$webhookFooter[]",
214-
"$webhookSend[]",
215-
"$webhookTitle[]",
216-
"$webhookUsername[]",
217-
"$year"
218-
]
89+
![CallbacksResponse](https://user-images.githubusercontent.com/70456337/231560588-3c6fd4c7-e0da-4818-89c1-d99b5b8d4a2b.png)
90+
91+
### Types For Enums
92+
93+
As you should know, some BDScript functions have arguments and these arguments have enums.\
94+
BPAPI will help to work with them as well. While retrieving the argument's enums, you can assign one of the [types](#types) to it.
95+
96+
```ts
97+
functionInfo('$addB').then(info => {
98+
if (info && info.args) {
99+
for (const arg of info.args) {
100+
if (arg.enumData) {
101+
const enums: AddButtonEnums = arg.enumData;
102+
// ^ ["primary", "secondary", "success", "danger", "link"]
103+
}
104+
}
105+
}
106+
});
219107
```
220108

221-
</details>
109+
#### Types
110+
| Name | Example Function |
111+
| :------------------------: | :-------------------------: |
112+
| AddButtonEnums | `$addButton[]` |
113+
| ModalEnums | `$addTextInput[]` |
114+
| CategoryEnums | `$categoryChannels[]` |
115+
| ChannelEnums | `$createChannel[]` |
116+
| EditButtonEnums | `$editButton[]` |
117+
| ErrorEnums | `$error[]` |
118+
| CooldownEnums | `$getCooldown[]` |
119+
| EmbedDataEnums | `$getEmbedData[]` |
120+
| InviteInfoEnums | `$getInviteInfo[]` |
121+
| LeaderboardTypeEnums | `$getLeaderboardValue[]`* |
122+
| SortEnums | `$getLeaderboardValue[]`** |
123+
| LeaderboardReturnTypeEnums | `$getLeaderboardValue[]`*** |
124+
| MessageDataEnums | `$getMessage[]` |
125+
| TimestampEnums | `$getTimestamp[]` |
126+
| MembersCountEnums | `$membersCount[]` |
127+
| UrlEnums | `$url[]` |
128+
| VariablesCountEnums | `$variablesCount[]` |
129+
130+
> \* - The `Variable type` argument of the function.\
131+
> \*\* - The `Sort` argument of the function.\
132+
> \*\*\* - The `Return type` argument of the function.

package-lock.json

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nightnutsky/bpapi",
3-
"version": "1.1.0",
4-
"description": "BPAPI allows you to retrieve and work with information from BDFD Public API more easier",
3+
"version": "2.0.0",
4+
"description": "BPAPI allows you to work with BDFD Public API more easier and pretty!",
55
"author": "NightNutSky",
66
"main": "dist/index.js",
77
"types": "types/types.d.ts",

0 commit comments

Comments
 (0)