Skip to content

Commit e0adc65

Browse files
committed
feat: add misc api for public key
1 parent 0f9d0e2 commit e0adc65

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

example/get-public-key.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { env } from 'bun'
2+
import { Kient } from 'kient'
3+
4+
const kient = new Kient()
5+
kient.setAuthToken(env.KICK_TOKEN as string)
6+
7+
const publicKey = await kient.api.misc.getPublicKey()
8+
console.log(publicKey)

src/api/misc/get-public-key.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Kient } from 'kient'
2+
import type { APIResponse } from '../../util/api-response'
3+
import type { PublicKey } from '../../structures/public-key'
4+
5+
export async function getPublicKey(kient: Kient) {
6+
const response = await kient._apiClient.fetch<APIResponse<PublicKey>>('/public-key')
7+
8+
return response.data.public_key
9+
}

src/api/misc/index.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { APIBase } from '../api-base'
2+
import { getPublicKey } from './get-public-key'
3+
4+
/**
5+
* Description placeholder
6+
*
7+
* @group APIs
8+
*/
9+
export class MiscAPI extends APIBase {
10+
/**
11+
* Returns an array of users by an array of IDs
12+
*
13+
* @param ids Accepts an array of user IDs that will be queried for
14+
*/
15+
getPublicKey() {
16+
return getPublicKey(this.kient)
17+
}
18+
}

src/kient.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CategoryAPI } from './api/category'
77
import { UserAPI } from './api/user'
88
import { ChannelAPI } from './api/channel'
99
import { ChatAPI } from './api/chat'
10+
import { MiscAPI } from './api/misc'
1011

1112
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T
1213

@@ -56,6 +57,7 @@ export class Kient extends EventEmitter<KientEventEmitters> {
5657
}
5758

5859
api = {
60+
misc: new MiscAPI(this),
5961
category: new CategoryAPI(this),
6062
user: new UserAPI(this),
6163
channel: new ChannelAPI(this),

src/structures/public-key.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface PublicKey {
2+
public_key: string
3+
}

0 commit comments

Comments
 (0)