MCPcopy
hub / github.com/Rapptz/discord.py / __init__

Method __init__

discord/client.py:298–345  ·  view source on GitHub ↗
(self, *, intents: Intents, **options: Unpack[_ClientOptions])

Source from the content-addressed store, hash-verified

296 """
297
298 def __init__(self, *, intents: Intents, **options: Unpack[_ClientOptions]) -> None:
299 self.loop: asyncio.AbstractEventLoop = _loop
300 # self.ws is set in the connect method
301 self.ws: DiscordWebSocket = None # type: ignore
302 self._listeners: Dict[str, List[Tuple[asyncio.Future, Callable[..., bool]]]] = {}
303 self.shard_id: Optional[int] = options.get('shard_id')
304 self.shard_count: Optional[int] = options.get('shard_count')
305
306 connector: Optional[aiohttp.BaseConnector] = options.get('connector', None)
307 proxy: Optional[str] = options.pop('proxy', None)
308 proxy_auth: Optional[aiohttp.BasicAuth] = options.pop('proxy_auth', None)
309 unsync_clock: bool = options.pop('assume_unsync_clock', True)
310 http_trace: Optional[aiohttp.TraceConfig] = options.pop('http_trace', None)
311 max_ratelimit_timeout: Optional[float] = options.pop('max_ratelimit_timeout', None)
312 self.http: HTTPClient = HTTPClient(
313 self.loop,
314 connector,
315 proxy=proxy,
316 proxy_auth=proxy_auth,
317 unsync_clock=unsync_clock,
318 http_trace=http_trace,
319 max_ratelimit_timeout=max_ratelimit_timeout,
320 )
321
322 self._handlers: Dict[str, Callable[..., None]] = {
323 'ready': self._handle_ready,
324 }
325
326 self._hooks: Dict[str, Callable[..., Coroutine[Any, Any, Any]]] = {
327 'before_identify': self._call_before_identify_hook,
328 }
329
330 self._enable_debug_events: bool = options.pop('enable_debug_events', False)
331 self._connection: ConnectionState[Self] = self._get_state(intents=intents, **options)
332 self._connection.shard_count = self.shard_count
333 self._closing_task: Optional[asyncio.Task[None]] = None
334 self._ready: asyncio.Event = MISSING
335 self._application: Optional[AppInfo] = None
336 self._connection._get_websocket = self._get_websocket
337 self._connection._get_client = lambda: self
338
339 if VoiceClient.warn_nacl:
340 VoiceClient.warn_nacl = False
341 _log.warning('PyNaCl is not installed, voice will NOT be supported')
342
343 if VoiceClient.warn_dave:
344 VoiceClient.warn_dave = False
345 _log.warning('davey is not installed, voice will NOT be supported')
346
347 async def __aenter__(self) -> Self:
348 await self._async_setup_hook()

Callers

nothing calls this directly

Calls 4

_get_stateMethod · 0.95
HTTPClientClass · 0.85
popMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected