| 372 | filter: new Api.ChannelParticipantsAdmins(), |
| 373 | showTotal: false, |
| 374 | }); |
| 375 | |
| 376 | allAdmins = users.filter( |
| 377 | (user): user is Api.User => user instanceof Api.User, |
| 378 | ); |
| 379 | } else { |
| 380 | const users = await client.getParticipants(target.entity, { |
| 381 | showTotal: false, |
| 382 | }); |
| 383 | |
| 384 | allAdmins = users.filter((user): user is Api.User => { |
| 385 | if (!(user instanceof Api.User)) return false; |
| 386 | const participant = (user as any).participant; |
| 387 | return ( |
| 388 | participant instanceof Api.ChatParticipantAdmin || |
| 389 | participant instanceof Api.ChatParticipantCreator |
| 390 | ); |
| 391 | }); |
| 392 | } |
| 393 | |
| 394 | const visibleAdmins = allAdmins.filter((user) => !user.bot); |
| 395 | |
| 396 | return { |
| 397 | allAdmins, |
| 398 | visibleAdmins, |
| 399 | totalCount: allAdmins.length, |
| 400 | botCount: allAdmins.filter((user) => !!user.bot).length, |
| 401 | nonBotCount: visibleAdmins.length, |
| 402 | }; |
| 403 | } |
| 404 | |
| 405 | async function getSeatLockDb() { |
| 406 | if (!dbPromise) { |
| 407 | dbPromise = JSONFilePreset<SeatLockDB>(DB_PATH, { lockedSeats: {} }); |
| 408 | } |
| 409 | return await dbPromise; |
| 410 | } |
| 411 | |
| 412 | async function getAvgCacheDb() { |
| 413 | if (!avgCacheDbPromise) { |
| 414 | avgCacheDbPromise = JSONFilePreset<AvgCacheDB>(AVG_CACHE_PATH, { |
| 415 | values: {}, |
| 416 | }); |
| 417 | } |
| 418 | return await avgCacheDbPromise; |