允许以仅用于调用方法的模式进行部分对象的实例化

This commit is contained in:
CrescentLeaf
2025-12-07 00:29:17 +08:00
parent 8817663371
commit f4a9cc9cda
2 changed files with 11 additions and 1 deletions

View File

@@ -19,6 +19,11 @@ export default class Chat extends BaseClientObject {
* 实例化方法
* ================================================
*/
static getForInvokeOnlyById(client: LingChairClient, id: string) {
return new Chat(client, {
id
} as ChatBean)
}
static async getById(client: LingChairClient, id: string) {
try {
return await this.getByIdOrThrow(client, id)

View File

@@ -14,10 +14,15 @@ export default class User extends BaseClientObject {
* 实例化方法
* ================================================
*/
static getForInvokeOnlyById(client: LingChairClient, id: string) {
return new User(client, {
id
} as UserBean)
}
static async getById(client: LingChairClient, id: string) {
try {
return await this.getByIdOrThrow(client, id)
} catch(_) {
} catch (_) {
return null
}
}