Metadata-Version: 2.1
Name: nextcore
Version: 2.0.2
Summary: A low level Discord API wrapper
Home-page: https://github.com/nextsnake/nextcore
License: MIT
Keywords: discord,bot,wrapper,api
Author: tag-epic
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Framework :: aiohttp
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Communications :: Chat
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Provides-Extra: speed
Requires-Dist: aiohttp (>=3.6.0,<4.0.0)
Requires-Dist: discord-typings (>=0.5.0,<0.6.0)
Requires-Dist: frozendict (>=2.3.0,<3.0.0)
Requires-Dist: orjson (>=3.6.8,<4.0.0) ; extra == "speed"
Requires-Dist: types-frozendict (>=2.0.6,<3.0.0)
Requires-Dist: types-orjson (>=3.6.2,<4.0.0) ; extra == "speed"
Requires-Dist: typing-extensions (>=4.1.1,<5.0.0)
Project-URL: Bug Tracker, https://github.com/nextsnake/nextcore/issues
Project-URL: Documentation, https://nextcore.readthedocs.io
Project-URL: Discord, https://discord.gg/3RFUm3eP5c
Project-URL: Repository, https://github.com/nextsnake/nextcore
Description-Content-Type: text/markdown

<div align="center">

  <img alt="" src="docs/_static/logo.svg" width="160px"/>
  
  # Nextcore
  <sub>A low level Discord API wrapper.</sub>
  
</div>

### ✨ Features

- #### Speed

  We try to make the library as fast as possible, without compromising on readability of the code or features.
  
- #### Modularity

  All the components can easily be swapped out with your own.

- #### Control

  Nextcore offers fine-grained control over things most libraries don't support.  
  
  This currently includes:  
  - Setting priority for individual requests
  - Swapping out components

<br>

<div align="center">

  # Examples
  
</div>

### 🏓 Ping pong
A simple "ping pong" example in nextcore.
This will respond with "pong" each time someone sends "ping" in the chat.
```py
import asyncio
from os import environ
from typing import cast

from discord_typings import MessageData

from nextcore.gateway import ShardManager
from nextcore.http import BotAuthentication, HTTPClient, Route

# Constants
AUTHENTICATION = BotAuthentication(environ["TOKEN"])

# Intents are a way to select what intents Discord should send to you.
# For a list of intents see https://discord.dev/topics/gateway#gateway-intents
GUILD_MESSAGES_INTENT = 1 << 9
MESSAGE_CONTENT_INTENT = 1 << 15

INTENTS = GUILD_MESSAGES_INTENT | MESSAGE_CONTENT_INTENT  # Guild messages and message content intents.


# Create a HTTPClient and a ShardManager.
# A ShardManager is just a neat wrapper around Shard objects.
http_client = HTTPClient()
shard_manager = ShardManager(AUTHENTICATION, INTENTS, http_client)


@shard_manager.event_dispatcher.listen("MESSAGE_CREATE")
async def on_message(message: MessageData):
    # This function will be called every time a message is sent.
    if message["content"] == "ping":
        # Send a pong message to respond.
        route = Route("POST", "/channels/{channel_id}/messages", channel_id=message["channel_id"])

        await http_client.request(
            route,
            rate_limit_key=AUTHENTICATION.rate_limit_key,
            json={"content": "pong"},
            headers=AUTHENTICATION.headers,
        )


async def main():
    await http_client.setup()

    # This should return once all shards have started to connect.
    # This does not mean they are connected.
    await shard_manager.connect()

    # Raise a error and exit whenever a critical error occurs
    (error,) = await shard_manager.dispatcher.wait_for(lambda: True, "critical")

    raise cast(Exception, error)


asyncio.run(main())
```

> More examples can be seen in the [examples](examples/) directory.

<br>

## Contributing
Want to help us out? Please read our [contributing](https://nextcore.readthedocs.io/en/latest/contributing/getting_started.html) docs.

