Skip to content

Commit

Permalink
feat(kook): support jsx typings
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 1, 2024
1 parent ff130d7 commit 7e516e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 25 additions & 0 deletions adapters/kook/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ import { Context, h, MessageEncoder, Schema } from '@satorijs/core'
import { KookBot } from './bot'
import * as Kook from './types'

declare global {
namespace JSX {
interface IntrinsicElements {
'kook:image-group': {}
'kook:action-group': {}
'kook:header': {
type: 'h1' | 'h2' | 'h3'
content: string
}
'kook:countdown': {
startTime: number
endTime: number
mode: 'day' | 'hour'
}
'kook:invite': {
code: string
}
'kook:card': {
theme?: Kook.Card.Theme
size?: Kook.Card.Size
}
}
}
}

export function isDirectChannel(channelId: string) {
return channelId.length > 30
}
Expand Down
4 changes: 3 additions & 1 deletion adapters/kook/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ export interface MessageReturn {
export interface Card {
type: 'card'
theme?: Card.Theme
size?: 'lg' | 'sm'
size?: Card.Size
modules: Card.Module[]
}

export namespace Card {
export const Theme = ['primary', 'secondary', 'warning', 'danger', 'info', 'none', 'success'] as const
export type Theme = typeof Theme[number]
export const Size = ['lg', 'sm'] as const
export type Size = typeof Size[number]
export type Module = Section | Container | ImageGroup | ActionGroup | Header | Divider | Invite | File | Countdown | Context

export interface Text {
Expand Down

0 comments on commit 7e516e7

Please sign in to comment.