import type { SocketServer } from '../types/socket.ts' export async function fetchSockets(io: SocketServer, excludeId?: string, channelId?: string) { let sockets: Awaited> if (channelId) { sockets = await io.in(channelId).fetchSockets() } else { sockets = await io.fetchSockets() } return sockets.filter((socket) => { return !(excludeId && socket.id === excludeId) }) }