mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-25 09:37:35 +00:00
feat(shell): add chronocat.guild.member.title.set
api def
This commit is contained in:
parent
0791221f36
commit
b97bb65151
30
packages/shell/src/satori/routes/guild/member/title/set.ts
Normal file
30
packages/shell/src/satori/routes/guild/member/title/set.ts
Normal 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)
|
||||
}
|
@ -12,6 +12,7 @@ import { guildMemberGet } from './guild/member/get'
|
||||
import { guildMemberKick } from './guild/member/kick'
|
||||
import { guildMemberList } from './guild/member/list'
|
||||
import { guildMemberMute } from './guild/member/mute'
|
||||
import { guildMemberTitleSet } from './guild/member/title/set'
|
||||
import { guildRemove } from './guild/remove'
|
||||
import { loginGet } from './login/get'
|
||||
import { messageCreate } from './message/create'
|
||||
@ -43,6 +44,7 @@ const routesIntl = {
|
||||
'guild.member.mute': guildMemberMute,
|
||||
'guild.member.role.set': notImplemented,
|
||||
'guild.member.role.unset': notImplemented,
|
||||
'chronocat.guild.member.title.set': guildMemberTitleSet,
|
||||
'guild.role.list': notImplemented,
|
||||
'guild.role.create': notImplemented,
|
||||
'guild.role.update': notImplemented,
|
||||
|
@ -153,3 +153,15 @@ export interface GuildMemberKickPayload {
|
||||
user_id: string
|
||||
permanent?: boolean
|
||||
}
|
||||
|
||||
export interface GuildMemberTitleSetPayload {
|
||||
guild_id: string
|
||||
user_id: string
|
||||
|
||||
/**
|
||||
* @title 专属头衔
|
||||
*
|
||||
* @description 要设置的专属头衔。
|
||||
*/
|
||||
title?: string
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ export type {
|
||||
GuildMemberListPayload,
|
||||
GuildMemberListResponse,
|
||||
GuildMemberMutePayload,
|
||||
GuildMemberTitleSetPayload,
|
||||
GuildRemovePayload,
|
||||
MessageDeletePayload,
|
||||
MessageGetPayload,
|
||||
|
@ -22,6 +22,7 @@ import type {
|
||||
GuildMemberListPayload,
|
||||
GuildMemberListResponse,
|
||||
GuildMemberMutePayload,
|
||||
GuildMemberTitleSetPayload,
|
||||
GuildRemovePayload,
|
||||
Login,
|
||||
Message,
|
||||
@ -116,6 +117,11 @@ export interface SatoriMethods {
|
||||
'guild.member.kick': [[GuildMemberKickPayload], Record<string, never>]
|
||||
'guild.member.mute': [[GuildMemberMutePayload], Record<string, never>]
|
||||
|
||||
'chronocat.guild.member.title.set': [
|
||||
[GuildMemberTitleSetPayload],
|
||||
Record<string, never>,
|
||||
]
|
||||
|
||||
'message.create': [
|
||||
[MessageCreatePayload, ChronocatSatoriServerConfig],
|
||||
Message[],
|
||||
|
Loading…
Reference in New Issue
Block a user