Skip to content

Commit bc301b2

Browse files
feat: update to v3 of the Kiai API (#11)
1 parent 6434af9 commit bc301b2

44 files changed

Lines changed: 1888 additions & 950 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/witty-brooms-refuse.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"kiai.js": major
3+
---
4+
5+
feat: update to v3 of the Kiai API
6+
- There shouldn't be any major breaking changes to any routes, with the exception of the rewards routes. Rewards have very different response payloads now and will need adjusting.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
- uses: ./.github/actions/setup
3838

3939
- name: Run Biome
40-
run: bunx @biomejs/biome ci .
40+
run: bunx @biomejs/biome ci .

‎.github/workflows/docs.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'src/**'
9-
- 'typedoc.json'
10-
- 'typedoc-formatter.mjs'
8+
- "src/**"
9+
- "typedoc.json"
10+
- "typedoc-formatter.mjs"
1111
workflow_dispatch:
1212

1313
jobs:
@@ -44,4 +44,4 @@ jobs:
4444
git config user.email "buapestudios@gmail.com"
4545
git add .
4646
git commit -m "docs: update kiai.js documentation from kiai.js@${{ github.sha }}"
47-
git push
47+
git push

‎.github/workflows/release.yml‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
push:
5+
branches:
6+
- main
77

88
concurrency: ${{ github.workflow }}-${{ github.ref }}
99

1010
jobs:
11-
release:
12-
name: Release
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Check out code
16-
uses: actions/checkout@v4
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
1717

18-
- name: Setup
19-
uses: ./.github/actions/setup
18+
- name: Setup
19+
uses: ./.github/actions/setup
2020

21-
- name: Process Changesets
22-
id: changesets
23-
uses: changesets/action@v1
24-
with:
25-
publish: bun run publish
26-
title: "Pending Releases"
27-
commit: "chore: update changelog and release"
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.BUAPEBOT_SECRET }}
30-
NPM_TOKEN: ${{ secrets.NPM_SECRET }}
21+
- name: Process Changesets
22+
id: changesets
23+
uses: changesets/action@v1
24+
with:
25+
publish: bun run publish
26+
title: "Pending Releases"
27+
commit: "chore: update changelog and release"
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.BUAPEBOT_SECRET }}
30+
NPM_TOKEN: ${{ secrets.NPM_SECRET }}

‎.github/workflows/snapshot.yml‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
name: Publish Snapshots
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
paths:
9-
- 'src/**'
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- "src/**"
1010

1111
concurrency: ${{ github.workflow }}-${{ github.ref }}
1212

1313
jobs:
14-
release:
15-
name: Release
16-
runs-on: ubuntu-latest
17-
needs: []
18-
permissions:
19-
contents: read
20-
steps:
21-
- name: Check out code
22-
uses: actions/checkout@v4
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v4
2322

24-
- name: Setup
25-
uses: ./.github/actions/setup
23+
- name: Setup
24+
uses: ./.github/actions/setup
2625

27-
- name: Publish Beta
28-
run: bun run publish:snapshot
29-
env:
30-
NPM_TOKEN: ${{ secrets.NPM_SECRET }}
26+
- name: Publish Beta
27+
run: bun run publish:snapshot
28+
env:
29+
NPM_TOKEN: ${{ secrets.NPM_SECRET }}

‎.gitignore‎

Lines changed: 4 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,5 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
1+
dist
2+
docs
43
node_modules
5-
.pnp
6-
.pnp.js
7-
8-
# testing
9-
coverage
10-
11-
# next.js
12-
.next/
13-
out/
14-
build
15-
16-
# misc
17-
.DS_Store
18-
*.pem
19-
20-
# debug
21-
npm-debug.log*
22-
yarn-debug.log*
23-
yarn-error.log*
24-
.pnpm-debug.log*
25-
26-
# local env files
27-
.env.local
28-
.env.development.local
29-
.env.test.local
30-
.env.production.local
31-
32-
# turbo
33-
.turbo
34-
35-
# env
36-
.env*
37-
!packages/database/.env
38-
39-
# typescript
40-
**/dist
41-
42-
# generated docs
43-
**/docs
44-
45-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
46-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
47-
48-
# User-specific stuff
49-
.idea/**/workspace.xml
50-
.idea/**/tasks.xml
51-
.idea/**/usage.statistics.xml
52-
.idea/**/dictionaries
53-
.idea/**/shelf
54-
55-
# AWS User-specific
56-
.idea/**/aws.xml
57-
58-
# Generated files
59-
.idea/**/contentModel.xml
60-
61-
# Sensitive or high-churn files
62-
.idea/**/dataSources/
63-
.idea/**/dataSources.ids
64-
.idea/**/dataSources.local.xml
65-
.idea/**/sqlDataSources.xml
66-
.idea/**/dynamic.xml
67-
.idea/**/uiDesigner.xml
68-
.idea/**/dbnavigator.xml
69-
70-
# Gradle
71-
.idea/**/gradle.xml
72-
.idea/**/libraries
73-
74-
# Gradle and Maven with auto-import
75-
# When using Gradle or Maven with auto-import, you should exclude module files,
76-
# since they will be recreated, and may cause churn. Uncomment if using
77-
# auto-import.
78-
# .idea/artifacts
79-
# .idea/compiler.xml
80-
# .idea/jarRepositories.xml
81-
# .idea/modules.xml
82-
# .idea/*.iml
83-
# .idea/modules
84-
# *.iml
85-
# *.ipr
86-
87-
# CMake
88-
cmake-build-*/
89-
90-
# Mongo Explorer plugin
91-
.idea/**/mongoSettings.xml
92-
93-
# File-based project format
94-
*.iws
95-
96-
# mpeltonen/sbt-idea plugin
97-
.idea_modules/
98-
99-
# JIRA plugin
100-
atlassian-ide-plugin.xml
101-
102-
# Cursive Clojure plugin
103-
.idea/replstate.xml
104-
105-
# SonarLint plugin
106-
.idea/sonarlint/
107-
108-
# Crashlytics plugin (for Android Studio and IntelliJ)
109-
com_crashlytics_export_strings.xml
110-
crashlytics.properties
111-
crashlytics-build.properties
112-
fabric.properties
113-
114-
# Editor-based Rest Client
115-
.idea/httpRequests
116-
117-
# Android studio 3.1+ serialized cache file
118-
.idea/caches/build_file_checksums.ser
4+
openapi-*.json
5+
.env

‎README.md‎

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ bun add kiai.js
2929
```typescript
3030
import { KiaiClient } from 'kiai.js';
3131

32-
// Initialize the client
33-
const kiai = new KiaiClient({
34-
apiKey: 'your-api-key'
35-
});
32+
const kiai = new KiaiClient('your-api-key'); // API v3 by default
3633

37-
// Example: Get user level
38-
const userLevel = await kiai.leveling.getUserLevel('guild_id', 'user_id');
39-
console.log(`User level: ${userLevel}`);
34+
const member = await kiai.leveling.getMember('guild_id', 'user_id');
35+
console.log(`User XP: ${member?.xp ?? 0}`);
4036
```
4137

4238
## Documentation
@@ -45,42 +41,47 @@ For detailed documentation, visit our [documentation site](https://kiai.app/docs
4541

4642
## Handlers
4743

48-
kiai.js provides several handlers to interact with different aspects of the API. These handlers mirror the API categories on our [API docs](https://api.kiai.app/v2/docs).
44+
kiai.js provides several handlers to interact with different aspects of the API. These handlers mirror the API categories on our [API v3 docs](https://www.kiai.app/api/v3/docs/json).
4945

50-
- `Leveling` - Manage user levels and XP
51-
- `Rewards` - Configure and manage level rewards
52-
- `LeaderboardRoles` - Handle leaderboard-based role assignments
53-
- `Settings` - Manage guild settings
54-
- `Multipliers` - Configure XP multipliers
55-
- `Denylist` - Manage denied channels and roles
56-
- `Misc` - Miscellaneous API interactions
46+
- `Leveling` - Levels, XP, prestige, leaderboards, and server stats
47+
- `Rewards` - Declarative rewards, capabilities, and reconciliation jobs
48+
- `LeaderboardRoles` and `AutoLeaderboards` - Leaderboard role and message management
49+
- `LevelUpMessages` - Read configured level-up messages
50+
- `Settings` - Read guild settings
51+
- `Multipliers` and `Cooldowns` - XP multipliers and cooldown overrides
52+
- `Denylist` - Manage denied channels, roles, and users
53+
- `Misc` - Application, guild status, export, feature preview, and XP drop endpoints
5754

5855
## Examples
5956

6057
### Working with Levels
6158

6259
```typescript
63-
// Get user XP
64-
const xp = await kiai.leveling.getUserXp('guild_id', 'user_id');
65-
66-
// Add XP to user
60+
// Add XP to a user
6761
await kiai.leveling.addXp('guild_id', 'user_id', 100);
6862

69-
// Get guild leaderboard
70-
const leaderboard = await kiai.leveling.getLeaderboard('guild_id');
63+
// Query a leaderboard by category and period
64+
const leaderboard = await kiai.leveling.getLeaderboard('guild_id', {
65+
type: 'xp',
66+
time: 'WEEK',
67+
start: 1,
68+
end: 10
69+
});
7170
```
7271

7372
### Managing Rewards
7473

7574
```typescript
76-
// Add a level reward
77-
await kiai.rewards.createReward('guild_id', {
78-
level: 10,
79-
roleId: 'role_id'
75+
// Create a role reward
76+
const reward = await kiai.rewards.createReward('guild_id', {
77+
type: 'ROLE',
78+
threshold: { level: 10, prestige: null },
79+
eligibility: { requiredRoleId: null },
80+
config: { roleId: 'role_id', operation: 'ADD', durationMs: null }
8081
});
8182

82-
// Get all rewards
83-
const rewards = await kiai.rewards.getRewards('guild_id');
83+
// List rewards (or filter by type, level, and prestige)
84+
const rewards = await kiai.rewards.getRewards('guild_id', { type: 'ROLE' });
8485
```
8586

8687
## License

‎package.json‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,10 @@
4444
"typedoc-plugin-markdown": "4.4.2",
4545
"typedoc-plugin-mdn-links": "4.0.12"
4646
},
47-
"files": [
48-
"dist",
49-
"LICENSE"
50-
],
47+
"files": ["dist", "LICENSE"],
5148
"engines": {
5249
"node": ">=20.18.1"
5350
},
54-
"keywords": [
55-
"kiai",
56-
"api",
57-
"leveling",
58-
"discord",
59-
"levels",
60-
"buape"
61-
],
62-
"trustedDependencies": [
63-
"@biomejs/biome"
64-
]
51+
"keywords": ["kiai", "api", "leveling", "discord", "levels", "buape"],
52+
"trustedDependencies": ["@biomejs/biome"]
6553
}

0 commit comments

Comments
 (0)