feat(shell): add chronocat.guild.member.title.set api def

This commit is contained in:
Il Harper 2024-04-13 15:29:11 +08:00
parent 0791221f36
commit b97bb65151
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
5 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import type { GuildMemberTitleSetPayload } from '../../../../types'
import type { RouteContext } from '../../../types'
export const guildMemberTitleSet = async ({
cctx,
path,
req,
res,
json,
}: RouteContext) => {
const payload = (await json()) as GuildMemberTitleSetPayload
const validateResult = await cctx.chronocat.validate(
'GuildMemberTitleSetPayload',
)(payload)
if (validateResult) {
const err = `解析 ${path} 请求时出现问题,来自 ${req.socket.remoteAddress}${validateResult}`
cctx.chronocat.l.error(err, {
code: 400,
})
res.writeHead(400)
res.end(`400 bad request\n${err}`)
return
}
return await cctx.chronocat.api['chronocat.guild.member.title.set'](payload)
}

View File

@ -12,6 +12,7 @@ import { guildMemberGet } from './guild/member/get'
import { guildMemberKick } from './guild/member/kick' import { guildMemberKick } from './guild/member/kick'
import { guildMemberList } from './guild/member/list' import { guildMemberList } from './guild/member/list'
import { guildMemberMute } from './guild/member/mute' import { guildMemberMute } from './guild/member/mute'
import { guildMemberTitleSet } from './guild/member/title/set'
import { guildRemove } from './guild/remove' import { guildRemove } from './guild/remove'
import { loginGet } from './login/get' import { loginGet } from './login/get'
import { messageCreate } from './message/create' import { messageCreate } from './message/create'
@ -43,6 +44,7 @@ const routesIntl = {
'guild.member.mute': guildMemberMute, 'guild.member.mute': guildMemberMute,
'guild.member.role.set': notImplemented, 'guild.member.role.set': notImplemented,
'guild.member.role.unset': notImplemented, 'guild.member.role.unset': notImplemented,
'chronocat.guild.member.title.set': guildMemberTitleSet,
'guild.role.list': notImplemented, 'guild.role.list': notImplemented,
'guild.role.create': notImplemented, 'guild.role.create': notImplemented,
'guild.role.update': notImplemented, 'guild.role.update': notImplemented,

View File

@ -153,3 +153,15 @@ export interface GuildMemberKickPayload {
user_id: string user_id: string
permanent?: boolean permanent?: boolean
} }
export interface GuildMemberTitleSetPayload {
guild_id: string
user_id: string
/**
* @title
*
* @description
*/
title?: string
}

View File

@ -16,6 +16,7 @@ export type {
GuildMemberListPayload, GuildMemberListPayload,
GuildMemberListResponse, GuildMemberListResponse,
GuildMemberMutePayload, GuildMemberMutePayload,
GuildMemberTitleSetPayload,
GuildRemovePayload, GuildRemovePayload,
MessageDeletePayload, MessageDeletePayload,
MessageGetPayload, MessageGetPayload,

View File

@ -22,6 +22,7 @@ import type {
GuildMemberListPayload, GuildMemberListPayload,
GuildMemberListResponse, GuildMemberListResponse,
GuildMemberMutePayload, GuildMemberMutePayload,
GuildMemberTitleSetPayload,
GuildRemovePayload, GuildRemovePayload,
Login, Login,
Message, Message,
@ -116,6 +117,11 @@ export interface SatoriMethods {
'guild.member.kick': [[GuildMemberKickPayload], Record<string, never>] 'guild.member.kick': [[GuildMemberKickPayload], Record<string, never>]
'guild.member.mute': [[GuildMemberMutePayload], Record<string, never>] 'guild.member.mute': [[GuildMemberMutePayload], Record<string, never>]
'chronocat.guild.member.title.set': [
[GuildMemberTitleSetPayload],
Record<string, never>,
]
'message.create': [ 'message.create': [
[MessageCreatePayload, ChronocatSatoriServerConfig], [MessageCreatePayload, ChronocatSatoriServerConfig],
Message[], Message[],